Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
显示wrong answer,麻烦大神看看哪里错了~!~!#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator