The input will begin with a line consisting of two numbers n and m, separated by a space (1 ≤ n, m ≤ 1000). The city will be an n x m grid of square subsections. The next n lines will each consist of a string of length m, consisting of the letters N',
E', S', or
W',
ex:
3 4
SWWW
SEWN
EEEN
int m,n,i,j;
scanf("%d%d",&m,&n);
char a[1001][1001],ch;
// priority_queue<struct str>p;
queue<struct str>q,p;
struct str st,st1,temp,temp1;
scanf("%c",&ch); //......line 1
for(i=0;i<m;i++){
for(j=0;j<n;j++){
scanf("%c",&a[i][j]);//......line 2
// cin>>a[i][j]; //line 4
st.x=i;
st.y=j;
// st.pr=0;
p.push(st);
}
scanf("%c",&ch); //.....line 3
}
with this code i get wrong answer.
when i used cin(line 4) and commented line 1, line 2,and line 3.. i got Ac.
In case of scanf,---
Since after inputting two numbers,i used a dummy variable 'ch' to get '\n'
and similarly after first line of input string.
But I am not getting where i am getting it wrong it is working well on my system.
Please explain it.
--
Thanx.