Advertisement
erfanul007

tURTLE gRAPHICS

Jan 9th, 2019
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long int ll;
  5. typedef unsigned long long int ull;
  6. typedef vector<int> vi;
  7. typedef vector<vi> vvi;
  8. typedef pair<int,int> pii;
  9. typedef vector< pii > vpii;
  10. typedef set<int> sti;
  11.  
  12. #define pb push_back
  13. #define pob pop_back
  14. #define mp make_pair
  15. #define ff first
  16. #define ss second
  17. #define loop1(i,n) for(int i=1; i<=int(n); i++)
  18. #define loop(i,y) for(int i=0; i<int(y); i++)
  19. #define rloop(i,y) for(int i=int(y)-1; i>=0; i--)
  20. #define read() freopen("input.txt", "r", stdin)
  21. #define write() freopen("output.txt", "w", stdout)
  22. #define cspf(i) printf("Case #%d: ", i)
  23. /// Constants
  24. #define eps 1e-9
  25. #define PI acos(-1.0) // 3.1415926535897932
  26.  
  27. int main()
  28. {
  29. read();
  30. int n,i,j,k;
  31. scanf("%d",&n);
  32. loop1(i,n){
  33. int x,y,ck[100][100];
  34. char s[200];
  35. scanf("%d %d",&x,&y);
  36. scanf("%s",s);
  37. int ln=strlen(s);
  38. for(j=0;j<100;j++){
  39. for(k=0;k<100;k++)
  40. ck[j][k]=0;
  41. }
  42. int c=0,cnt=0;
  43. loop(j,ln){
  44. ck[x][y]=1;
  45. if(s[j]=='F'){
  46. if(c%4==0)
  47. y++;
  48. else if(c%4==1)
  49. x++;
  50. else if(c%4==2)
  51. y--;
  52. else if(c%4==3)
  53. x--;
  54. if(ck[x][y]==1)
  55. cnt++;
  56. }
  57. else if(s[j]=='R')
  58. c++;
  59. else if(s[j]=='L')
  60. c--;
  61. }
  62. cspf(i);
  63. printf("%d %d %d\n",x,y,cnt);
  64. }
  65. return 0;
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement