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

显示wrong answer,麻烦大神看看哪里错了~!~!

Posted by prowllw at 2011-02-23 20:33:29 on Problem 1164
#include "stdio.h"



char castle[51][51] = {0};
int nroom = 0;
int largest = 0;


void Count( int x, int y, int *sum)
{
	char east = 0, west = 0, south = 0, north = 0;
	(*sum)++;
	east = castle[x][y]&4;
	west = castle[x][y]&1;
	south = castle[x][y]&8;
	north = castle[x][y]&2;
	if( !east)
	{
		castle[x][y+1]=castle[x][y+1]|1;
		Count( x, y+1, sum);
		castle[x][y+1]=castle[x][y+1]-1;
	}
	if( !north)
	{
		castle[x-1][y]=castle[x-1][y]|8;
		Count( x-1, y, sum);
		castle[x-1][y]=castle[x-1][y]-8;
	}
	if( !west)
	{
		castle[x][y-1]=castle[x][y-1]|4;
		Count( x, y-1, sum);
		castle[x][y-1]=castle[x][y-1]-4;
	}
	if( !south)
	{
		castle[x+1][y]=castle[x+1][y]|2;
		Count( x+1, y, sum);
		castle[x+1][y]=castle[x+1][y]-2;
	}
	castle[x][y]=castle[x][y]|16;
	return;
}


int Room( int x, int y)
{
	int sum = 0;
	if( castle[x][y]&16)
	{
		return sum;
	}
	else
	{
		Count( x, y, &sum);
		return sum;
	}
}


int main( void)
{
	int size = 0;
	char x = 0, y = 0, i = 0, j = 0;
	scanf("%d%d", &x, &y);
	for( i = 0; i < x; i++)
	{
		for( j = 0; j < y; j++)
		{
			scanf("%d", &castle[i][j]);
		}
	}
	for( i = 0; i < x; i++)
	{
		for( j = 0; j < y; j++)
		{
			size = Room( i, j);
			if( size)
			{
				nroom++;
			}
			if( size > largest)
			{
				largest = size;
			}
		}
	}
	printf("%d\n%d", nroom, largest);
	return 1;
}

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