forked from beet-aizu/library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdice.cpp
136 lines (125 loc) · 2.07 KB
/
dice.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
struct Dice{
int s[6];
void roll(char c){
//the view from above
// N
//W E
// S
//s[0]:top
//s[1]:south
//s[2]:east
//s[3]:west
//s[4]:north
//s[5]:bottom
int b;
if(c=='E'){
b=s[0];
s[0]=s[3];
s[3]=s[5];
s[5]=s[2];
s[2]=b;
}
if(c=='W'){
b=s[0];
s[0]=s[2];
s[2]=s[5];
s[5]=s[3];
s[3]=b;
}
if(c=='N'){
b=s[0];
s[0]=s[1];
s[1]=s[5];
s[5]=s[4];
s[4]=b;
}
if(c=='S'){
b=s[0];
s[0]=s[4];
s[4]=s[5];
s[5]=s[1];
s[1]=b;
}
// migi neji
if(c=='R'){
b=s[1];
s[1]=s[2];
s[2]=s[4];
s[4]=s[3];
s[3]=b;
}
if(c=='L'){
b=s[1];
s[1]=s[3];
s[3]=s[4];
s[4]=s[2];
s[2]=b;
}
}
int top() {
return s[0];
}
int hash(){
int res=0;
for(int i=0;i<6;i++) res=res*256+s[i];
return res;
}
};
vector<Dice> makeDices(Dice d){
vector<Dice> res;
for(int i=0;i<6;i++){
Dice t(d);
if(i==1) t.roll('N');
if(i==2) t.roll('S');
if(i==3) t.roll('S'),t.roll('S');
if(i==4) t.roll('L');
if(i==5) t.roll('R');
for(int k=0;k<4;k++){
res.push_back(t);
t.roll('E');
}
}
return res;
}
//END CUT HERE
signed ITP1_11_A(){
Dice d;
for(int i=0;i<6;i++) cin >> d.s[i];
string s;cin >> s;
for(int i=0;i<(int)s.size();i++) d.roll(s[i]);
cout << d.top() << endl;
return 0;
}
/*
verified on 2018/02/09
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_11_A
*/
signed AOJ_0502(){
Int n;
while(cin>>n,n){
Dice d;
for(Int i=0;i<6;i++) d.s[i]=i+1;
Int ans=d.top();
for(Int i=0;i<n;i++){
string s;
cin>>s;
d.roll(s[0]);
ans+=d.top();
}
cout<<ans<<endl;
}
return 0;
}
/*
verified on 2018/02/09
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0502
*/
signed main(){
ITP1_11_A();
//AOJ_0502();
return 0;
}