hdu1285拓扑排序
来源:互联网 发布:思源物业收费软件 编辑:程序博客网 时间:2024/05/03 13:14
#include <cstdio>#include <iostream>#include <cstring>using namespace std;int N, M, a, b, num;bool map[510][510];int temp[510], ans[510];int main(){while(scanf("%d %d", &N, &M)!= EOF){memset(temp, 0, sizeof(temp));memset(ans, 0, sizeof(ans));memset(map, 0, sizeof(map));num = 0;for(int i = 1; i <= M; i++){cin >> a >> b;if(!map[a][b]){temp[b] ++;}map[a][b] = true;}while(num <= N){int j = 1;while(temp[j] != 0){j++;if(j > N){break;}}temp[j] = -1;ans[num] = j;num++;for(int i = 1; i <= N; i++){if(map[j][i]){map[j][i] = false;temp[i]--;}}}for(int i = 0; i < num - 1; i++){if(i == num - 2){cout << ans[i] << endl;break;}cout << ans[i] << " ";}}return 0;}
0 0
- hdu1285拓扑排序
- HDU1285 拓扑排序
- HDU1285-拓扑排序
- hdu1285拓扑排序
- hdu1285(拓扑排序)
- hdu1285 拓扑排序
- hdu1285(拓扑排序)
- hdu1285+hdu2467(拓扑排序)
- hdu1285拓扑排序
- hdu1285 简单拓扑排序
- hdu1285(拓扑排序)
- hdu1285 & hdu4857 --拓扑排序
- hdu1285拓扑排序
- hdu1285(拓扑排序)
- hdu1285-拓扑排序
- hdu1285(拓扑排序)
- hdu1285及拓扑排序模板
- hdu1285 拓扑排序+优先队列
- 程序猿媳妇儿注意事项
- 获取路径
- 请大家远离偶,偶不是“好人”!
- Spring数据库访问之iBatis(一)
- Apache kafka 工作原理介绍
- hdu1285拓扑排序
- mac使用终端,拉取git上的工程
- activiti 动态表单+easyui 实现启动流程功能(三)
- 程序设计
- 你是码农还是优秀程序员?
- linux命令
- 建立全文索引
- 树状数组
- log4j.properties配置详解与实例-全部测试通过