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

各位大牛帮忙看下。

Posted by 1195927822 at 2011-02-17 16:03:05 on Problem 2524
这个程序通过了样例。可是提交后是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:
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