-
Notifications
You must be signed in to change notification settings - Fork 3
/
a.cpp
47 lines (47 loc) · 879 Bytes
/
a.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
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
char v;
cin >> n;
vector<bool> V(n);
for (int i = 0; i < n; ++i) {
cin >> v;
V[i] = v == 'T';
}
vector<bool> s;
while (cin >> v) {
switch (v) {
case '-': {
s.back() = !s.back();
break;
}
case '+': {
bool b = s.back();
s.pop_back();
bool a = s.back();
if (a) s.back() = true;
else {
s.back() = b;
}
break;
}
case '*': {
bool b = s.back();
s.pop_back();
bool a = s.back();
if (a && b) s.back() = true;
else s.back() = false;
break;
}
default: {
s.push_back(V[v-'A']);
break;
}
}
}
cout << (s.back() ? 'T' : 'F') << endl;
return 0;
}