Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

这样会什么WA

Posted by superman2006 at 2007-09-12 22:09:42 on Problem 3272
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator