784 – Maze Exploration

Problem Link

#Solution

#include
#include
using namespace std;
char in[100][100];
void dfs(int a,int b)
{
if(in[a][b]==’X’ || in[a][b]==’#’)
return ;
in[a][b]=’#’;
dfs(a+1,b);
dfs(a-1,b);
dfs(a,b+1);
dfs(a,b-1);

}
int main()
{

int t,n,i,j;
scanf(“%d “,&t);
while(t–)
{
n=0;
while(gets(in[n]))
{

if(in[n][0]==’_’)
break;
n++;
}
for( i=0;i<n;i++)
{

for(j=0;in[i][j];j++)
{
if(in[i][j]==’*’)
dfs(i,j);
}
}
for(int i=0;i<=n;i++)
puts(in[i]);
}
return 0;
}

Advertisements

About waprogramming

I am in CSE,from CUET
This entry was posted in Uncategorized, uva and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s