Advertisement
Imran2544

trutle graphics(WA)

Nov 8th, 2018
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.87 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int t, ca=1;
  7.     scanf("%d", &t);
  8.     while (t--) {
  9.         int x, y;
  10.         cin>>x>>y;
  11.         char s[200];
  12.         scanf("%s", s);
  13.         bool visited[64][64]={false}, rep=0;
  14.         bool Y=true, pos=true;
  15.         int x1=x, y1=y, cnt=1;
  16.         for (int i=0; s[i]!='\0'; i++) {
  17.             if (s[i]=='F') {
  18.                 if (Y)
  19.                     y1+=cnt;
  20.                 else x1+=cnt;
  21.                 if (visited[x1][y1]==false) {
  22.                     visited[x1][y1]=true;
  23.                 }
  24.                 else {
  25.                     rep++;
  26.                 }
  27.             }
  28.             else if (s[i]=='R') {
  29.                 if (Y) {
  30.                     Y=false;
  31.                     if (pos)
  32.                         cnt=1;
  33.                     else {
  34.                         cnt=-1;
  35.                         pos=false;
  36.                     }
  37.                 }
  38.                 else {
  39.                     Y=true;
  40.                     if (pos) {
  41.                         cnt=-1;
  42.                         pos=false;
  43.                     }
  44.                     else cnt=1;
  45.  
  46.                 }
  47.             }
  48.             else if (s[i]=='L') {
  49.                 if (Y) {
  50.                     Y=false;
  51.                     if (pos) {
  52.                         cnt=-1;
  53.                         pos=false;
  54.                     }
  55.                     else {
  56.                         cnt=1;
  57.                         pos=true;
  58.                     }
  59.                 }
  60.                 else {
  61.                     Y=true;
  62.                     if (pos) {
  63.                         cnt=1;
  64.                     }
  65.                     else {
  66.                         cnt=-1;
  67.                     }
  68.                 }
  69.              }
  70.         }
  71.         printf("Case #%d: %d %d %d\n", ca++, x1, y1, rep);
  72.     }
  73.     return 0;
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement