Page 1 of 7

10279

Posted: Tue Aug 13, 2002 1:45 pm
by kelvin
[pascal] :cry:
I passed the sample but I still got WA
I need help
type
arr=array[1..10,1..10] of char;
var
a:arr;f,n:integer;
procedure ini(n:integer);
var
i,j:integer;
begin
for i:=1 to n do
begin
for j:=1 to n do
read(a[i,j]);
readln;
end;
end;
procedure main(var a:arr);
var
i,j,t:integer;
ch:char;
begin
f:=0;
for i:=1 to n do
begin
for j:=1 to n do
begin
read(ch);
if ch='x' then
if a[i,j]='*' then f:=1
else {if a[i,j]<>'*' then} begin
t:=0;
if ((i-1)>0)and((j-1)>0) then
if a[i-1,j-1]='*' then t:=t+1;
if ((i-1)>0)and(j>0) then
if a[i-1,j]='*' then t:=t+1;
if ((i-1)>0)and((j+1)<n+1) then
if a[i-1,j+1]='*' then t:=t+1;
if (i>0)and((j-1)>0) then
if a[i,j-1]='*' then t:=t+1;
if (i>0)and((j+1)<n+1) then
if a[i,j+1]='*' then t:=t+1;
if ((i+1)<n+1)and((j-1)>0) then
if a[i+1,j-1]='*' then t:=t+1;
if ((i+1)<n+1)and(j>0) then
if a[i+1,j]='*' then t:=t+1;
if ((i+1)<n+1)and((j+1)<n+1) then
if a[i+1,j+1]='*' then t:=t+1;
a[i,j]:=chr(t+ord('0'));
end
// else write('*');
end;
readln;
end;
end;
procedure print(a:arr);
var
i,j:integer;
begin
if f=1 then
for i:=1 to n do
begin
for j:=1 to n do
write(a[i,j]);
writeln;
end
else for i:=1 to n do
begin
for j:=1 to n do
if a[i,j] in ['0'..'8']
then write(a[i,j])
else write('.');
writeln;
end;
end;

begin
readln(n);
ini(n);
main(a);
print(a);
readln;
end.[/pascal]

10279

Posted: Mon Aug 19, 2002 7:15 am
by sunkid
:evil:
i can't pass the 10279!
why???

if the input is:
/************input******/
3

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

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

8
...**..*
......*.
....*...
........
........
.....*..
...**.*.
.....*..
........
........
........
........
........
........
........
x.......

/****************/

my out put is :
/***************/
001.....
0013....
0001....
00011...
00001...
00123...
001.....
00123...

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

001.....
0013....
0001....
00011...
00001...
00123...
001.....
001.....
/***********/

is it right!
who can tell me
thank!

Posted: Sun Sep 01, 2002 10:06 am
by wyvmak
something strange.
i didn't read the problem statement :-?
but the third case, my output is:

........
........
........
........
........
........
........
0.......
i guess it's the output to:
8
...**..*
......*.
....*...
........
........
.....*..
...**.*.
.....*..
........
........
........
........
........
........
........
x.......

Posted: Sun Sep 01, 2002 5:47 pm
by arc16
sunkid:
wyvmak is right, you only have to print the number of mine only if the current position has been touched ('X'). The others remain blank ('.') except any of the touched position revealed mine.

Posted: Sun Dec 15, 2002 10:17 am
by rjhadley
It's a multiple input problem. See http://acm.uva.es/problemset/minput.html.

10279

Posted: Sun Dec 22, 2002 5:05 pm
by angga888
I am sure that my program is working correctly, I still can't pass 602. Why? Any idea? :wink:
What should be the output if 'X' touch '*' ? Should another touched position (number between 0..8) be in output ? or just the mine's position ?
And, please give me unique and creative inputs to check my program.

Thanx for helping me.
Angga :D

Posted: Tue Dec 24, 2002 10:47 am
by deddy one
umm, I still confused, what happened if the position of 'X' is the same with '*',

in my understanding is the output will be exact the same with the input

am I right????

pls someone clarify this for me

Posted: Tue Jan 07, 2003 9:23 pm
by the LA-Z-BOy
umm, I still confused, what happened if the position of 'X' is the same with '*', in my understanding is the output will be exact the same with the input
am I right????
no, you aren't! look:
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 (doesn't matter if you touch a/many mine(s) or not.)
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.

try this

Code: Select all

/* Input */
8
...**..*
......*.
....*...
........
........
.....*..
...**.*.
.....*..
xxxxxxxx
xxxx....
xxxx....
xxxxx...
xxxxx...
xxxxx...
xxx.....
xxxxx...

Code: Select all

/* Output */
001**22*
0013..*.
0001*...
00011...
00001...
00123*..
001**.*.
00123*..

10279 a easy problem,but why wrong answer?

Posted: Thu Mar 20, 2003 1:13 am
by mrtamtam
[c]
#include <stdio.h>

int main()
{
int map[100][100];
char str[200];
int n;
int i,j,x,y,ans;
int t1,t2;
char ch;

scanf("%d",&t2);

for (t1=1; t1<=t2; t1++)
{
scanf("%d\n",&n);

if (t1 > 1)
printf("\n");

for (i=0; i <= 20; i++)
for (j=0; j <= 20; j++)
map[j] = 0;

for (i=1; i <= n; i++)
{
gets(str);
for (j=1; j <= n; j++)
{

if (str[j-1] == '*')
map[j] = 1;
else
map[j] = 0;
}
}

for (i=1; i <= n; i++)
{
gets(str);
for (j=1; j <= n; j++)
{
ans = 0;

if (str[j-1] == 'x')
{

if (map[j] == 1)
printf("*");
else
{

ans = 0;
for (x=-1; x <= 1; x++)
for (y=-1; y <= 1; y++)
if (map[i+y][j+x] == 1)
ans++;

printf("%d",ans);

}

}
else
printf(".");

if (j == n)
printf("\n");

}
}
}

return 0;
} [/c]

grrrrr :-(

Posted: Thu Mar 20, 2003 12:57 pm
by bery olivier
I got the same problem, I can't find the inputs that causes that wrong answer. :evil:

10279 Why WA and WA ???

Posted: Tue Apr 01, 2003 8:41 am
by Daredevil
consider this input :
4
. . . *
. * * .
. . . .
* * * *
xxx.
xx..
x...
x...
What will the output be?
Output 1
. . . *
. * * .
. . . .
* * * *
Output 2
123.
1**.
3...
****

Or neither of them?, if so what will it be?

Posted: Tue Apr 01, 2003 11:00 am
by Dominik Michniewski
Why you have spaces in input ?
My accepted solution outputs:

123*
1**.
3...
****

Dominik

PS. Did you see blue checkmark near this problem ?(Multiply input)

Posted: Wed Apr 02, 2003 4:39 pm
by Daredevil
I'm aware that this is a multiple input problem. Btw, It's said if a bomb is encountered during the game, ALL POSITION CONTAINING THE BOMB MUST PRINTED '*' AND ALL OTHER POSITION MUST CONTAIN '.'.
Oh, should I print extra blank line between two consecutive outputs?
Thx anyway!!

Posted: Thu Apr 03, 2003 8:05 am
by Dominik Michniewski
I don't remember - If specifications say print empty line between cases - print it, otherwise - not print it :)

Dominik
PS. In your input you pick a mine in last row, so you must print all of them .

Posted: Sun Apr 06, 2003 8:08 am
by Daredevil
I've tried everything, but still WA

C :
#include<stdio.h>
#include<string.h>
int i,j,k,l,m,n,sum,yes;
char game[15][15],board[15][15];
void main(){
while(scanf("%i",&n)!=EOF){
for(i=0;i<n;i++){scanf("%s",&board);}
for(i=0;i<n;i++){scanf("%s",&game);}
for(i=0;i<n;i++){
for(j=0;j<n;j++){
if(game[j]!='.'&&board[j]=='*'){yes=1;break;}
}
}
if(yes==1){
yes=0;
for(i=0;i<n;i++){
for(j=0;j<n;j++){
if(game[j]!='.'){
if(board[j]=='*'){printf("*");}
else{
k=i-1;m=j-1;
if(k<0){k++;}
if(m<0){m++;}
for(k=k;k<=i+1&&k<n;k++){
for(l=m;l<=j+1&&l<n;l++){
if(board[k][l]=='*'){sum++;}
}
}
printf("%i",sum);sum=0;
}
}
else{
if(board[j]=='*'){printf("*");}
else{printf(".");}
}
}
printf("\n");
}
}
else{
for(i=0;i<n;i++){
for(j=0;j<n;j++){
if(game[j]!='.'){
k=i-1;m=j-1;
if(k<0){k++;}
if(m<0){m++;}
for(k=k;k<=i+1&&k<n;k++){
for(l=m;l<=j+1&&l<n;l++){
if(board[k][l]=='*'){sum++;}
}
}
printf("%i",sum);sum=0;
}
else{printf(".");}
}
printf("\n");
}
}
}
}

Could you please tell me where my mistakes?
I'm very frustrated. Thx