please tell me why they show me wrong answer.
i used this technique. if a = 1, go right. if a = -1, go left, if b = 1, go up, if b = -1, go down.
used ara[64][64] to store 0 if it is not travelled and store 1 if it is travelled.
include<stdio.h>
include<string.h>
int main(){
int a,b,i,j,m,n,t,len,ara[64][64],p,q,r; char s[130]; scanf("%d",&t); for(i = 0; i < t; i++){ scanf("%d %d\n", &m, &n); r = 0; gets(s); for(p = 0; p < 64; p++){ for(q = 0; q < 64; q++){ ara[p][q] = 0; } } ara[m][n] = 1; len = strlen(s); a = 0, b = 1; for(j = 0; j < len; j++){ if(s[j] == 'F'){ if(b == 1){ n++; } else if(b == -1){ n--; } else if(a == 1){ m++; } else if(a == -1){ m--; } if(ara[m][n] == 1){ r++; } else{ ara[m][n] = 1; } } else if(s[j] == 'R'){ if(b == 1){ b = 0; a = 1; } else if(b == -1){ b = 0; a = -1; } else if(a == 1){ a = 0; b = -1; } else if(a == -1){ a = 0; b = 1; } } else{ if(a == 1){ a = 0; b = 1; } else if(a == -1){ a = 0; b = -1; } else if(b == 1){ b = 0; a = -1; } else if(b == -1){ b = 0; a = 1; } } } printf("Case #%d: %d %d %d\n",i + 1,m,n,r); } return 0;
}
LoOoOooLoOoOoOoooOLooOoOoOoOooL. ROFL. LMAO. NO.
what. when, i stuck on a problem and you say lol. please, find my mistake as they are giving me WA
One possible thing: The question asks for the number of locations visited more than once, not how many times you visit an already-seen location. So if you visit a single square three times and all other squares at most once, the answer is 1, not 2.
thanks bro