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 |
太奇怪了,总是RE,,,为什么???????#include <iostream> #include <vector> using namespace std; int k,n,m; int begin[1001]; int res[1001]; vector<int> map[1001]; bool canGet[1001]={false}; void search(int b) { canGet[b]=true; for(int i=0;i<map[b].size();i++) search(map[b][i]); return; } int main() { memset(begin,false,sizeof(begin)); memset(res,false,sizeof(res)); memset(map,false,sizeof(map)); cin>>k>>n>>m; //k个牛,n个草坪,m条路 int i,j; for(i=1;i<=k;i++) scanf("%d",&begin[i]); for(i=1;i<=m;i++ ) { int a,b; scanf("%d %d",&a,&b); map[a].push_back(b); } for(i=1;i<=k;i++) { memset(canGet,false,sizeof(canGet)); search(begin[i]); //查询第i只牛,能够到达的草坪 for(j=1;j<=n;j++) if(canGet[j]==true)res[j]++; } int resNum=0; for(i=1;i<=n;i++) if(res[i]==k) resNum++; cout<<resNum<<endl; // system("pause"); return 1; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator