Advertisement
rafid_shad

A

Aug 6th, 2019
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.94 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. //*****************Data type**********************//
  5. typedef long long ll;
  6. typedef long long int lli;
  7. typedef unsigned long long  ull;
  8. typedef unsigned long long int ulli;
  9.  
  10. //*****************Map****************************//
  11. typedef map<int, int> mp;
  12. typedef map<int, string> mps;
  13. typedef map<int, char>mpc;
  14. typedef map<string, int>mpsi;
  15. typedef map<char, int>mpci;
  16.  
  17. //****************Pair****************************//
  18. typedef pair<int, int> pii;
  19. typedef pair<string, string> pss;
  20. typedef pair<char, char> pcc;
  21. typedef pair<int, string> pis;
  22. typedef pair<int, char> pic;
  23.  
  24. //*****************Vector************************//
  25. typedef vector<int> VI;
  26. typedef vector<string> VS;
  27. typedef vector<double> VD;
  28. typedef vector<lli> VLLI;
  29. typedef vector<VI> VVI;
  30. typedef vector<pii> VPI;
  31.  
  32. //-------------------------------------------------------------------------------//
  33. #define pp1(A)              printf("%d\n",A)
  34. #define pp2(A,B)            printf("%d %d\n",A,B)
  35. #define pp3(A,B,C)          printf("%d %d %d\n",A,B,C)
  36.  
  37. #define ss1(A)              scanf("%d", &A)
  38. #define ssl(A)              scanf("%lld", &A)
  39. #define ss2(A,B)            scanf("%d,%d",&A,&B)
  40. #define ss3(A,B,C)          scanf("%d,%d,%d",&A,&B,&C)
  41.  
  42. //--------------------------------------------------------------------------------//
  43. #define nosync              ios_base::sync_with_stdio(false), cin.tie(NULL)
  44. #define pf                  push_front
  45. #define pb                  push_back
  46. #define popp                pop_back()
  47. #define itr                 iterator
  48. #define mk                  make_pair
  49. #define ff                  first
  50. #define ss                  second
  51. #define END                 return 0
  52. #define line                printf("\n")
  53. #define sq(a)               (a)*(a)
  54. #define SZ(a)               (int)a.size()
  55. #define all(a)              (a).begin(), (a).end()
  56. #define Erase(V,I)          (V).erase((V).begin()+I)
  57. #define Insert(V,I,M)       (V).insert((V).begin()+I,M)
  58. #define READ()              freopen("input.txt", "r", stdin)
  59. #define WRITE()             freopen("output.txt", "w", stdout)
  60.  
  61. //********************************************************************************//
  62. #define loop(i,n)           for(int i=0;i<n;i++)
  63. #define loop2(i,n)          for(int i=n-1;i>=0;i--)
  64. #define loop3(i,t)          for(int i=1;i<=t;i++)
  65. #define scanV(V, N)         for(int i=0; i<N; i++){ int X; ss1(X); V.pb(X); }
  66. #define scanVll(V, N)       for(int i=0; i<N; i++){ lli X; ssl(X); V.pb(X); }
  67. #define scanA(A, N)         for(int i=0; i<N; i++){ ss1(A[i]); }
  68. #define scanAll(A, N)       for(int i=0; i<N; i++){ ssl(A[i]); }
  69. #define printA(A, N)        for(int i=0; i<N; i++){ cout<<A[i]; if (i<N-1)cout<<" ";else cout<<endl; }
  70. #define vout(v)             for(int i = 0; i < v.size(); i++) {cout << v[i]; if(i < v.size() - 1) cout <<" "; else cout << endl;}
  71.  
  72. /*-----------------------GCD && LCM------------------*/
  73. int gcd(int a, int b)
  74. {
  75.     return b == 0 ? a : gcd(b, a % b);
  76. }
  77. int lcm(int a, int b)
  78. {
  79.     return a * (b / gcd(a, b));
  80. }
  81. /*---------------------------------------------------*/
  82.  
  83. //---------------------------------*START*-----------------------------------------//
  84.  
  85. char left1(char s)
  86. {
  87.     if(s=='<')
  88.         s='v';
  89.     else if(s=='^')
  90.         s='<';
  91.     else if(s=='>')
  92.         s='^';
  93.     else if(s=='v')
  94.         s='>';
  95.     return s;
  96. }
  97. char right1(char s)
  98. {
  99.     if(s=='<')
  100.         s='^';
  101.     else if(s=='>')
  102.         s='v';
  103.     else if(s=='^')
  104.         s='>';
  105.     else if(s=='v')
  106.         s='<';
  107.     return s;
  108. }
  109.  
  110. void same(string s[],int len)
  111. {
  112.     //line;
  113.     loop(i,len)
  114.     {
  115.         loop(j,len)
  116.         {
  117.             cout<<s[i][j];
  118.         }
  119.         line;
  120.     }
  121. }
  122.  
  123. void Right(string s[],int len)
  124. {
  125.     string s1[len],s2[len];
  126.     loop(i,len)
  127.     {
  128.         loop(j,len)
  129.         {
  130.             s2[i][j]=s[i][j];
  131.  
  132.             s1[j]+=s[i][j];
  133.         }
  134.  
  135.     }
  136.     //line;
  137.     loop(i,len)
  138.     {
  139.         reverse(s1[i].begin(),s1[i].end());
  140.         loop(j,len)
  141.         {
  142.             if(s1[i][j]=='<')
  143.                 s1[i][j]='^';
  144.             else if(s1[i][j]=='>')
  145.                 s1[i][j]='v';
  146.             else if(s1[i][j]=='^')
  147.                 s1[i][j]='>';
  148.             else if(s1[i][j]=='v')
  149.                 s1[i][j]='<';
  150.             cout<<s1[i][j];
  151.         }
  152.         line;
  153.  
  154.     }
  155. }
  156.  
  157. int main()
  158. {
  159.     int n;
  160.     string s;
  161.     cin>>n>>s;
  162.     string s1[n];
  163.     loop(i,n)cin>>s1[i];
  164.     int len=s.size();
  165.     char result=s1[0][0];
  166.     //cout<<result<<endl;
  167.     if(n==1)
  168.     {
  169.         loop(i,len)
  170.         {
  171.             if(s[i]=='L')
  172.             {
  173.                 result=left1(result);
  174.             }
  175.             else
  176.             {
  177.                 result=right1(result);
  178.             }
  179.         }
  180.         cout<<result<<endl;
  181.         END;
  182.     }
  183.  
  184.     if(len%2==0)
  185.     {
  186.         same(s1,n);
  187.     }
  188.     else
  189.     {
  190.         Right(s1,n);
  191.     }
  192.     END;
  193. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement