Page 1 of 28

10189

Posted: Thu Oct 03, 2002 12:32 pm
by liusu
why i got WA again and again? are there special inputs? thanks :cry:

Posted: Fri Oct 04, 2002 1:21 pm
by Ghost77 dimen
I am afraid not.

Maybe something wrong in your code,because I got A.C. at once.

Posted: Mon Dec 23, 2002 7:40 pm
by deddy one
to liusu:

if you haven't it AC yet,
maybe you got the same problem with me few while ago

try to use bigger array

10189 Easy but dunno why wrong answer....sigh.....

Posted: Fri Jan 17, 2003 9:51 pm
by vancelee
:( this is an easy one........ but I still always get wrong answer when submitting to the online judge, I have tested the program with some cases and getting all-correct result.

May anyone please help me to see what's go wrong....?? thanks!!

[c]
/* @JUDGE_ID: 27296JC 10189 C "aaa" */
/* CSC1140@ 02759173 jl3Rjjtv 10189*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

int main(int argc, char *argv[])
{
/* height and width store the input height and width of the board */
int i, j, height, width, cno;
/* the board stores the minesweeper board */
char board[200][200];
char temp[200][200];

for(cno = 0; ; cno++)
{
/* get the height and width of the first board */
scanf("%d %d", &height, &width);
if(height == 0 && width == 0)
break;

if(cno > 0)
printf("\n");

/* get the input board */
for (i=0; i< height; i++)
scanf("%s", board);

for (i=0; i<200; i++){
for (j=0;j<200; j++){
temp[j]=48;
}
}

for (i=0;i<width;i++){
for (j=0;j<height;j++){
if (board[j]=='*'){
if (i>0 && j>0 && board[i-1][j-1]!='*'){ temp[i-1][j-1]+=1;}
if (j>0 && board[j-1]!='*'){ temp[j-1]+=1;}
if (i<200-1 && j>0 && board[i+1][j-1]!='*'){ temp[i+1][j-1]+=1;}
if (i>0 && board[i-1][j]!='*'){ temp[i-1][j]+=1;}
if (i<200-1 && board[i+1][j]!='*') {temp[i+1][j]+=1;}
if (i>0 && j<200-1 && board[i-1][j+1]!='*'){ temp[i-1][j+1]+=1;}
if (j<200-1 && board[j+1]!='*') {temp[j+1]+=1;}
if (j<200-1 && board[i+1][j+1]!='*') {temp[i+1][j+1]+=1;}
temp[j]='*';
}
}
}




printf("Field #%d:\n", cno + 1);
for (i=0; i< height; i++)
{
for (j=0; j< width; j++)
printf("%c", temp[j]);
printf("\n");
}
}

return 0;
}
[/c]

10196 - Check The Check

Posted: Thu Jun 26, 2003 3:44 am
by AllanLin
Dear EVERYONE!

I'm am not sure how to send my programs into the ACM grader...

Here is my program from MINESWEEPER , ID # 10189
Please Help me Find out what is Wrong!
its keeps saying Compiner Error :o

[c]
#include<stdio.h>

int m,n;
char field[100][100]={0};
int map [100][100]={0};

main()
{
int i,j;
char ch;

scanf("%d%d",&m,&n);
while(( m != 0) && ( n!=0 ))
{
//RESET//
for(i=0;i<100;i++)
for(j=0;j<100;j++)
{field[j]=0;
map[j]=0;}

//INPUT//
for(i=1;i<=m;i++)
{ scanf("%c",&ch);
for(j=1;j<=n;j++)
scanf("%c",&field[j]);}

//WORK//
for(i=1;i<=m;i++)
for(j=1;j<=n;j++)
if(field[j] == '*')
{ map[i+1][j+0] ++;
map[i+1][j+1] ++;
map[i+1][j-1] ++;
map[i+0][j+1] ++;
map[i+0][j-1] ++;
map[i-1][j+0] ++;
map[i-1][j+1] ++;
map[i-1][j-1] ++;}

//OUTPUT//
for(i=1;i<=m;i++)
{for(j=1;j<=n;j++)
if(field[j] == '*') printf("*");
else printf("%d",map[j]);
printf("\n");}

scanf("%d%d",&m,&n);
}
}[/c]








:evil: errrrrrrrr why won't it work!

Posted: Thu Jun 26, 2003 7:38 pm
by Moni
Welcome! Allan!

I have compiled your code and got only one warning.........

your main function should return a value........


One very important thing.............

Try to post your threads in the related topic..........you may use the volume or language C section for this.........


Carry on :)

Posted: Thu Jun 26, 2003 10:30 pm
by Adrian Kuegel
Did you submit this code as C programming language? You cannot use // comments in ANSI C, only in C++.

Thank You Everyone

Posted: Sat Jun 28, 2003 3:30 am
by AllanLin
I am very lucky to decided to start this ACM training. I have complety amazed with everyone!

Everyone Cares.. and helps those in need.

Thank You! You Guys the best


Yours
Allan Lin
:D

10189 W.A

Posted: Wed Jul 23, 2003 5:27 am
by lendlice
[cpp]//10189
#include<stdio.h>
main()
{
char in[100][100],out[100][100];
int n,m,i=0,j=0,now=1;
while(scanf("%d%d%*c",&n,&m)==2)
{
if(n==0&&m==0)
break;
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
scanf("%c",&in[j]);
out[j]='0';
}
scanf("%*c");
}
for(i=0;i<n;i++)
for(j=0;j<m;j++)
{
if(in[j]=='*')
{
out[j]=in[j];
if(i>0&&in[i-1][j]!='*')
out[i-1][j]++;
if(i+1<=n&&in[i+1][j]!='*')
out[i+1][j]++;
if(j+1<=m&&in[j+1]!='*')
out[j+1]++;
if(j>0&&in[j-1]!='*')
out[j-1]++;
if(i>0&&j>0&&in[i-1][j-1]!='*')
out[i-1][j-1]++;
if(i+1<n&&j>0&&in[i+1][j-1]!='*')
out[i+1][j-1]++;
if(i>0&&j<m&&in[i-1][j+1]!='*')
out[i-1][j+1]++;
if(i<n&&j<m&&in[i+1][j+1]!='*')
out[i+1][j+1]++;
}
}
printf("Field #%d:\n",now);
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
printf("%c",out[j]);
printf("\n");
}
printf("\n");
now++;
}
}[/cpp]
Anyone can help.
I got W.A.
Thanks

Posted: Thu Jul 31, 2003 6:12 am
by UFP2161
Increase your array (out) size to 101.

On a 100x100 board, you sometimes attempt to increase out[x][100], which in memory is the same as out[x+1][0] and is thus incrementing something you don't want to.

Also, you can make the array size 102 and start everything at 1, so you don't have to worry about indexes going below 0 as well, and eliminate the bounds checking altogether.

Alternatively, you can just fix your bounds checking, but the above recommendation is probably quicker.

Posted: Thu Jul 31, 2003 7:26 pm
by Larry
A cleaner way to write this instead of all those statements are:

Code: Select all

int dx[] = { 1, 1, 1, 0, 0, -1, -1, -1 };
int dy[] = { 1, -1, 0, 1, -1, 1, 0, -1 };
for ( i = 0; i < 8; i++ )
   /*  Check stuff with x + dx[i] and y + dy[i] */
Makes it easier to read/write and less error prone..

10189 - Minesweeper: AC but still...

Posted: Thu Aug 21, 2003 3:45 pm
by toren
Look at the response i got after submitting the solution:

[BEGIN]
Your C++ program has solved Ok the problem 10189 (Minesweeper)
in 0.018 seconds with low memory spent.
Congratulations!

Warning: Your program would get a Presentation Error in a true contest.
The 24-hours judge interpretes it as an "Accepted" problem.
[END]

What does this really mean? I should also mention that i got
WA at http://www.programming-challenges.com. Weird.

--
Tore Nedretvedt

Posted: Thu Aug 21, 2003 3:56 pm
by toren
Fixed the problem. I just had to remove the newline after the last field.

--
Tore Nedretvedt

Posted: Thu Aug 21, 2003 4:42 pm
by Julien Cornebise
Hi Tore
PE (or Presentation Error) happens when you've got presentation problems, such as leading or trailing white spaces or new lines, or sometimes trickier errors (but rarely, designing a judge able to deal with complicated errors of that kind is tricky). At the real time contest, you'd have WA.
Programming challenges isn't as nice as uva, talking about PE or even in general : look at its board : very many people are complaining about uva's AC problems, and WA on p-c. I agree that p-c might be testing some trickier input than uva, but it doesn't explain why SO MANY problems arise. Problems in latency time in answers, or running time much slower than UVA, etc, are also reported.
I've been really disapointed by programming-challenges. In my opinion, The book is as good as the site is bad : while the book is good, with a few bad points, the site is bad, with a (very) few good points.
So let's take best of both worlds : Programming challenges Book, and UVA website :)
To conclude on P-c, I would say that it is a fairly good introduction to Skiena's reference : Algorithm design manual. I learned a lot by beginning a subject with p-c and goind deeper with adm (for Dynamic Programming, specially).

Posted: Sun Aug 24, 2003 4:25 pm
by toren
OK, thanks for the tip. Just another thing about PE. I've experienced
PE for one problem when I wrote a new line after the last output, and then got it fixed when I removed it. But, to the contrary, I've also experienced PE for another problem when I didn't write a newline after the last output, and then got it fixed by outputing a newline at the end. Go figure.

--
Tore Nedretvedt