poj 2367
来源:互联网 发布:苏州110网络报警平台 编辑:程序博客网 时间:2024/06/11 22:30
#include<iostream>using namespace std;struct EDGE{int v,next;}e[200];int head[200],k,intdegree[200],queue[200],a[200];void insert(int u,int v){e[k].v=v;e[k].next=head[u];head[u]=k++;}int tuopu(int n){int i,u,r=0,f=0,j=0; for(i=1;i<=n;i++)if(intdegree[i]==0) //存的是起点的入度queue[r++]=i; // 存的是入度为0的起点while(f<r){u=queue[f++];a[j++]=u;for(i=head[u];i!=-1;i=e[i].next){intdegree[e[i].v]--;if(intdegree[e[i].v]==0)queue[r++]=e[i].v;}}return j;}int main(){memset(head,-1,sizeof(head));memset(intdegree,0,sizeof(intdegree));k=0;int n,i,j,v;cin>>n;for(i=1;i<=n;i++){while(cin>>v&&v){insert(i,v);intdegree[v]++;}}j=tuopu(n);for(i=0;i<j-1;i++)cout<<a[i]<<" ";cout<<a[i]<<endl;}
0 0
- POJ 2367
- poj 2367
- poj 2367
- (2367)POJ
- poj 2367
- poj 2367
- poj 2367 Genealogical tree
- poj 2367 Genealogical tree
- poj 2367 Genealogical tree
- POJ 2367 Topology
- POJ 2367 Genealogical tree
- poj 2367 拓扑排序
- poj 2367 Genealogical tree
- poj 2367 Genealogical tree
- POJ 2367 topological_sort
- POJ 2367 Genealogical tree
- poj 2367 拓扑排序
- poj 2367 拓扑排序
- 基于Canvas的Char.js库使用
- HTML5的图像系统Canvas与SVG
- 九度题目1011:最大连续子序列
- Linux下配置Xdebug调试(xdebug-2.2.5)
- java实现Excel导出
- poj 2367
- 学生信息管理系统-垫脚石(三)
- Codeforces Round #256 (Div. 2)
- 黑名单拦截之SQLite的用法
- 畅通工程续(HDU 1874)
- poj 2019 Cornfields(二维RMQ)
- wait() waitpid()信号返回 进程和子进程
- 卷积神经网络
- The old Padawan(二分)