Advertisement
Guest User

Untitled

a guest
Jan 19th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.20 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <vector>
  4. #include <string>
  5. #include <stack>
  6. #include <fstream>
  7. #include <iomanip>
  8. #include <queue>
  9.  
  10. using namespace std;
  11.  
  12. typedef long long ll;
  13.  
  14. int main(){
  15.  
  16.     ios_base::sync_with_stdio(false);
  17.     cin.tie(nullptr);
  18.     cout.tie(nullptr);
  19.  
  20.     string s;
  21.     string e = "";
  22.     cin >> s;
  23.  
  24.     ll x = 0,y = 0,num = 1, hm = 1, index = 0, up, right, down,left,bottom;
  25.     bool change = false;
  26.     ll i = 0, temp;
  27.     num = 1;
  28.     up = 5;
  29.     down = 2;
  30.     right = 4;
  31.     left = 3;
  32.     bottom = 6;
  33.  
  34.  
  35.     while(i < s.size()){
  36.  
  37.         if(s[i] == '.')
  38.             break;
  39.  
  40.         if(s[i] == '-')
  41.             change = !change;
  42.         if(s[i] == '+' && change)
  43.             change = false;
  44.         while(isdigit(s[i])){
  45.             e+=s[i];
  46.             i++;
  47.         }
  48.         if(!e.empty()) {
  49.             hm = stoi(e);
  50.             e = "";
  51.             //cout << "HM = " << hm << endl;
  52.         }
  53.         else{
  54.             hm = 1;
  55.         }
  56.         if(s[i] == 'X' and !change){
  57.             x += hm;
  58.             for(int j = 0; j < hm%4; ++j) {
  59.                 temp = num;
  60.                 num = left;
  61.                 left = bottom;
  62.                 bottom = right;
  63.                 right = temp;
  64.             }
  65.         }
  66.         else if(s[i] == 'X' and change) {
  67.             x -= hm;
  68.             for(int j = 0; j < hm%4; ++j) {
  69.                 temp = num;
  70.                 num = right;
  71.                 right = bottom;
  72.                 bottom = left;
  73.                 left = temp;
  74.             }
  75.         }
  76.         else if(s[i] == 'Y' and !change) {
  77.             y += hm;
  78.             for(int j = 0; j < hm%4; ++j) {
  79.                 temp = num;
  80.                 num = down;
  81.                 down = bottom;
  82.                 bottom = up;
  83.                 up = temp;
  84.             }
  85.         }
  86.         else if(s[i] == 'Y' and change) {
  87.             for(int j = 0; j < hm%4; ++j) {
  88.                 y -= hm;
  89.                 temp = num;
  90.                 num = up;
  91.                 up = bottom;
  92.                 bottom = down;
  93.                 down = temp;
  94.             }
  95.         }
  96.  
  97.         ++i;
  98.     }
  99.  
  100.     cout << x << " " << y << " " << num << endl;
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement