Page 1 of 2

784 - Maze Exploration

Posted: Thu Dec 26, 2002 1:27 pm
by angga888
I am sure that my program is working correctly, but I still got WA :( . Any special or strange input?
What is the length of "_" character that indicates the end of one maze?
[/pascal]

Can anyone give me another creative input?

Regards
Angga888

Output Format

Posted: Sun Apr 06, 2003 9:21 pm
by Moinul(AUST)
The problem is a simple one but getting WA. I think, my mistake lies in the output format.
Can anyone Help me specifying on how to format the output.

The problem suggests that, the output should be exactly like input along with the separation line. But, will there be any newline between two consecutive outputs? if the input contains some blank lines, will those blank lines be printed?

Any help will be appreciated... Thanks in advance.

Moinul
AUST, Bangladesh

Posted: Wed Aug 06, 2003 7:47 pm
by UFP2161
Read each line of the file. Store in an array. When you hit a separator, flood-fill the array accordingly, print the array, including the separator line out, and repeat.

As long as the first character on the line is a '_', it is considered a separator.

Posted: Wed Aug 13, 2003 10:30 pm
by Moinul(AUST)
Allthough I had the problem solved long ago... :)

Thanks to UFP2161 for respnsing to this query..
I hope, it will help others trying to sove 784

----------------------------------------------------------

Moinul,
Bangladesh

784

Posted: Thu Feb 19, 2004 5:33 pm
by lky
i think my program works for all sort of input...but still wa.....can anyone give me some critical inputs for this problem? i simply floodfill the places which is reachable from the * room....

program q784;
var a:array[1..40]of string;
n,i,j,k,l,x,y:integer;
procedure recur(s,t:integer);
var u,v:integer;
begin
a[s,t]:='#';
if (s>1)and(length(a[s-1])>=t)
then if (a[s-1,t]=' ')
then recur(s-1,t);
if (t>1)and(a[s,t-1]=' ')
then recur(s,t-1);
if (s<l-2)and(length(a[s+1])>=t)
then if (a[s+1,t]=' ')
then recur(s+1,t);
if (t<length(a[s]))and(a[s,t+1]=' ')
then recur(s,t+1)
end;
begin
readln(n);
for k:=1 to n do
begin
l:=1;
readln(a[l]);
while a[l][1]<>'-' do
begin
l:=l+1;
readln(a[l])
end;
for i:=1 to l-1 do
for j:=1 to length(a) do
if a[j]='*'
then begin
x:=i;
y:=j;
recur(x,y)
end;
for i:=1 to l do
begin
for j:=1 to length(a) do
write(a[j]);
writeln
end;
end
end.

pls help, ty in advance

784 - Maze Exploration. Please look these inputs...

Posted: Sun Mar 21, 2004 3:19 pm
by Dejarik
Hello! I'm becoming crazy trying to find why this simple problem are returning me Wrong Answer in all the implementations I can design to solve it. I decided to build a great input in order to submit it here to be checked by anyone who received Correct Answer in his implementation.

Thanks in advance!

Joan, SPAIN

Here is my input:

Code: Select all

4
AAAAAAAAA  
A   A   A
A * A   A
A   A   A
AAAAAAAAA
_________
BBBBB   BBBBB
B   B   B   B
B * B   B   B
B   B   B   B
BBBBB   BBBBB
_________
CCCCCCCCCCCCC
C   C   C   C
C * C   C   C
C   C   C   C
CC CCCCCCC CC
C   C   C   C
C           C
C   C   C   C
CC CCCCCCC CC
C   C   C   C
C   C   C   C
C   C   C   C
CCCCCCCCCCCCC
_____________
AXXXBXXXCXXXDXXXEXXXFXXXG   
X   X   X   X   X   X   X
X *     X   X           X
X   X   X   X   X   X   X
XXXXXX XXXXXXXXXXXXXXX XX
X   X   X   X   X   X   X
X   X                   X  
X   X   X   X   X   X   X 
HXXXIXXXJXXXKXXXLXXXMXXXX
_________________________
And that's the returned output with my executable:

Code: Select all

AAAAAAAAA  
A###A   A  
A###A   A  
A###A   A  
AAAAAAAAA  
_________
BBBBB   BBBBB
B###B   B   B
B###B   B   B
B###B   B   B
BBBBB   BBBBB
_________
CCCCCCCCCCCCC
C###C   C###C
C###C   C###C
C###C   C###C
CC#CCCCCCC#CC
C###C###C###C
C###########C
C###C###C###C
CC#CCCCCCC#CC
C###C   C###C
C###C   C###C
C###C   C###C
CCCCCCCCCCCCC
_____________
XXXXXXXXXXXXXXXXXXXXXXXXX   
X###X###X   X###X###X###X   
X#######X   X###########X   
X###X###X   X###X###X###X   
XXXXXX#XXXXXXXXXXXXXXX#XX   
X   X###X###X###X###X###X   
X   X###################X   
X   X###X###X###X###X###X   
XXXXXXXXXXXXXXXXXXXXXXXXX   
_________________________

post your code

Posted: Mon Mar 22, 2004 10:21 am
by sohel
Your output seems to be correct and matches with my AC code's output...
... may be you are not handling the input taking properly....
.. I am not a supporter of posting code over here but I think in this case you should...
.. why don't you post your code and may be errors can be detected..

help me... please

Posted: Fri Jun 11, 2004 12:23 pm
by utter
I am ashamed, :oops: but I can't solve this problem. I am trying to write the program on Pascal, but nothing is good. :(
But I must solve it on this two weeks, because I get this task in my university.
Help me... maybe you have the code of this task on Pascal or C++, please, mail me - utter@yandex.ru

784 PE why? (maze exploration)

Posted: Sat Jun 24, 2006 1:31 am
by nukeu666
heres the io i get from the program, why is it PE?

Code: Select all

7
AAAAAAAAA 
A   A   A
A * A   A
A   A   A
AAAAAAAAA
_________
BBBBB   BBBBB
B   B   B   B
B * B   B   B
B   B   B   B
BBBBB   BBBBB
_________
CCCCCCCCCCCCC
C   C   C   C
C * C   C   C
C   C   C   C
CC CCCCCCC CC
C   C   C   C
C           C
C   C   C   C
CC CCCCCCC CC
C   C   C   C
C   C   C   C
C   C   C   C
CCCCCCCCCCCCC
_____________
AXXXBXXXCXXXDXXXEXXXFXXXG   
X   X   X   X   X   X   X
X *     X   X           X
X   X   X   X   X   X   X
XXXXXX XXXXXXXXXXXXXXX XX
X   X   X   X   X   X   X
X   X                   X 
X   X   X   X   X   X   X
HXXXIXXXJXXXKXXXLXXXMXXXX
_________________________
XXXXX
X  XX
X*XXX
X   X
X X X
X XX
X X
X X
XXX
__
XXX
X X
X*X
XX
____
AXXXBXXXCXXXDXXXEXXXFXXXG   
X   X   X   X   X   X   X
X *     X   X           X
X   X   X   X   X   X   X
XXXXXX XXXXXXXXXXXXXXX XX
X   X   X   X   X   X   X
X   X                   X 
X   X   X   X   X   X   X
HXXXIXXXJXXXKXXXLXXXMXXXX
_

Code: Select all


nuke@nukem ~
$ ./a.exe <in1 
AAAAAAAAA 
A###A   A 
A###A   A 
A###A   A 
AAAAAAAAA 
_________
BBBBB   BBBBB
B###B   B   B
B###B   B   B
B###B   B   B
BBBBB   BBBBB
_________
CCCCCCCCCCCCC
C###C   C###C
C###C   C###C
C###C   C###C
CC#CCCCCCC#CC
C###C###C###C
C###########C
C###C###C###C
CC#CCCCCCC#CC
C###C   C###C
C###C   C###C
C###C   C###C
CCCCCCCCCCCCC
_____________
AXXXBXXXCXXXDXXXEXXXFXXXG   
X###X###X   X###X###X###X   
X#######X   X###########X   
X###X###X   X###X###X###X   
XXXXXX#XXXXXXXXXXXXXXX#XX   
X   X###X###X###X###X###X   
X   X###################X   
X   X###X###X###X###X###X   
HXXXIXXXJXXXKXXXLXXXMXXXX   
_________________________
XXXXX
X##XX
X#XXX
X###X
X#X#X
X#XX 
X#X  
X#X  
XXX  
__
XXX
X#X
X#X
XX 
____
AXXXBXXXCXXXDXXXEXXXFXXXG   
X###X###X   X###X###X###X   
X#######X   X###########X   
X###X###X   X###X###X###X   
XXXXXX#XXXXXXXXXXXXXXX#XX   
X   X###X###X###X###X###X   
X   X###################X   
X   X###X###X###X###X###X   
HXXXIXXXJXXXKXXXLXXXMXXXX   
_

