Advertisement
Imran2544

trutle graphics(WA again)

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