hdu1285确定比赛名次
来源:互联网 发布:血手幽灵压枪数据 编辑:程序博客网 时间:2024/06/06 02:50
http://acm.hdu.edu.cn/showproblem.php?pid=1285
拓扑排序,邻接矩阵存储,注意重边
#include <stdio.h>#include <string.h>int adjMatrix[501][501],indegree[501];int n,m;void initTopo(){ int p1,p2; memset(indegree,0,sizeof(indegree)); memset(adjMatrix,0,sizeof(adjMatrix)); while(m--) { scanf("%d %d",&p1,&p2); if(adjMatrix[p1][p2]==0) { adjMatrix[p1][p2]=1; indegree[p2]++; } }}void topoSort(){ int i,j,count=0; while(count<n) { for(i=1;i<=n;i++) if(indegree[i]==0) { indegree[i]=-1; break; } if(count>0) printf(" "); printf("%d",i); count++; for(j=1;j<=n;j++) if(adjMatrix[i][j]) indegree[j]--; } printf("\n");}int main(){ while(~scanf("%d %d",&n,&m)) { initTopo(); topoSort(); } return 0;}
0 0
- hdu1285-确定比赛名次
- hdu1285确定比赛名次
- hdu1285 确定比赛名次
- HDU1285确定比赛名次
- HDU1285---确定比赛名次
- hdu1285确定比赛名次
- hdu1285确定比赛名次
- hdu1285 确定比赛名次
- HDU1285-确定比赛名次
- HDU1285 确定比赛名次
- HDU1285-确定比赛名次
- 【拓扑排序】 hdu1285 确定比赛名次
- hdu1285 确定比赛名次 拓扑排序
- 确定比赛名次(hdu1285拓扑排序)
- hdu1285 确定比赛名次 (拓扑排序)
- HDU1285——确定比赛名次
- HDU1285 确定比赛名次 拓扑排序
- Hdu1285 step5.2.5 确定比赛名次
- hdoj 2120 Ice_cream's world I 【判断成环】
- 关于sizeof 和strlen 的用法
- 反向代理服务器的工作原理
- Android Gradle 技巧之一: Build Variant 相关
- 编程之美之中国象棋问题
- hdu1285确定比赛名次
- win32API之InterlockedIncrement
- Kubernetes系统常见运维技巧
- 使用Handler中postDelayed方法实现广告页面无限循环轮播效果
- LB负载均衡中LVS搭建DR模式
- 计蒜之道-初赛2 A. 联想公司的 logo 设计
- javascript中attribute和property的区别详解
- Ghost windows7系统的连接网络的情况下网络连接图标为什么显示无网络访问
- 面试必问Top10(2016.06.06)