poj 2367 Genealogical tree
来源:互联网 发布:parsley.js 手册 编辑:程序博客网 时间:2024/05/17 01:32
裸的拓扑排序。
#include <iostream>#include<stdio.h>#include<cstring>#include<vector>using namespace std;vector<int>a[105];int from[105],to[105],flag[105];//出度,入度,标记是否访问过int main(){ int n,temp; scanf("%d",&n); memset(from,0,sizeof(from)); memset(to,0,sizeof(to)); memset(flag,0,sizeof(flag)); for(int i=1;i<=n;i++){ while(scanf("%d",&temp),temp){ a[i].push_back(temp); from[i]++; to[temp]++; } } int count=0; while(count!=n){ for(int i=1;i<=n;i++){ if(to[i]==0&&flag[i]==0){ count++; printf("%d ",i); flag[i]=1; int len=a[i].size(); for(int j=0;j<len;j++){ to[a[i][j]]--; } } } } printf("\n"); return 0;}
- poj 2367 Genealogical tree
- poj 2367 Genealogical tree
- poj 2367 Genealogical tree
- POJ 2367 Genealogical tree
- poj 2367 Genealogical tree
- poj 2367 Genealogical tree
- POJ 2367 Genealogical tree
- POJ 2367 Genealogical tree
- POJ--2367--Genealogical tree
- poj-2367 Genealogical tree
- poj 2367 Genealogical tree
- POJ 2367 Genealogical tree
- poj 2367 Genealogical tree
- POJ 2367 Genealogical tree
- 【POJ 2367 Genealogical tree】
- POJ 2367Genealogical tree
- 【POJ】[2367]Genealogical tree
- poj 2367 Genealogical tree
- hdu 1811 Rank of Tetris
- hdu 1158 Employment Planning
- poj 1018 Communication System
- hdu 1827 Summer Holiday
- hdu 1295 Move Move Look
- poj 2367 Genealogical tree
- poj 3660 Cow Contest
- poj 3553 Task schedule
- C++ 简单实现HTTP GET/POST 请求
- poj 2488 A Knight's Journey
- 问题集2
- How compiler works
- AjaxPro版自动完成(Autocomplete)功能实现
- Silverlight访问页面dom元素