Saleh127

live ar 6802

Jun 17th, 2020
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define test int t; cin>>t; while (t--)
  4. #define ll long long int
  5. #define Faster ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  6. int main()
  7. {
  8. Faster
  9.  
  10. ll t,f;
  11. cin>>t;
  12. for(f=1;f<=t;f++)
  13. {
  14. ll x,y,pos=0,c=0,i,j,k,l;
  15. string a;
  16. ll fil[65][65]={0};
  17. cin>>x>>y;
  18. cin>>a;
  19. fil[x][y]=1;
  20. l=a.size();
  21.  
  22. for(i=0;i<l;i++)
  23. {
  24. if(a[i]=='F')
  25. {
  26. pos=pos%4;
  27. if(pos<0) pos+=4;
  28.  
  29. if(pos==0) y++;
  30. else if(pos==2) y--;
  31. else if(pos==1) x++;
  32. else if(pos==3) x--;
  33. fil[x][y]++;
  34. }
  35. else if(a[i]=='R') pos++;
  36. else if(a[i]=='L') pos--;
  37. }
  38. for(i=0;i<65;i++)
  39. {
  40. for(j=0;j<65;j++)
  41. {
  42. if(fil[i][j]>1)
  43. {
  44. c++;
  45. }
  46. }
  47. }
  48. printf("Case #%lld: %lld %lld %lld\n",f,x,y,c);
  49. }
  50.  
  51. return 0;
  52. }
Add Comment
Please, Sign In to add comment