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("%d %d %d\n",m,n,r); } return 0;
}