hdu_1285 确定比赛名次 (拓扑排序)
来源:互联网 发布:python 加载c 静态库 编辑:程序博客网 时间:2024/05/18 09:55
http://acm.hdu.edu.cn/showproblem.php?pid=1285
分析: 拓扑排序
代码:
//hdu1285 确定比赛名次#include <iostream>#include <stdio.h>#include <string.h>#include <string>#include <stack>using namespace std;#define N 504int edge[N][N],indegree[N]; //事先初始化int c[N];int n,m;void PoloOrder(){for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)if(edge[i][j]) indegree[j]++; for(int i=1;i<=n;i++){int j=1;while(indegree[j]!=0) j++;c[i]=j;indegree[j]--;for(int k=1;k<=n;k++)if(edge[j][k]) indegree[k]--;}for(int i=1;i<n;i++) printf("%d ",c[i]);printf("%d\n",c[n]); }int main(){ int a,b; //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); while(scanf("%d%d",&n,&m)!=EOF){ memset(edge,0,sizeof(edge)); memset(indegree,0,sizeof(indegree)); for(int i=1;i<=m;i++){ scanf("%d%d",&a,&b); edge[a][b]=1; } PoloOrder(); } return 0;}
- hdu_1285 确定比赛名次 (拓扑排序)
- 拓扑排序-- 确定比赛名次
- HDOJ 1285:确定比赛名次 拓扑排序
- 【拓扑排序】 hdu1285 确定比赛名次
- hdu 确定比赛名次(拓扑排序)
- 确定比赛名次(拓扑排序)
- HDU 1285 拓扑排序 确定比赛名次
- HDU 1285 拓扑排序-- 确定比赛名次
- HDOJ1285 确定比赛名次(拓扑排序)
- 确定比赛名次 (拓扑排序)
- hdu 1285 确定比赛名次(拓扑排序)
- hdu1285 确定比赛名次 拓扑排序
- 确定比赛名次(hdu1285拓扑排序)
- hdu1285 确定比赛名次 (拓扑排序)
- HDU1285 确定比赛名次 拓扑排序
- 拓扑排序——确定比赛名次
- hdu1285 确定比赛名次(拓扑排序)
- 确定比赛名次(拓扑排序)
- javascript中的position的说明
- 上传的速度,表示(关键是精确) BigDecima
- python实现排序算法目录
- 随笔2013.11.24
- CODE 138: Linked List Cycle
- hdu_1285 确定比赛名次 (拓扑排序)
- android viewpager 动态从网络获取图片
- leetcode Linked List Cycle II
- 在线网络考试系统
- 两分钟彻底让你明白Android Activity生命周期(图文)!
- Shuttle Puzzle
- ASM(Active Shape Model)算法介绍
- ungetc()
- 新课程选修课选课系统_校本课程选课系统