Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <vector>
- #include <string>
- #include <stack>
- #include <fstream>
- #include <iomanip>
- #include <queue>
- using namespace std;
- typedef long long ll;
- int main(){
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- string s;
- string e = "";
- cin >> s;
- ll x = 0,y = 0,num = 1, hm = 1, index = 0, up, right, down,left,bottom;
- bool change = false;
- ll i = 0, temp;
- num = 1;
- up = 5;
- down = 2;
- right = 4;
- left = 3;
- bottom = 6;
- while(i < s.size()){
- if(s[i] == '.')
- break;
- if(s[i] == '-')
- change = !change;
- if(s[i] == '+' && change)
- change = false;
- while(isdigit(s[i])){
- e+=s[i];
- i++;
- }
- if(!e.empty()) {
- hm = stoi(e);
- e = "";
- //cout << "HM = " << hm << endl;
- }
- else{
- hm = 1;
- }
- if(s[i] == 'X' and !change){
- x += hm;
- for(int j = 0; j < hm%4; ++j) {
- temp = num;
- num = left;
- left = bottom;
- bottom = right;
- right = temp;
- }
- }
- else if(s[i] == 'X' and change) {
- x -= hm;
- for(int j = 0; j < hm%4; ++j) {
- temp = num;
- num = right;
- right = bottom;
- bottom = left;
- left = temp;
- }
- }
- else if(s[i] == 'Y' and !change) {
- y += hm;
- for(int j = 0; j < hm%4; ++j) {
- temp = num;
- num = down;
- down = bottom;
- bottom = up;
- up = temp;
- }
- }
- else if(s[i] == 'Y' and change) {
- for(int j = 0; j < hm%4; ++j) {
- y -= hm;
- temp = num;
- num = up;
- up = bottom;
- bottom = down;
- down = temp;
- }
- }
- ++i;
- }
- cout << x << " " << y << " " << num << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement