【拓扑排序】CODEVS 2833 奇怪的梦境
2014-11-06 11:26
330 查看
拓扑排序模板。
#include<cstdio> #include<vector> #include<stack> using namespace std; #define N 10001 vector<int>G ; stack<int>S; int n,m,x,y,ru ,tot; int main() { scanf("%d%d",&n,&m); for(int i=1;i<=m;i++) { scanf("%d%d",&x,&y); G[x].push_back(y); ru[y]++; } for(int i=1;i<=n;i++) if(!ru[i]) S.push(i); while(!S.empty()) { int U=S.top(); S.pop(); tot++; for(vector<int>::iterator it=G[U].begin();it!=G[U].end();it++) if(!(--ru[*it])) S.push(*it); } if(tot==n) puts("o(∩_∩)o"); else printf("T_T\n%d\n",n-tot); return 0; }
相关文章推荐
- codevs 2833 奇怪的梦境(拓扑排序)
- codevs 2833 奇怪的梦境(拓扑排序)
- codevs 2833 奇怪的梦境 题解报告
- CODEVS——T 2833 奇怪的梦境
- codevs奇怪的梦境(拓扑排序)
- Codevs 2833 奇怪的梦境
- codevs 2833 奇怪的梦境
- 奇怪的梦境(codevs 2833)
- Codevs 2833 奇怪的梦境
- codevs 2833 奇怪的梦境 拓扑排序
- codevs2833 2833 奇怪的梦境(拓扑排序)
- 【CS 2833】奇怪的梦境(拓扑排序top_sort)
- Codevs 2833 奇怪的梦境
- codevs2833 奇怪的梦境 x
- 奇怪的函数 (codevs 3538/1696) 题解
- 2833 奇怪的梦境
- 【CODEVS】2833 奇怪的梦境
- code(vs)2488 绿豆蛙的归宿(拓扑排序+动规)
- 【codevs2833】奇怪的梦境 拓扑排序
- 【codevs 2833】奇怪的梦境