Submission #862894

#TimeUsernameProblemLanguageResultExecution timeMemory
862894Trisanu_DasHomework (CEOI22_homework)C++17
100 / 100
140 ms46236 KiB
#include "bits/stdc++.h" using namespace std; using pii = pair <int, int>; string s; int question_marks, point; pair<int, int> get() { 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++; pair<int, int> u, w; u = get(); point++; w = get(); point++; if(ismax) return {u.first + w.first, max(u.second, w.second)}; else return {min(u.first, w.first), u.second + w.second - question_marks - 1}; } signed main() { cin >> s; question_marks = count(s.begin(), s.end(), '?'); pair<int, int> ans = get(); cout << ans.second - ans.first + 1 << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...