Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- //freopen("in.txt", "r", stdin);
- //freopen("out.txt", "w", stdout);
- int t, ca=1;
- scanf("%d", &t);
- while (t--) {
- int x, y;
- cin>>x>>y;
- char s[200];
- scanf("%s", s);
- int visited[64][64]={0};
- int rep=0;
- bool Y=true, pos=true;
- int x1=x, y1=y, cnt=1;
- visited[x][y]=true;
- for (int i=0; s[i]!='\0'; i++) {
- if (s[i]=='F') {
- if (Y)
- y1+=cnt;
- else x1+=cnt;
- visited[x1][y1]++;
- }
- else if (s[i]=='R') {
- if (Y) {
- Y=false;
- if (pos)
- cnt=1;
- else {
- cnt=-1;
- pos=false;
- }
- }
- else {
- Y=true;
- if (pos) {
- cnt=-1;
- pos=false;
- }
- else cnt=1;
- }
- }
- else if (s[i]=='L') {
- if (Y) {
- Y=false;
- if (pos) {
- cnt=-1;
- pos=false;
- }
- else {
- cnt=1;
- pos=true;
- }
- }
- else {
- Y=true;
- if (pos) {
- cnt=1;
- }
- else {
- cnt=-1;
- }
- }
- }
- }
- for (int i=0; i<64; i++) {
- for (int j=0; j<64; j++) {
- if (visited[i][j]>1)
- rep++;
- }
- }
- printf("Case #%d: %d %d %d\n", ca++, x1, y1, rep);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement