HDU1285确定比赛名次 + 拓扑排序
来源:互联网 发布:sql数据脱敏处理方法 编辑:程序博客网 时间:2024/05/17 03:01
原题连接:http://acm.hdu.edu.cn/showproblem.php?pid=1285
#include<stdio.h>#include<stdlib.h>#define Max 510typedef struct vert{int num; //结点编号struct vert* next;}G_v;typedef struct node{int InDgree,OutDgree; //出度和入度G_v* next;}G_n;G_n g[Max];void Init(){int i;for(i = 1;i < Max;i ++){g[i].InDgree = g[i].OutDgree = 0;g[i].next = NULL;}}void CreateGraph(int x,int y) //将y结点连到x节点上。{G_v* tmp = g[x].next;G_v* q = (G_v*)malloc(sizeof(G_v));q->next = NULL;q->num = y;if(tmp == NULL) g[x].next = q;else{while(tmp->next!=NULL)tmp = tmp->next;tmp->next = q;}g[x].OutDgree ++;g[y].InDgree ++;}void Top(int N){G_v *tmp;int i,count = 1;for(i = 1;i <= N;i ++){if(g[i].InDgree == 0){if(count == N)printf("%d\n",i);elseprintf("%d ",i);tmp = g[i].next;while(tmp){g[tmp->num].InDgree --;tmp = tmp->next;}i = 0; //返回重新检验所有点g[i].InDgree = --; //将已经输出的点排除count++;}}}int main(void){int N,M,x,y;Init();while(scanf("%d %d",&N,&M)!=EOF){Init();for(int i = 1;i <= M;i ++){scanf("%d %d",&x,&y);CreateGraph(x,y);}Top(N);}}
0 0
- 【拓扑排序】 hdu1285 确定比赛名次
- hdu1285 确定比赛名次 拓扑排序
- 确定比赛名次(hdu1285拓扑排序)
- hdu1285 确定比赛名次 (拓扑排序)
- HDU1285 确定比赛名次 拓扑排序
- hdu1285 确定比赛名次(拓扑排序)
- HDU1285 确定比赛名次 【拓扑排序】
- hdu1285 - 确定比赛名次 (拓扑排序)
- HDU1285 确定比赛名次(拓扑排序)
- HDU1285 确定比赛名次(拓扑排序)
- HDU1285确定比赛名次 + 拓扑排序
- hdu1285 确定比赛名次 (拓扑排序)
- Hdu1285 拓扑排序-确定比赛名次
- HDU1285确定比赛名次【拓扑排序】
- HDU1285确定比赛名次(拓扑排序)
- hdu1285 确定比赛名次 (简单拓扑排序)
- hdu1285 确定比赛名次(拓扑排序)
- HDU1285确定比赛名次(拓扑排序)
- 最长不重复子串(动态规划最长不重复子串+Hash)
- 25. Location hash 属性
- 旁路劫持攻
- 为宝宝冲奶粉,40度水还是70度水?
- POJ-1248
- HDU1285确定比赛名次 + 拓扑排序
- Linux管道的实现机制
- 二叉查找树的C语言实现
- afx_msg消息响应返回值LRESULT char*在多字节字符集下面就可以转换为CString
- -fPIC ppc_85xx-gcc -shared -fPIC liberr.c -o liberr.so
- form表单中onsubmit属性的作用
- python中的for循环
- linux切换文本-图形模式
- 搜索引擎搭建:heritrix+lucene