"shooting" question in august cook off-2014

2014
aug2014
augcookoff14
august
august14
cookoff
shooting

#1

BELOW WRITTEN TEXT WAS MY CODE FOR THE SHOOTING QUESTION FOR AUGUST COOK OFF-2014
THE CODE WORKS ON MY COMPILER IF I TAKE TEST CASE=1 BUT DOES NOT LET ME INPUT ALL THE ARRAY ELEMENTS IF I TAKE REST CASES MORE THAN 1.
I TRIED CHECKING IT FOR ALL 3 SAMPLE INPUT-OUTPUT VALUES
EVERYTHING SEEMS OKAY.
CAN SOMEONE EXPLAIN ME THE FAULT IN THE CODE, IF ANY

#include<stdio.h>
int main()
{
int i,j,n,m,t,x,z,flag;char arr[50][50];
scanf("%d",&t);
for(z=1;z<=t;z++)
{
flag=0;
scanf("%d%d",&n,&m);
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
scanf("%ch",&arr*[j]);
}

}

for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
if(arr*[j]==‘L’)
{
for(x=0;x<=j;x++)
if(arr*[x]==‘E’)
arr*[x]=’.’;

	for(x=j;x<m;x++)
	if(arr*[x]=='E')
	arr*[x]='.';

	for(x=0;x<=i;x++)
	if(arr[x][j]=='E')
	arr[x][j]='.';
   }
 }

}
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
if(arr*[j]==‘E’)
flag++;
}
}
if(flag==0)
printf("impossible
");
else
printf("possible
");
}
return 0;
}


#2

You can’t ask any question or program when the contest is on. So, When contest will ended then we can help you.

Happy coding .


#3

You are printing “impossible” instead of “Impossible”.


#4

Actually the laser can fire in only “one of the three directions” while the code you have written is based on the assumption that it fires in all three directions.


#5

It’s a character array. So, after you scan the number of rows and columns, you would press either enter or space which is a character. So, use getchar and also use getchar after scanning every row if you are pressing enter after giving the row elements. Also, the laser can fire in only one direction and not all the three.