#include "bits/stdc++.h"
using namespace std;
using pii = pair <int, int>;
string s;
int question_marks, point;
pii get()
{
if(s[point] == ')') point++;
if(s[point] == ',' || s[point] == '(') point += 1;
if(s[point] == '?') return {1, question_marks};
if(s[point] == 'm') point += 2;
if(s[point] == 'a' || s[point] == 'i') point += 1;
bool ismax = (s[point] == 'x');
point++;
pii u1 = get();
point++;
pii u2 = get();
if(ismax)
return {u1.first + u2.first, max(u1.second, u2.second)};
else
return {min(u1.first, u2.first), u1.second + u2.second - question_marks - 1};
}
signed main()
{
cin >> s;
question_marks = count(s.begin(), s.end(), '?');
pii ans = get();
cout << ans.second - ans.first + 1 << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
4052 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
4052 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
254 ms |
118796 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
4052 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
4052 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |