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了~~郁闷~~调试了N久!··谁有测试数据也说下~~#include<iostream> using namespace std; int way[10000][2]; int rea[1000]; bool vis[1000]; int k, n, m; void work(int a) { int j; for(j = 0; j < n; j ++) if( a == way[j][0] && vis[way[j][1]] == false) { rea[way[j][1]] ++; vis[way[j][1]] = true; work(way[j][1]); } } int main() { while( 3 == scanf("%d %d %d", &k, &n, &m) ) { int i; int* cow = new int [n]; for(i = 0; i < k; i ++ ) scanf("%d", &cow[i]); for(i = 0; i < m; i ++ ) scanf("%d %d", &way[i][0], &way[i][1] ); memset(rea, 0, sizeof(rea) ); for(i = 0; i < k; i ++) { memset(vis,false, sizeof(vis)); vis[cow[i]] = true; rea[cow[i]] ++; work(cow[i]); } int cnt = 0; for(i = 1; i <= n; i ++) if(rea[i] == k) cnt ++; printf("%d\n", cnt); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator