Page 3 of 7

Posted: Mon May 05, 2003 3:34 pm
by Dominik Michniewski
If you have a lot of free time - you may try to send your personal access to do this job to judges :wink:

Best regards
DM

Re: the end to the WA mystery of 10279 Minesweeper

Posted: Wed May 07, 2003 4:34 pm
by bery olivier
stcheung wrote:Make sure you know it's a multiple input problem [...]
Hope this would end the WA mystery of this simple problem.
Thank a lot. I lost my source some time. I have it right now, did some modifications and got AC. :D

10279 - Minesweeper again - help

Posted: Mon Jun 09, 2003 4:46 am
by Almost Human
I don't get it... what is the meaning by this :

"If a mine has been touched, all positions with a mine should contain an asterisk. All other positions should contain a period."

Is that mean if a mine has been touched, we only have to output the map contains asteriks and periods ... ????

please help ...

code :

Code: Select all

#include <stdio.h>

char input[10][10] , click[10][10] , output[10][10] ;
int NumOfCase , grid ;

char process ( void ) ;

int main ( void )
{
  int i ;

/*  freopen ( "10279.in" , "r" , stdin ) ;
  freopen ( "10279.out" , "w" , stdout ) ;*/

  scanf ( "%i" , &NumOfCase ) ;

  while ( NumOfCase -- )
  {
	 scanf ( "%i" , &grid ) ;

	 for ( i = 0 ; i < grid ; i ++ )
		scanf ( "%s" , input[i] ) ;

	 for ( i = 0 ; i < grid ; i ++ )
		scanf ( "%s" , click[i] ) ;

	 if ( process ( ) )
	 {
		for ( i = 0 ; i < grid ; i ++ )
		  printf ( "%s\n" , output[i] ) ;
	 }
	 else
	 {
		for ( i = 0 ; i < grid ; i ++ )
		  printf ( "%s\n" , input[i] ) ;
	 }

	 printf ( "\n" ) ;
  }

  return 0 ;
}

char process ( void )
{
  int i , j , counter ;

  for ( i = 0 ; i < grid ; i ++ )
  {
	 for ( j = 0 ; j < grid ; j ++ )
		output[i][j] = '.' ;

	 output[i][j] = 0 ;
  }

  for ( i = 0 ; i < grid ; i ++ )
	 for ( j = 0 ; j < grid ; j ++ )
	 {
		if ( click[i][j] == 'x' )
		{
		  if ( input[i][j] == '*' )
			 return 0 ;

		  counter = 0 ;

		  if ( input[i-1][j-1] == '*' && i > 0 && j > 0 )
			 counter ++ ;
		  if ( input[i-1][j] == '*' && i > 0 )
			 counter ++ ;
		  if ( input[i-1][j+1] == '*' && i > 0 && j < grid - 1 )
			 counter ++ ;
		  if ( input[i][j-1] == '*' && j > 0 )
			 counter ++ ;
		  if ( input[i][j+1] == '*' && j < grid - 1 )
			 counter ++ ;
		  if ( input[i+1][j-1] == '*' && i < grid - 1 && j > 0 )
			 counter ++ ;
		  if ( input[i+1][j] == '*' && i < grid - 1 )
			 counter ++ ;
		  if ( input[i+1][j+1] == '*' && i < grid - 1 && j < grid - 1 )
			 counter ++ ;

		  output[i][j] = counter + '0' ;
		}
	 }

  return 1 ;
}

Posted: Mon Jun 09, 2003 9:24 am
by the LA-Z-BOy
to almost human:
Is that mean if a mine has been touched, we only have to output the map contains asteriks and periods ... ????
nop. the problem statement says:
Your output should represent the board, with each position filled in appropriately. Positions that have been touched and do not contain a mine should contain an integer between 0 and 8. If a mine has been touched, all positions with a mine should contain an asterisk. All other positions should contain a period.
here All other positions means all untouched positions that have no mines.
if any mine(s) has been touched then show all mines with asterisks and other unmined touched position with number and rest untouched positions with a period.
input:

Code: Select all

8 
...**..* 
......*. 
....*... 
........ 
........ 
.....*.. 
...**.*. 
.....*.. 
xxxxxxxx 
xxxx.... 
xxxx.... 
xxxxx... 
xxxxx... 
xxxxx... 
xxx..... 
xxxxx...
output:

Code: Select all

001**22* 
0013..*. 
0001*... 
00011... 
00001... 
00123*.. 
001**.*. 
00123*..
tell us if you still got problem.
btw. this was discussed in previous board topics.
thanks.

Posted: Tue Jun 10, 2003 9:26 am
by Almost Human
I'd changed my code, but it still got Wrong Answer ... but thanks for your help...

any suggestion ... ?

Code: Select all

#include <stdio.h>

char input[10][10] , click[10][10] , output[10][10] ;
int NumOfCase , grid ;

void process ( void ) ;

int main ( void )
{
  int i ;

/*  freopen ( "10279.in" , "r" , stdin ) ;
  freopen ( "10279.out" , "w" , stdout ) ;*/

  scanf ( "%i" , &NumOfCase ) ;

  while ( NumOfCase -- )
  {
	 scanf ( "%i" , &grid ) ;

	 for ( i = 0 ; i < grid ; i ++ )
		scanf ( "%s" , input[i] ) ;

	 for ( i = 0 ; i < grid ; i ++ )
		scanf ( "%s" , click[i] ) ;

	 process ( ) ;

	 for ( i = 0 ; i < grid ; i ++ )
		printf ( "%s\n" , output[i] ) ;

	 if ( NumOfCase ) printf ( "\n" ) ;
  }

  return 0 ;
}

void process ( void )
{
  int i , j , k , l , counter ;
  char kaboom = 0 ;

  for ( i = 0 ; i < grid ; i ++ )
  {
	 for ( j = 0 ; j < grid ; j ++ )
		output[i][j] = '.' ;

	 output[i][j] = 0 ;
  }

  for ( i = 0 ; i < grid ; i ++ )
	 for ( j = 0 ; j < grid ; j ++ )
	 {
		if ( click[i][j] == 'x' )
		{
		  if ( input[i][j] == '*' )
		  {
			 if ( kaboom == 0 )
			 {
				kaboom = 1 ;

				for ( k = 0 ; k < grid ; k ++ )
				  for ( l = 0 ; l < grid ; l ++ )
				  {
					 if ( input[k][l] == '*' )
						output[k][l] = '*' ;
				  }
			 }
		  }
		  else
		  {
			 counter = 0 ;

			 if ( input[i-1][j-1] == '*' && i > 0 && j > 0 )
				counter ++ ;
			 if ( input[i-1][j] == '*' && i > 0 )
				counter ++ ;
			 if ( input[i-1][j+1] == '*' && i > 0 && j < grid - 1 )
				counter ++ ;
			 if ( input[i][j-1] == '*' && j > 0 )
				counter ++ ;
			 if ( input[i][j+1] == '*' && j < grid - 1 )
				counter ++ ;
			 if ( input[i+1][j-1] == '*' && i < grid - 1 && j > 0 )
				counter ++ ;
			 if ( input[i+1][j] == '*' && i < grid - 1 )
				counter ++ ;
			 if ( input[i+1][j+1] == '*' && i < grid - 1 && j < grid - 1 )
				counter ++ ;

			 output[i][j] = counter + '0' ;
		  }
		}
	 }
}

Posted: Tue Jun 10, 2003 1:48 pm
by the LA-Z-BOy
hey, don't you think your input and output buffers are smaller than needed?

Code: Select all

char input[10][10] , click[10][10] , output[10][10] ;
input is supposed to be <=10 lines and <=10 chars at each line. so your buffer should be 1 char bigger than now...(to hold the terminating '\0')...

Code: Select all

char input[10][11] , click[10][11] , output[10][11] ;
that's enough...
Greetings

Posted: Wed Jun 11, 2003 3:21 am
by Almost Human
What a stupid mistake ...

I thought the maximum grid is 8 * 8 ... I didn't read it correctly...

thank you very much the LA-Z-BOy. I finally got AC ...

10279 Runtime Error! Help!

Posted: Sun Jul 27, 2003 7:09 pm
by mafattah
My program compiles and runs correctly on my test cases, but produces run-time error on the judge. I do not see why. Can anybody help?
[cpp]
#include <iostream.h>

