fork(3) download
  1. // iostream is too mainstream
  2. #include <cstdio>
  3. // bitch please
  4. #include <iostream>
  5. #include <algorithm>
  6. #include <cstdlib>
  7. #include <vector>
  8. #include <set>
  9. #include <map>
  10. #include <queue>
  11. #include <stack>
  12. #include <list>
  13. #include <cmath>
  14. #include <iomanip>
  15. #define dibs reserve
  16. #define OVER9000 1234567890
  17. #define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
  18. #define tisic 47
  19. #define soclose 1e-8
  20. #define chocolate win
  21. // so much chocolate
  22. #define patkan 9
  23. #define ff first
  24. #define ss second
  25. #define abs(x) ((x < 0)?-(x):x)
  26. #define uint unsigned int
  27. #define dbl long double
  28. using namespace std;
  29. // mylittledoge
  30.  
  31. int main() {
  32. cin.sync_with_stdio(0);
  33. cin.tie(0);
  34. int T;
  35. cin >> T;
  36. cout << T << "\n";
  37. for(int t =0; t < T; t++) {
  38. string s;
  39. cin >> s;
  40. vector< vector<bool> > isF(242,vector<bool>(142,false));
  41. int y =109, x =0, d =0;
  42. isF[y][x] =true;
  43. int dx[] ={1,0,-1,0};
  44. int dy[] ={0,1,0,-1};
  45. for(int i =0; i < s.length(); i++) {
  46. if(s[i] == 'R') {
  47. d =(d+1)%4;
  48. isF[y+dy[d]][x+dx[d]] =true;
  49. x +=dx[d];
  50. y +=dy[d];
  51. continue;}
  52. if(s[i] == 'F') {
  53. isF[y+dy[d]][x+dx[d]] =true;
  54. x +=dx[d];
  55. y +=dy[d];
  56. continue;}
  57. if(s[i] == 'L') {
  58. d =(d+3)%4;
  59. isF[y+dy[d]][x+dx[d]] =true;
  60. x +=dx[d];
  61. y +=dy[d];
  62. continue;}
  63. x -=dx[d];
  64. y -=dy[d];
  65. d =(d+2)%4;}
  66.  
  67. x =0;
  68. while(x < 242-9) {
  69. bool b =false;
  70. for(int i =0; i < 142; i++) if(isF[x+1][i]) b =true;
  71. if(!b) x++;
  72. else break;}
  73. int x2 =241;
  74. while(x2 > 0) {
  75. bool b =false;
  76. for(int i =0; i < 142; i++) if(isF[x2-1][i]) b =true;
  77. if(!b) x2--;
  78. else break;}
  79. y =0;
  80. for(int i =0; i < 242; i++) for(int j =0; j < 142; j++)
  81. if(isF[i][j]) y =max(y,j);
  82. cout << x2-x+1 << " " << y+2 << "\n";
  83. for(int i =0; i < x2-x+1; i++) {
  84. string s;
  85. for(int j =0; j <= y+1; j++) {
  86. if(isF[i+x][j]) s +='.';
  87. else s +='#';}
  88. cout << s << "\n";}
  89. }
  90. return 0;}
  91.  
  92. // look at my code
  93. // my code is amazing
Success #stdin #stdout 0s 3436KB
stdin
3
FFRBLF
FFRFRBRFBFRBRFLF
FRLFFFLBRFFFRFFFRFRFBRFLBRFRLFLFFR
stdout
3
4 4
####
...#
##.#
####
7 5
#####
...##
##.##
#...#
##.##
##.##
#####
7 7
#######
#...#.#
#.#...#
#.#.###
..###.#
#.....#
#######