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

数据真强啊,官方数据都通过,还是WR掉了。

Posted by 411465294 at 2008-04-04 11:48:02 on Problem 1029
#include <stdio.h>
int a[1006];
int b[1006];
int main()
{
	int N, M, left,i,j ,k =-1 , t;
	char str[5];
	scanf("%d%d",&N,&M);
	while(M--)
	{
		scanf("%d",&left);
		left *=2;
		for( i =0; i <  left ; i ++)
			scanf("%d",&b[i]);
		scanf("%s",str);
		switch(str[0])
		{
			case '=':
				{
					for( i =0 ;i < left ; i ++ )
						a[ b[ i ] - 1 ] = 1; 
					break;
				}
			case '<':
				{
					for( j =1 ; j <= N; j ++ )
					{
						for( i =0 ; i < left ; i ++ )
							if(j == b[i]) break;
						if(i >= left ) a[j-1] = 1; 
					}
					for( i = 0 ; i < left>>1 ; i ++ )
					{
						t = b[i] -1;
						if(a[t] == 1) continue;
						if( a[ t  ] == -1 ) a[ t ] = 1 ;
						else a[t] = -2;
					}
					for( ; i < left ; i ++ )
					{
						t = b[i] -1;
						if(a[t] == 1) continue;
						if( a[ t ] == -2 ) a[ t ] = 1 ;
						else a[t] = -1;
					}
					break;
				}
			default:
				{
					for( j =1 ; j <= N; j ++ )
					{
						for(int i =0 ; i < left ; i ++ )
							if(j == b[i]) break;
						if(i >= left ) a[j-1] = 1; 
					}
					for( i = 0 ; i < left>>1 ; i ++ )
					{
						t = b[i] -1;
						if(a[t] == 1) continue;
						if( a[ t ] == -2 ) a[ t ] = 1 ;
						else a[t] = -1;
					}
					for( ; i < left ; i ++ )
					{
						t = b[i] -1;
						if(a[t] == 1) continue;
						if( a[ t ] == -1 ) a[ t ] = 1 ;
						else a[t] = -2;
					}
					break;
				}
		}
	}
	for( i =0 ; i < N; i ++ )
		if(a[i] < 0 )
		{
			if(k == -1) k = i;
			else { k = -1 ; break;} 
		}
	if(i == N && k == -1) 
	{
		for( i =0 ; i < N; i ++ )
		if(a[i] == 0 )
		{
			if(k == -1) k = i;
			else { k = -1 ; break;} 
		}
	}
    printf("%d\n",++k);
	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