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 slwgu at 2005-06-29 01:58:29 on Problem 2446
我真的找不到 wa的情况.
请告诉我一些数据.
#include <iostream.h>

int a[34][34];
int b[34][34];
int ch;
int s;
int m,n,k;

void check(int sx,int sy, int ss)
{
	if (ss==s) ch=1;
	if (ch==1) return;
	if (sx==m && sy==(n+1)) return;
	if (sy==(n+1)) {sx++;sy=1;}

	int tx,ty;
	int tmp;

	if (b[sx][sy]!=0)
		check(sx,sy+1,ss);

	if (b[sx][sy]==0)
	{
		b[sx][sy]=1;
		tx=sx;ty=sy+1;
		if (b[tx][ty]==0)
		{
			if ((--a[sx+1][sy])==0) {a[sx+1][sy]++;goto nxt;}
			if ((--a[tx+1][ty])==0) {a[tx+1][ty]++;goto nxt;}
			if ((--a[tx][ty+1])==0) {a[tx][ty+1]++;goto nxt;}
			b[tx][ty]=1;
			check(sx,sy+1,ss+2);
			b[tx][ty]=0;
			if (ch==1) return;
			a[sx+1][sy]++;
			a[tx+1][ty]++;
			a[tx][ty+1]++;
		}
nxt:
		tx=sx+1;ty=sy;
		if (b[tx][ty]==0)
		{
			if ((--a[sx][sy+1])==0) {a[sx][sy+1]++;goto nxt1;}
			if ((--a[tx+1][ty])==0) {a[tx+1][ty]++;goto nxt1;}
			if ((--a[tx][ty+1])==0) {a[tx][ty+1]++;goto nxt1;}
			if ((--a[tx][ty-1])==0) {a[tx][ty-1]++;goto nxt1;}
			b[tx][ty]=1;
			check(sx,sy+1,ss+2);
			b[tx][ty]=0;
			if (ch==1) return;
			a[sx][sy+1]++;
			a[tx+1][ty]++;
			a[tx][ty+1]++;
			a[tx][ty-1]++;
		}
nxt1:
		b[sx][sy]=0;
	}
}

int main()
{
	int i,j;
	int x,y;
	cin>>m>>n>>k;
		for (i=0;i<=m+1;i++)
			for (j=0;j<=n+1;j++)
			{
				if ((i>0) && (i<=m) && (j>0) && (j<=n)) 
					a[i][j]=b[i][j]=0;
				else 
					a[i][j]=b[i][j]=-1;
			}
		for (i=0;i<k;i++)
		{
			cin>>x>>y;
			a[y][x]=b[y][x]=-1;
		}
		s=m*n-k;
		if (s%2==1)
		{
			cout<<"NO"<<endl;
			return 0;
		}

		ch=1;
		for (i=1;i<=m;i++)
			for (j=1;j<=n;j++)
			{
				if (a[i][j]==0)
				{
					if (a[i-1][j]!=-1) a[i][j]++;
					if (a[i+1][j]!=-1) a[i][j]++;
					if (a[i][j-1]!=-1) a[i][j]++;
					if (a[i][j+1]!=-1) a[i][j]++;
					if (a[i][j]==0) {ch=0; goto ext;}
				}
			}
ext:
		if (ch==0)
		{
			ch=0;
			check(1,1,0);
		}
		if (ch==1) cout<<"YES"<<endl; else cout<<"NO"<<endl;
	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