Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- typedef long long int ll;
- typedef unsigned long long int ull;
- typedef vector<int> vi;
- typedef vector<vi> vvi;
- typedef pair<int,int> pii;
- typedef vector< pii > vpii;
- typedef set<int> sti;
- #define pb push_back
- #define pob pop_back
- #define mp make_pair
- #define ff first
- #define ss second
- #define loop1(i,n) for(int i=1; i<=int(n); i++)
- #define loop(i,y) for(int i=0; i<int(y); i++)
- #define rloop(i,y) for(int i=int(y)-1; i>=0; i--)
- #define read() freopen("input.txt", "r", stdin)
- #define write() freopen("output.txt", "w", stdout)
- #define cspf(i) printf("Case #%d: ", i)
- /// Constants
- #define eps 1e-9
- #define PI acos(-1.0) // 3.1415926535897932
- int main()
- {
- int n,i,j,k;
- scanf("%d",&n);
- loop1(i,n){
- int x,y,ck[100][100];
- char s[200];
- scanf("%d %d",&x,&y);
- scanf("%s",s);
- int ln=strlen(s);
- for(j=0;j<100;j++){
- for(k=0;k<100;k++)
- ck[j][k]=0;
- }
- int c=0,cnt=0;
- ck[x][y]=1;
- loop(j,ln){
- if(s[j]=='R')
- c++;
- else if(s[j]=='L')
- c--;
- else if(s[j]=='F'){
- if(c%4==0)
- y++;
- else if(c%4==1 || c%4==-3)
- x++;
- else if(c%4==2 || c%4==-2)
- y--;
- else if(c%4==3 || c%4==-1)
- x--;
- if(ck[x][y]==0)
- ck[x][y]=1;
- else if(ck[x][y]==1){
- cnt++;
- ck[x][y]=2;
- }
- }
- }
- cspf(i);
- printf("%d %d %d\n",x,y,cnt);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement