Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
这样会什么WA#include<cstdio> #include<algorithm> #include<vector> using namespace std; vector<int>map[5005]; int in[5005]; int dfs(int v0) {int sum=0; if(map[v0].size()==0) return 1; else for(int i=0;i<map[v0].size();i++) sum+=dfs(map[v0][i]); return sum; } int main() {int i,j,k,m,n; int x,y; while(1) { scanf("%d%d",&n,&m); for(i=1;i<=m;i++) { scanf("%d%d",&x,&y); map[x].push_back(y); in[y]=1; } int ans=0; for(i=1;i<=n;i++) { if(in[i]==0){ans+=dfs(i);} } printf("%d\n",ans); break; } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator