Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <string>
- #include <set>
- using namespace std;
- enum
- {
- UP = 0,
- RIGHT,
- DOWN,
- LEFT,
- EDGE_SIZE = 3,
- FRONT_EDGE = 0,
- BACK_EDGE,
- LEFT_EDGE,
- RIGHT_EDGE,
- LOWER_EDGE,
- UPPER_EDGE
- };
- void f(int y, int x, int dy, int dx)
- {
- if ((y >= -EDGE_SIZE - EDGE_SIZE / 2) && (y < -EDGE_SIZE / 2))
- {
- if (x == EDGE_SIZE / 2 + 1)
- {
- x--;
- swap(y, x);
- swap(dy, dx);
- }
- else if (x == -EDGE_SIZE / 2 - 1)
- {
- x++;
- dx *= -1;
- swap(y, x);
- swap(dy, dx);
- }
- }
- else if ((y > EDGE_SIZE / 2) && (y <= EDGE_SIZE + EDGE_SIZE / 2))
- {
- if (x == EDGE_SIZE / 2 + 1)
- {
- x--;
- dx *= -1;
- swap(y, x);
- swap(dy, dx);
- }
- else if (x == -EDGE_SIZE / 2 - 1)
- {
- x++;
- swap(y, x);
- swap(dy, dx);
- }
- }
- }
- void fix(int& x, int& y, int& dx, int& dy)
- {
- if (y == EDGE_SIZE * 2 + EDGE_SIZE / 2 + 1)
- {
- y -= 4 * EDGE_SIZE;
- }
- else if (y == -EDGE_SIZE - EDGE_SIZE / 2 - 1)
- {
- y += 4 * EDGE_SIZE;
- }
- else if (dx == 0)
- {
- if ((x >= -EDGE_SIZE - EDGE_SIZE / 2) && (x < -EDGE_SIZE / 2))
- {
- if (y == EDGE_SIZE / 2 + 1)
- {
- y--;
- swap(x, y);
- swap(dx, dy);
- }
- else if (y == -EDGE_SIZE / 2 - 1)
- {
- y++;
- dy *= -1;
- swap(x, y);
- swap(dx, dy);
- }
- }
- else if ((x > EDGE_SIZE / 2) && (x <= EDGE_SIZE + EDGE_SIZE / 2))
- {
- if (y == EDGE_SIZE / 2 + 1)
- {
- y--;
- dy *= -1;
- swap(x, y);
- swap(dx, dy);
- }
- else if (y == -EDGE_SIZE / 2 - 1)
- {
- y++;
- swap(x, y);
- swap(dx, dy);
- }
- }
- }
- else if (dy == 0)
- {
- if ((y >= -EDGE_SIZE - EDGE_SIZE / 2) && (y < -EDGE_SIZE / 2))
- {
- if (x == EDGE_SIZE / 2 + 1)
- {
- x--;
- swap(y, x);
- swap(dy, dx);
- }
- else if (x == -EDGE_SIZE / 2 - 1)
- {
- x++;
- dx *= -1;
- swap(y, x);
- swap(dy, dx);
- }
- }
- else if ((y > EDGE_SIZE / 2) && (y <= EDGE_SIZE + EDGE_SIZE / 2))
- {
- if (x == EDGE_SIZE / 2 + 1)
- {
- x--;
- dx *= -1;
- swap(y, x);
- swap(dy, dx);
- }
- else if (x == -EDGE_SIZE / 2 - 1)
- {
- x++;
- swap(y, x);
- swap(dy, dx);
- }
- }
- else if (x == -EDGE_SIZE - EDGE_SIZE / 2 - 1)
- {
- dx *= -1;
- x += 1 + EDGE_SIZE;
- y = 2 * EDGE_SIZE - y;
- }
- else if (x == EDGE_SIZE + EDGE_SIZE / 2 + 1)
- {
- dx *= -1;
- x -= 1 - EDGE_SIZE;
- y = 2 * EDGE_SIZE - y;
- }
- else if (x == -EDGE_SIZE / 2 - 1)
- {
- dx *= -1;
- y -= 2 * EDGE_SIZE;
- y *= -1;
- x -= EDGE_SIZE - 1;
- }
- else if (x == EDGE_SIZE / 2 + 1)
- {
- dx *= -1;
- y -= 2 * EDGE_SIZE;
- y *= -1;
- x += EDGE_SIZE - 1;
- }
- }
- }
- vector<int>& operator+= (vector<int>& target, const vector<int>& adding)
- {
- auto adding_it = adding.begin();
- for (auto it = target.begin(); it != target.end(); ++it, ++adding_it) {
- *it += *adding_it;
- }
- return target;
- }
- vector<int>& operator-= (vector<int>& target, const vector<int>& subtrahend)
- {
- auto subtrahend_it = subtrahend.begin();
- for (auto it = target.begin(); it != target.end(); ++it, ++subtrahend_it) {
- *it -= *subtrahend_it;
- }
- return target;
- }
- int
- fix_is_necessary(const vector<int>& coordinates)
- {
- for (int i = 0; i < coordinates.size(); i++) {
- if ((coordinates[i] < 0) && (coordinates[i] >= EDGE_SIZE)) {
- return i;
- }
- }
- return -1;
- }
- void
- coordinates_changing(vector<int>& coordinates, vector<int>& direction)
- {
- coordinates += direction;
- int index_to_fix;
- if ((index_to_fix = fix_is_necessary(coordinates)) == -1) {
- return;
- }
- coordinates -= direction;
- }
- inline void
- change_coordinates(int& x, int& y, int& z, int& edge, const int direction)
- {
- }
- inline void
- process(const char command, set<int>& visited)
- {
- auto encode_coordinates = [](int x, int y, int z) { return x * EDGE_SIZE * EDGE_SIZE + y * EDGE_SIZE + z; };
- static int x = 1, y = 1, z = 0;
- static int face_mode = 1;
- static int direction = 0;
- visited.insert(encode_coordinates(x, y, z));
- switch (command)
- {
- case 'R':
- direction += 1;
- direction %= (LEFT + 1);
- break;
- case 'L':
- direction -= 1;
- direction += LEFT + 1;
- direction %= (LEFT + 1);
- break;
- case 'S':
- return;
- }
- change_coordinates(x, y, z, edge, direction);
- }
- int main()
- {
- string input;
- set<int> visited;
- cin >> input;
- for (auto elem : input)
- {
- process(elem, visited);
- }
- cout << visited.size() << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement