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

求助:1021的以下代码

Posted by s310060011 at 2010-12-11 10:42:57 on Problem 1021
/*
poj1021:棋盘同构问题

*/
#include <stdio.h>
#include <string.h>
#define N 105


int X[N][N];
int Y[N][N];
int count_X[10005];
int count_Y[10005];
void cal(int W,int H,int X[N][N],int *count)
{
	int sum;
	int i,j;
	for (i=0;i<H;i++)
	{ 
		sum=0;
		for(j=0;j<W;j++)
		{
			if(X[i][j]==1&&j!=W-1) 
			{
				sum++;	
			}
			if(X[i][j]==1&&j==W-1)
			{
				sum++;
				count[sum]++;
			}
			if(X[i][j]==0)
			{	
				count[sum]++;
				sum=0;
			}
		}
	}
	
	
	for(j=0;j<W;j++)
	{
		sum=0;
		for(i=0;i<H;i++)
		{
			if(X[i][j]==1&&i!=H-1) 
			{
				sum++;	
			}
			if(X[i][j]==1&&i==H-1)
			{
				sum++;
				count[sum]++;
				
			}
			if(X[i][j]==0)
			{
				count[sum]++;
				sum=0;
			}
		}
	}
	
	
}

int main()
{
	int te;
	int W,H,n;
	int i,j;
	scanf("%d",&te);
	for(i=1;i<=te;i++)
	{
		int xi,yi;
		int xj,yj;
		scanf("%d%d%d",&W,&H,&n);
		for(int i=0;i<H;i++)
		{
			for(int j=0;j<W;j++)
			{
				X[i][j]=0;
				Y[i][j]=0;
			}
		}	
		
		for(i=1;i<=n;i++)
		{
			scanf("%d%d",&xi,&yi);
			X[yi][xi]=1;
		}
		
		for(j=1;j<=n;j++)
		{
			scanf("%d%d",&xj,&yj);
			Y[yj][xj]=1;
		}
		
		
		for(i=0;i<10005;i++)
		{
			count_X[i]=0;
			count_Y[i]=0;
		}
		
		
		cal(W,H,X,count_X);
		cal(W,H,Y,count_Y);
        
		/*		printf("The content of the count_X:\n");
		for (i=1;i<=10;i++)
		{
		printf("%d ",count_X[i]);
		}
		printf("\n");
		
		  printf("The content of the count_Y:\n");
		  for (i=1;i<=10;i++)
		  {
		  printf("%d ",count_Y[i]);
		  }
		  
			printf("\n");
			for(i=H-1;i>=0;i--)
			{
			for(j=0;j<W;j++)
			{
			printf("%d ",X[i][j]);
			}
			printf("\n");
			}
			
		*/
		
		
		
		int flag=0;
		for(i=1;i<=100;i++)
		{
			if(count_X[i]!=count_Y[i])
			{
				flag=1;
				break;
			}
		}
		
		if(flag==0)
			printf("YES\n");
		else if(flag==1)
			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