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 <iostream> #include <cstdio> using namespace std; #define N 50005 int num[N] ; int main() { int n , m ; int T = 1 ; while(scanf("%d %d" , &n , &m)==2){ if(n==0 && m==0) break; memset(num , 0 , (n+1)*sizeof(int)); int cnt = n ; for(int i = 0 ; i < m ; i++){ int a , b ; cin>>a>>b ; if(num[a] == 0 ){ num[a] = -1 ; if(num[b]!=-1) num[b] = 1 ; cnt--; } else if(num[b] == 0){ num[b] = -1 ; if(num[a]!=-1) num[a] = 1 ; cnt--; } } cout<<"Case "<<T<<": "<<cnt<<endl; T++; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator