Page 4 of 7

Posted: Thu Feb 24, 2005 10:24 pm
by ibrahim
Finaly i got AC :D (After change the full code) :( .

10279

Posted: Wed Aug 24, 2005 9:58 am
by Salman
Getting WA ?Some one help?

Code: Select all


/*
Name: Mine Sweeper   
Number: 10279
Type :  simulation
Process : ON
Author :Salman Zaman
Email : zamansalman@gmail.com
Date : 15/08/05 20:10



*/



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



//#include<conio.h>



int main(){

       int t,n,i,j,k;
       int mines[200][200];
       int touch[200][200];
       int output[200][200];
       char input[100];

  //     freopen("10279.txt","r",stdin);
//       printf("%d",'.');
       gets(input);
       sscanf(input,"%d",&t);
       for(k=0;k<t;k++){
           gets(input); 
           gets(input);
           sscanf(input,"%d",&n);

            for(i=0;i<=n;i++){
               for(j=0;j<=n;j++){
                   mines[i][j]=0;
                   output[i][j]=0;
                   touch[i][j]=0;
                   
               }    
             
            }    

 
           for(i=1;i<=n;i++){
               gets(input);
                for(j=0;j<n;j++){
                   if(input[j]=='.'){
                       mines[i][j+1]=0;     
                   }
                   else if(input[j]=='*'){
                       mines[i][j+1]=1;
                   }         
               }    
           }    
           for(i=1;i<=n;i++){
                gets(input);
                for(j=0;j<n;j++){
                  if(input[j]=='x'){
                      touch[i][j+1]=1;
                  }    
                  else if(input[j]=='.'){
                      touch[i][j+1]=0;  
                  }    
               }       
                 
           }    
           for(i=1;i<=n;i++){
               
               for(j=1;j<=n;j++){
     //             printf("%d ",touch[i][j]);
                     if(touch[i][j]){ 
                            if(i-1>=1 && j-1>=1){
                                output[i][j]+=mines[i-1][j-1];      
                            }    
                            if(i-1>=1) {
                                output[i][j]+=mines[i-1][j];      
                                
                            }    
                            if(i-1>=1 && j+1<=n){
                                output[i][j]+=mines[i-1][j+1];      
                                
                            }    
                            if(j-1>=1){
                                output[i][j]+=mines[i][j-1];      
                                
                            }        
                            if(j+1<=n){
                                output[i][j]+=mines[i][j+1];      
                               
                            }    
                            if(i+1<=n && j-1>=1){
                                output[i][j]+=mines[i+1][j-1];      
                                
                            }    
                            if(i+1<=n){
                                output[i][j]+=mines[i+1][j];      
                                
                            }    
                            if(i+1<=n && j+1<=n){
                                output[i][j]+=mines[i+1][j+1];      
                                
                            }    
//                          output[i][j]='1';
                    }     
                    else {
                        output[i][j]=46;    
                    }    
           
               }    
       //        printf("\n");
          }    

           for(i=1;i<=n;i++){
                for(j=1;j<=n;j++){
                 if(output[i][j]==46){
                     printf("%c",'.');
                 }
                 else{     
                  printf("%d",output[i][j]);
                 }    


             }       
             printf("\n");
         }    


          printf("\n\n"); 
           
       }    

     
//   getch();
   return 0;
}

Posted: Wed Aug 24, 2005 11:56 am
by mohiul alam prince
Hi salman

Try this input

Input

Code: Select all

1

8 
...**..*
......*.
....*...
........
........
.....*..
...**.*.
.....*..
xxxxxxxx
xxxx....
xxxx....
xxxxx...
xxxxx...
xxxxx...
xxx.....
xxxxx...
Output

Code: Select all

001**22*
0013..*.
0001*...
00011...
00001...
00123*..
001**.*.
00123*..
for this input your output is

Output

Code: Select all

00111221
0013....
0001....
00011...
00001...
00123...
001.....
00123...
Thanks
MAP

10279 Why WA ????

Posted: Tue Oct 04, 2005 3:41 pm
by jan_holmes
Anyone could help me why is my source is still wrong ???

#include <iostream>
#include <string.h>
#include <stdlib.h>

using namespace std;

int main () {
int n,m;
char sign[150][150];
char sign2[150][150];
int number[150][150];
cin >> n;
for (int i=0;i<n;i++) {
memset(number,0,sizeof(number));
cin >> m;
for (int j=0;j<m;j++) {
for (int k=0;k<m;k++) {
cin >> sign[j][k];
if (sign[j][k] == '*') {
if (k-1 >= 0 ) number[j][k-1]++;
if (k+1 < m) number[j][k+1]++;
if (j-1 >= 0) number[j-1][k]++;
if (j+1 < m) number[j+1][k]++;
if (j-1 >=0 && k-1 >=0) number[j-1][k-1]++;
if (j-1 >=0 && k+1 < m) number[j-1][k+1]++;
if (j+1 < m && k-1 >=0) number[j+1][k-1]++;
if (j+1 < m && k+1 < m) number[j+1][k+1]++;
}
}
}
for (int j=0;j<m;j++) {
for (int k=0;k<m;k++) {
cin >> sign2[j][k];
}
}
for (int j=0;j<m;j++) {
for (int k=0;k<m;k++) {
if (sign2[j][k] == 'x') {
if (sign[j][k] == '.') {
cout << number[j][k];
}
else if (sign[j][k] == '*') {
cout << sign[j][k];
}
}
else {
if (sign[j][k] == '*') cout << sign[j][k];
else cout << sign2[j][k];
}
}
cout << "\n";
}
if (i != n-1) cout << "\n";
}
return 0;
}

Posted: Sun Oct 09, 2005 3:20 pm
by Niaz
It looks an easy one but its pulling my brain out by showing WA again and again. Plz check my code and do some comment.

Another thing, will there be any blank line after the last case ?

Code

Code: Select all

#include<stdio.h>
char grid[20][20],extra[20][20];
void putmine(int n)
{
    int i,j;
    for(i=0;i<n;i++)
        for(j=0;j<n;j++)
            if(grid[i][j]=='*')
                extra[i][j]='*';    
}
int count(int i,int j, int n)
{
    int s=0;
    if(i<n-1)
        if(grid[i+1][j]=='*')
            s++;    
    
    if(i<n-1 && j<n-1)
        if(grid[i+1][j+1]=='*')
            s++;
    
    if(j<n-1)
        if(grid[i][j+1]=='*')
            s++;
    
    if(i>0)
    {
        if(grid[i-1][j]=='*')
            s++;           
        if(grid[i-1][j+1]=='*')
            s++;
    }
    
    if(j>0)
    {
        if(grid[i][j-1]=='*')
            s++;
        if(grid[i+1][j-1]=='*')
            s++;
    }
    if(i>0 && j>0)
    {
        if(grid[i-1][j-1]=='*')
            s++;
    }
    return s;
}    
int main()
{
    int i,j,N,n,s,chk;
    scanf("%d",&N);
    while(N--)
    {
        scanf("%d",&n);
        for(i=0;i<n;i++)
            scanf("%s",grid[i]);
        
        for(i=0;i<n;i++)
            scanf("%s",extra[i]);
        
        chk=1;    
        for(i=0;i<n;i++)
        {
            for(j=0;j<n;j++)
            {
                if(extra[i][j]=='x')
                {
                    if(grid[i][j]=='*')
                        chk=0;
                    s=count(i,j,n);
                    extra[i][j]=s+48;
                }                   
            }    
        }
        if(chk==0)
            putmine(n);
        for(i=0;i<n;i++)
            printf("%s\n",extra[i]);
        
        //if(N!=0)
            printf("\n");
    }    
}
Thanks in advance.

Posted: Thu Dec 15, 2005 3:51 pm
by WR
Try this one:

Code: Select all

1
.
x

10279

Posted: Wed Apr 19, 2006 7:19 pm
by CrazyTerabyte
It reads "The first line of input contains how many game you have to solved followed by blank line.", it should read: "The first line of input contains how many games you have to solve followed by blank line."

Ok, this is a really small change, but I felt I should report it.

I'm not sure where I should post this, if at this forum or at "Bugs and suggestions".

Thanks.

Posted: Thu Nov 30, 2006 3:28 am
by razor_blue
Sorry, I still don't get the point of the problem.
Can someone tell me what is the output for this:

Code: Select all

1

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

Posted: Thu Nov 30, 2006 8:23 am
by Jan
My accepted code returns

Output:

Code: Select all

001**..*
0013..*.
0001*...
00011...
00001...
00123*..
001**.*.
00123*..
Hope it helps.

Posted: Sat Dec 02, 2006 3:07 am
by razor_blue
Thx, now I understand the problem and I've solved it.

Posted: Wed Jan 03, 2007 10:06 am
by albet_januar
got AC..
at last i know where i do mistake..

:) :wink:

Wa :(

Posted: Tue Jan 16, 2007 3:52 pm
by vijay03
I`ve taken care of it being a multiple input problem and i`ve printed the blank lines between consecutive cases. My program gives the correct output for all the i/o on this forum. Why WA?

Code: Select all


#include<stdio.h>

int main()
{
	char area [102][102];
	char output [102][102];
	char used[102][102];
	int m,n,i,j,k,flag=0;
	char c;
	scanf("%d\n",&n);
	for(k=0;k<n;k++)
	{
		scanf("%d",&m);
		
		flag=0;

		for(i=0;i<m;i++)
			for(j=0;j<m;j++)
				output[i][j]='0';
		
		for(i=0;i<m;i++)
			for(j=0;j<m;j++)
			{
				scanf("%c",&c);
				if(c=='\n')
				{
					j--;
				}
				else
				{
					area[i][j]=c;
					if(area[i][j]=='*')
						{
							output[i][j]='*';
							if(i!=0)
								{
									if(output[i-1][j]!='*')
									output[i-1][j]++;
									if(j!=m-1)
										if(output[i-1][j+1]!='*')
											output[i-1][j+1]++;
									if(j!=0)
										if(output[i-1][j-1]!='*')
											output[i-1][j-1]++;
								}
							if(j!=0)
								if(output[i][j-1]!='*')
									output[i][j-1]++;
							if(j!=m-1)
								if(output[i][j+1]!='*')
								output[i][j+1]++;

							if(i!=m-1)
								{
									if(output[i+1][j]!='*')
									output[i+1][j]++;
									if(j!=0)
										 if(output[i+1][j-1]!='*')
										output[i+1][j-1]++;
								}
							
							if(!i&&!j)
								if(output[i-1][j-1]!='*')
								output[i-1][j-1]++;
							if((i!=m-1)&&(j!=m-1))
								if(output[i+1][j+1]!='*')
								output[i+1][j+1]++;
					}
				}
			}

			for(i=0;i<m;i++)
				for(j=0;j<m;j++)
				{
					scanf("%c",&c);
					if(c=='\n')
					{
						j--;
					}
					else
					{
						used[i][j]=c;
						if(!flag)
						{
							if(c=='X')
							if(area[i][j]=='*')
								flag=1;
						}
					}
				}

			if(k)
				printf("\n");			
			

			
			for(i=0;i<m;i++)
			{
				for(j=0;j<m;j++)
				{
					if(flag)
					{
						if(area[i][j]=='*')
							printf("%c",'*');
						else
							if(used[i][j]=='X')
								printf("%c",output[i][j]);
							else
								printf("%c",'.');
					}
					else
					{
						if(used[i][j]=='X')
								printf("%c",output[i][j]);
							else
								printf("%c",'.');
					}

				}
				printf("\n");
			}

			
	}
	return 0;
}

why 10279 mine sweeper WA

Posted: Sat Jul 28, 2007 12:34 pm
by bishop
i test all input output
but still WA

Code: Select all

for 
1

1
.
x
Thanks rio 


:D

can anyone

Posted: Wed Aug 01, 2007 7:42 pm
by bishop
CAN anyone tell me what is wrong for

can anyone

Posted: Wed Aug 01, 2007 7:43 pm
by bishop
CAN anyone tell me what is wrong for
result shows wrong ans