nuke@nukem ~
$ 

Posted: Wed Dec 20, 2006 12:08 pm
by algoJo
for your inputs my AC program gave:

OUTPUT

Code: Select all

##########
##########
##########
##########
##########
_________ 
##############
##############
##############
##############
##############
_________ 
##############
##############
##############
##############
##############
##############
##############
##############
##############
##############
##############
##############
##############
_____________ 
AXXXBXXXCXXXDXXXEXXXFXXXG    
X###X###X   X###X###X###X 
X#######X   X###########X 
X###X###X   X###X###X###X 
XXXXXX#XXXXXXXXXXXXXXX#XX 
X   X###X###X###X###X###X 
X   X###################X 
X   X###X###X###X###X###X 
HXXXIXXXJXXXKXXXLXXXMXXXX 
_________________________ 
XXXXX 
X##XX 
X#XXX 
X###X 
X#X#X 
X#XX 
X#X 
X#X 
XXX 
__ 
XXX 
X#X 
X#X 
XX 
____ 
AXXXBXXXCXXXDXXXEXXXFXXXG    
X###X###X   X###X###X###X 
X#######X   X###########X 
X###X###X   X###X###X###X 
XXXXXX#XXXXXXXXXXXXXXX#XX 
X   X###X###X###X###X###X 
X   X###################X 
X   X###X###X###X###X###X 
HXXXIXXXJXXXKXXXLXXXMXXXX 
_
---empty line----
hope it helps..

Posted: Mon May 07, 2007 8:34 am
by hamedv
you most to replace this line
while a[l][1]<>'-' do
whith
while a[l][1]<>'_' do

Re: 784 - Maze Exploration

Posted: Sat Dec 08, 2012 4:10 pm
by Sabiha_Fancy
I am getting WA for a long time.But unable to find error. If anyone help i will be glad. #include<stdio.h>
#include<stdlib.h>

char maze[100][100];

void floodFill(int start_row,int start_col);
int main()
{
int no_of_maze,i,j,start_row,start_col,k,flag;

scanf("%d",&no_of_maze);
fflush(stdin);
for(i=0; i<no_of_maze; ++i)
{
flag = 0;
start_row = -5;
start_col = -5;
for(j=0; ; ++j)
{
gets(maze[j]);
if(maze[j][0] == '_')
break;
if(start_row == -5 && start_col == -5)
{ for(k=0; maze[j][k]!='\0'; ++k)
{
if(maze[j][k] == '*')
{
start_row = j;
start_col = k;
flag = 1;
break;
}
}
}
}
if(flag == 1)
floodFill(start_row,start_col);
for(k=0; k<=j; ++k)
{
puts(maze[k]);
}
}
return 0;
}

void floodFill(int start_row,int start_col)
{
if(maze[start_row][start_col] == ' ' || maze[start_row][start_col] == '*')
{
maze[start_row][start_col] = '#';
floodFill(start_row,start_col-1);
floodFill(start_row,start_col+1);
floodFill(start_row-1,start_col);
floodFill(start_row+1,start_col);
}
else
return;
}

Re: 784 - Maze Exploration

Posted: Tue Dec 11, 2012 12:40 am
by brianfry713
Don't use fflush(stdin);

Re: 784 - Maze Exploration

Posted: Fri Dec 14, 2012 10:26 am
by Sabiha_Fancy
Thank you for your reply. I got ac. But what is the problem with fflush(stdin)?

Re: 784 - Maze Exploration

Posted: Fri Dec 14, 2012 7:55 pm
by brianfry713
The behavior of fflush(stdin) is undefined for the C standard.