Page 7 of 28

Posted: Thu Mar 09, 2006 6:48 pm
by Qodeus
Oh, I can't beleve that i didn't see that. :oops: Thanks a lot man! :D

10189 mines WA!

Posted: Thu May 25, 2006 3:01 pm
by xivphoenix
I've no idea what's wrong whith my code.somebody plz help. THX.

Here's my code.

Code: Select all

#include <stdio.h>

int main(void)
{
	int arr[150][150];
	int i,j,mrow,mcol,cnt=0;
	char c[200];

	while(scanf("%d%d ",&mrow,&mcol)!=EOF) {
		if(mrow==0 && mcol==0) break;
		printf("Field #%d:\n",++cnt);

		for(i=0 ; i<mrow ; i++) {
			scanf("%s",c);
			for(j=0 ; j<mcol ; j++) {
				if(c[j]=='*') 	arr[i][j] = -100;
				else 							arr[i][j] =  0;
			}
		}

		for(i=0 ; i<mrow ; i++) {
			for(j=0 ; j<mcol ; j++) {
				if (arr[i][j] < 0) {
					arr[i-1][j-1] ++;  arr[i-1][j] ++; 	arr[i-1][j+1] ++;
					arr[i][j-1] ++;  	 arr[i][j] ++; 	  arr[i][j+1] ++;
					arr[i+1][j-1] ++;  arr[i+1][j] ++; 	arr[i+1][j+1] ++;
				}
			}
		}

		for(i=0 ; i<mrow ; i++) {
			for(j=0 ; j<mcol ; j++) {
				if (arr[i][j] > -1) printf("%d",arr[i][j]);
				else							  printf("*");
			}
			printf("\n");
		}

		printf("\n");

	}

	return 0;
}

Posted: Mon May 29, 2006 8:21 pm
by ayeshapakhi
hi there!
i didnt run ur code but probably u r getting out of array boundary by these lines.........

for(i=0 ; i<mrow ; i++) {
for(j=0 ; j<mcol ; j++) {
if (arr[j] < 0) {
arr[i-1][j-1] ++; arr[i-1][j] ++; arr[i-1][j+1] ++;
arr[j-1] ++; arr[j] ++; arr[j+1] ++;
arr[i+1][j-1] ++; arr[i+1][j] ++; arr[i+1][j+1] ++;
}
}
}
what abt arr[0-1][0-1]???

What is Presentation error I don't understand it

Posted: Sat Jun 17, 2006 8:11 pm
by northboy
Dear North:

Your C++ program has solved Ok the problem 10189 (Minesweeper)
in 0.008 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.

--

PS: Check the board at http://acm.uva.es/board/

The Online Judge (Linux acm.uva.es 2.4.18-27.7.x i686)
Judge software version 2.8 [http://acm.uva.es/problemset/]
Sat Jun 17 17:43:03 UTC 2006


I can't understand about this mail please tell me what is presentation error thanks for answer

Posted: Sat Jun 17, 2006 8:44 pm
by jan_holmes
Presentation Error means that your program worked well for all the testcases but the position of your output might not be put in order...

For example,the problem encourages you not to put a blank line after the last testcase,but your program did it...

Hope it helps... :wink:

Posted: Sun Jun 18, 2006 5:43 am
by northboy
Oh I see Thank you very much for answer :D

Posted: Sun Jun 25, 2006 9:53 am
by SHAHADAT
Please delete your code....
And it,s not good idea to upload a code and say whats wrong?????
Try to disscuss about algorithm....

10189WA

Posted: Tue Jul 18, 2006 5:34 pm
by AikoSenoo
I have tried many means to test,but still got WA.

Would you please help me to find where my code's problem is?

Thanks a lot!

There is my code:

Code: Select all

#include<stdio.h>
#include<stdlib.h>
char a[102][102];
int n,m;
int check(int j,int i,int m){
        int count=0;
        if(a[j][i]=='*')
            return 9;
        else {
            if(j!=0){     
                  if(a[j-1][i-1]=='*' && i!=0)
                      count++;            
                  if(a[j-1][i]=='*')
                        count++;
                  if(a[j-1][i+1]=='*')
                        count++;
                
            }
            if(a[j][i-1]=='*' && i!=0)
                count++;
            if(a[j][i+1]=='*')
                count++;
            if(j!=m){
              if(a[j+1][i-1]=='*' && i!=0)
                  count++;
              if(a[j+1][i]=='*')
                  count++;
              if(a[j+1][i+1]=='*')
                  count++;
            }
            return count+'0';
        }
                                                                                
}
                                                                                
int main(void){
    int cnt=0;
    int i,j;
                                                                                
    while(1){
        scanf("%d %d",&n,&m);
        if(n==0 && m==0)
          break;
        cnt++;
        for(j=0;j<n;j++){
            for(i=0;i<m;i++){
                a[j][i]='.';
            }
        }
        for(j=0;j<n;j++){
            for(i=0;i<m;i++){
                scanf(" %c",&a[j][i]);
            }
        }
        for(j=0;j<n;j++){
            for(i=0;i<m;i++){
                if(check(j,i,m)!=9)
                    a[j][i]=check(j,i,m);
            }
        }
        if(cnt>1)printf("\n");
        printf("Field #%d:\n",cnt);
        for(j=0;j<n;j++){
            for(i=0;i<m;i++)
                printf("%c",a[j][i]);
            printf("\n");
        }
        
    }
    return 0;
}

Posted: Tue Jul 18, 2006 6:52 pm
by Darko
Clear the whole array, not just mxn (if board is smaller than the previous one, you might get WA) Or clear it after each case (not at the beginning).

10189

Posted: Wed Feb 14, 2007 7:51 pm
by code_man
what is wrong with this code? I have WA.. I don't undersand why...?

Code: Select all

#include<iostream>
using namespace std;

char check(char t)
{
 int i=0;
 if(t!=42) i=1; 
  return i;   
}

main()
{
int a, b, it=1;

 while(cin>>a>>b)
 {
  if((a==0) && (b==0)) break;
  
  char **t;
  t= new char*[a+5];
  for(int i=0; i<a+5; i++)
   t[i] = new char[b+5];
   
  for(int i=0; i<a+5; i++)
   {
     for(int j=0; j<b+5; j++)
      t[i][j]=48;
   } 
   
  char z; 
  for(int i=1; i<a+1; i++)
   {
     for(int j=1; j<b+1; j++)
      {
        cin>>z;
        if(z==42)
         {
          t[i][j]=42;          
          t[i-1][j-1]+=check(t[i-1][j-1]);
          t[i-1][j]+=check(t[i-1][j]);
          t[i-1][j+1]+=check(t[i-1][j+1]);
          t[i][j-1]+=check(t[i][j-1]);
          t[i][j+1]+=check(t[i][j+1]);
          t[i+1][j-1]+=check(t[i+1][j-1]);
          t[i+1][j]+=check(t[i+1][j]);
          t[i+1][j+1]+=check(t[i+1][j+1]);       
         }   
      } 
    }
  
  cout<<"\nField #"<<it++<<"\n";
  for(int i=1; i<a+1; i++)
   {    
    for(int j=1; j<b+1; j++)
     {
      cout<<t[i][j];
     }
    cout<<"\n";
    }
  
   
  for(int i=a; i<a+5; i++)
    delete [] t[i];
   delete [] t; 
 }      
}

Posted: Thu Feb 15, 2007 1:24 am
by big_mac
The first things I can see is that you are printing a '\n' before the first 'Field', and no ':' after the field number.

10189:how to present

Posted: Thu Feb 15, 2007 6:09 pm
by m2lajoo
help me! why my program say presentation error :cry:

Code: Select all

var
m,n:byte;
test:integer;
house:array[1..100,1..100]of char;
st:string;
khane:array[1..100,1..100]of (mine,clear);
h:array[1..100,1..100]of byte;
i,j:integer;
function shownumber(num1,num2:integer):integer;
var
x,y,tedad:integer;
begin
tedad:=0;
for x:=num1-1 to num1+1 do
for y:=num2-1 to num2+1 do
if (khane[x,y]=mine)and(x<=m)and(x>=1)and(y<=n)and(y>=1) then
tedad:=tedad+1;
shownumber:=tedad;
end;
begin
readln(m,n);
test:=1;
while (m<>0)or(n<>0) do
begin
for i:=1 to m do
for j:=1 to n do
begin
khane[i,j]:=clear;
house[i,j]:='.';
h[i,j]:=0;
end;
for i:=1 to m do
begin
readln(st);
for j:=1 to length(st) do
house[i,j]:=st[j];
end;
writeln('Field #',test,':');
for i:=1 to m do
for j:=1 to n do
if house[i,j]='*' then
khane[i,j]:=mine
else
khane[i,j]:=clear;
for i:=1 to m do
for j:=1 to n do
if khane[i,j]<>mine then
h[i,j]:=shownumber(i,j);
for i:=1 to m do
begin
for j:=1 to n do
if khane[i,j]<>mine then
write(h[i,j])
else
write('*');
writeln;
end;
writeln
test:=test+1;
readln(m,n);
end;
end.

Posted: Thu Feb 15, 2007 6:41 pm
by helloneo
Just try to search first.. and..
Do not make a new thread if there is one already..

http://online-judge.uva.es/board/viewtopic.php?t=8869

Don't forget to remove your code after AC.. :)

Posted: Fri Feb 23, 2007 9:58 pm
by code_man
thx big_mac for you help..:) Now I know whats was incorrect..

10189 WA

Posted: Sun Mar 04, 2007 9:45 pm
by KaDeG
I have made the minsweeper program but i got WA,
I checked some testcases I found in the forums and everything works fine,
any ideas where the probelm is?

Code: Select all

Code, deleted, thanks 
I'm a bit complicate with all thes \n that can give a WA, any suggestion would be very hepful, thanks.