# Untitled

unknown
plain_text
a month ago
1.5 kB
1
Indexable
Never
#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include "assert.h"
#include <vector>

using namespace std;

#define ll long long

const int N = 600010;

#define ll long long
#define pb push_back
#define pii pair<int, int>
#define vi vector <int>
#define vii vector<pii>

void moveRight(vi &v) {
vi tmp = v;
tmp[1] = v[2];
tmp[2] = v[4];
tmp[4] = v[5];
tmp[5] = v[1];
v = tmp;
//return v;
}

void moveForward(vi &v) {
vi tmp = v;
tmp[0] = v[5];
tmp[2] = v[0];
tmp[3] = v[2];
tmp[5] = v[3];
v = tmp;
}

void turnCounterClockwise(vi &v) {
vi tmp = v;
tmp[0] = v[4];
tmp[1] = v[0];
tmp[3] = v[1];
tmp[4] = v[3];
v = tmp;
}

void solve() {
int n;
cin >> n;
vi a(6, 0);
cin >> a[0] >> a[1] >> a[2];
a[3] = 7 - a[0];
a[4] = 7 - a[1];
a[5] = 7 - a[2];
string s;
cin >> s;
for (char c : s) {
if (c == 'R')
turnCounterClockwise(a);
else if (c == 'L')
for (int i = 1; i <= 3; i++) turnCounterClockwise(a);
else if (c == 'N')
moveForward(a);
else if (c == 'S')
for (int i = 1; i <= 3; i++) moveForward(a);
else if (c == 'E')
moveRight(a);
else
for (int i = 1; i <= 3; i++) moveRight(a);
}
cout << a[0] << " " << a[1] << " " << a[2] << endl;
}

int main()
{
int T;
T = 1;
//cin >> T;
while (T--) {
solve();
}
return 0;
}