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 denganliang at 2011-03-19 11:50:12 on Problem 1029
#include<stdio.h>
#include<string.h>
int value[101],d[101],temp[101],t[101];
int main(){
   int a,b,i,j,n,flag=0,count=0,k,m,num,e,f,find,h=0;
   char ch;
   while(scanf("%d %d",&a,&b)!=EOF){
	   if(h==1) printf("\n");
	   flag=0;
	   k=0;
	   num=0;
	   count=0;
	   for(i=1;i<=a;i++)
	     value[i]=d[i]=temp[i]=t[101]=0;
	     getchar();//接收换行
	   for(j=0;j<b;j++){
	       ch=getchar();
	       m=ch-'0';
	       n=2*m;
	       for(i=0;i<n;i++)
	          {
				  ch=getchar();
				  ch=getchar();
				  t[i]=ch-'0';
				  }
			getchar();//接收换行  
		     ch=getchar();
	        if(ch=='=')
	          for(i=0;i<n;i++)
	             temp[t[i]]=1;
	         else{
				 for(e=1;e<=a;e++)
				   {
					   find=0;
					   for(f=0;f<n;f++)
					     {
							 if(e==t[f]){
								 find=1;
							   break;
                           }
                           }
                         if(find==0) temp[e]=1;
					   }
				 
				 count++;
				 if(ch=='<'){
	          for(i=0;i<m;i++)
	             value[t[i]]++;
	          for(;i<n;i++)
	             d[t[i]]++;
	             }
	             else {
				for(i=0;i<m;i++)
	             d[t[i]]++;
	          for(;i<n;i++)
	             value[t[i]]++;
					 
					 }
	             }
	         getchar();
	             
	      }
	      for(i=1;i<=a;i++)
            {
				if(temp[i]==1) continue;
				if((value[i]==d[i])||(count!=1&&value[i]==1&&d[i]==0)||(count!=1&&value[i]==0&&d[i]==1)) 
				   {
					   temp[i]=1;
					   }
			     if(value[i]==count||d[i]==count)
			     {
					 k=i;
					 flag=1;
					 num++;
					 }
					   
				}	
				h=1;		
	       if(flag==0||num>1)  printf("0");	
	       else printf("%d",k);
	            
 	   }
   return 0;
}
基本上把讨论的所有的数据都过了,还是wa,求解释

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