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

好像while( m -- ) 的确有问题,但是为什么最开始while( t -- )就没有问题呢……我也郁闷,检查一下

Posted by ACM06Louty at 2008-09-27 21:00:07
In Reply To:我也一直RE,不知道什么问题,能否帮忙看下,谢谢 Posted by:054100532 at 2008-09-27 20:51:15
> #include<stdio.h>
> 
> struct Node
> {
> 	int p,val;
> 	Node *next;
> 	Node(int _p,int _v){next=NULL;p=_p;val=_v;}
> };
> 
> struct List
> {
> 	Node *head;
> 	int flag;
> 	List(){head=new Node(0,0);}
> 	void set(){head->next=NULL;}
> 	void Insert(int p,int v)
> 	{
> 		Node *t=new Node(p,v);
> 		t->next=head->next;
> 		head->next=t;
> 	}
> }list[200200];
> 
> int queue[200200][3];
> 
> int main()
> {
> 	int T;
> 	while(scanf("%d", &T)!=EOF)
> 	{
> 		int ca = 1;
> 		for( ca=1; ca<=T; ca++ )
> 		{
> 			printf("Case %d: ", ca);
> 			int n,m,s;
> 			scanf("%d%d%d", &n, &m, &s);
> 			while( s >= n || s < 0 )
> 				printf("!!");
> 			int i;
> 			for( i=0; i<=n; i++ )
> 			{
> 				list[i].set();
> 				list[i].flag = 0;
> 			}
> 			while( m -- )
> 			{
> 				int a,b;
> 				scanf("%d%d", &a, &b);
> 				while( a >= n || a < 0 || b >= n || b < 0 )
> 				{
> 					printf("11");
> 				}
> 				list[a].Insert(b,0);
> 				list[b].Insert(a,0);
> 			}
> 			int l,r;
> 			l = 0;
> 			r = 0;
> 			queue[r][1] = 0;
> 			queue[r++][0] = s;
> 			list[s].flag = 1;
> 			int flag = 0;
> 			while( l < r )
> 			{
> 				int time = queue[l][1];
> 				int cur = queue[l++][0];
> 				Node * temp = list[cur].head->next;
> 				while( temp != NULL )
> 				{
> 					int t = temp->p;
> 					if( list[t].flag != 0 )
> 					{
> 						if( list[t].flag != ((time+1)%2) + 1)
> 							flag = 1;
> 					}
> 					else
> 					{
> 						queue[r][0] = t;
> 						queue[r++][1] = time+1;
> 						list[t].flag = ((time+1)%2) + 1;
> 					}
> 					temp = temp->next;
> 				}
> 			}
> 			if( r == n && flag == 1 )
> 				printf("YES\n");
> 			else
> 				printf("NO\n");
> 		}
> 	}
> 	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