void main() {
int n;
int i, j;
char minearray[12][12];
char inarray[12][12];
int calcarray[12][12];

for (i = 0; i <= 11; i++)
for (j = 0; j <= 11; j++) {
minearray[j] = '.';
inarray[j] = '.';
calcarray[j] = 0;
}
cin >> n;
for (i = 1; i <= n; i++)
for (j = 1; j <= n; j++) {
cin >> minearray[j];
}
char temp;
for (i = 1; i <= n; i++)
for (j = 1; j <= n; j++) {
cin >> temp;
inarray[j] = temp;
if (temp == 'x') {
if (minearray[j] == '*') {
for (int k = 1; k <= n; k++)
for (int l = 1; l <= n; l++)
if (minearray[k][l] == '*') calcarray[k][l] = -1;
}
else {
if (minearray[i-1][j-1] == '*') calcarray[j]++;
if (minearray[i-1][j] == '*') calcarray[j]++;
if (minearray[i-1][j+1] == '*') calcarray[j]++;
if (minearray[j-1] == '*') calcarray[i][j]++;
if (minearray[i][j+1] == '*') calcarray[i][j]++;
if (minearray[i+1][j-1] == '*') calcarray[i][j]++;
if (minearray[i+1][j] == '*') calcarray[i][j]++;
if (minearray[i+1][j+1] == '*') calcarray[i][j]++;
}
}
}
for (i = 1; i <= n; i++) {
for (j = 1; j <= n; j++) {
if (calcarray[i][j] == -1) cout << '*';
else if (inarray[i][j] == '.') cout << '.';
else cout << calcarray[i][j];
}
cout << endl;
}

}
[/cpp]

Posted: Sun Jul 27, 2003 8:21 pm
by Adrian Kuegel
The problem is in multiple input format (blue checkmark).
Unfortunately the link given in the head of each volume isn't working any more, so here in short how to read/process the input:
Input:
number of test cases
<blank line>
test case 1 in the format like described in the problem description
<blank line>
test case 2
...
<blank line>
last test case

that means the test cases are separated by blank lines

Output:
print the output for each test case and separate outputs with blank lines.

10279 - Mine Sweeper

Posted: Wed Mar 10, 2004 12:05 pm
by WR
Hi,

I don't quite understand the input/output format specification of this
problem.

This problem has no blue check mark, but the description
clearly indicates multiple input. That's true?

As to the output the description says:
Print a blank line between each consecutive 2 consecutive data sets.
Does this mean an additional empty line or does it mean to print
two data sets without any separation and only then output a blank
line? (Btw "consecutive 2 consecutive" is probably a typo?!?)

Well, I submitted both versions, but earned a WA. So there's another
problem. I just want to make sure it's not I/O related.

Thanks in advance

look at this

Posted: Wed Mar 10, 2004 12:59 pm
by sohel
Hi WR,

here is how the input and output data is set.

Input:

3

8
...**..*
......*.
....*...
........
........
.....*..
...**.*.
.....*..
xxx.....
xxxx....
xxxx....
xxxxx...
xxxxx...
xxxxx...
xxx.....
xxxxx...

8
...**..*
......*.
....*...
........
........
.....*..
...**.*.
.....*..
xxx.....
xxxx....
xxxx....
xxxxx...
xxxxx...
xxxxx...
xxx.....
xxxxx...

8
...**..*
......*.
....*...
........
........
.....*..
...**.*.
.....*..
xxx.....
xxxx....
xxxx....
xxxxx...
xxxxx...
xxxxx...
xxx.....
xxxxx...





Output:

001.....
0013....
0001....
00011...
00001...
00123...
001.....
00123...

001.....
0013....
0001....
00011...
00001...
00123...
001.....
00123...

001.....
0013....
0001....
00011...
00001...
00123...
001.....
00123...


Hope it helps.
:wink:

Posted: Wed Mar 10, 2004 4:34 pm
by WR
Thanks Sohel,

I thought as much, but wasn't too sure.

My first version was correct as far as the I/O is concerned.

So now I have to look for the serious errors.

Thanks again!

10279

Posted: Mon Feb 21, 2005 9:11 pm
by ibrahim
What's the wrong with my code.

Code: Select all

Removed after got AC
Please help me. :-?

Posted: Mon Feb 21, 2005 9:21 pm
by Destination Goa
I think "<= siz" should be "< siz" everywhere in your code. In 'C' it is convenient to think of array segments in form [a;b), and you do when you read a[j] (i<siz, j<siz), but not in further comparisons.

Posted: Mon Feb 21, 2005 10:20 pm
by ibrahim
Destination Goa wrote:I think "<= siz" should be "< siz" everywhere in your code. In 'C' it is convenient to think of array segments in form [a;b), and you do when you read a[j] (i<siz, j<siz), but not in further comparisons.

Thanks for your response, but i am still WA (After the change) :(