Submission #1174301

#TimeUsernameProblemLanguageResultExecution timeMemory
1174301heeheeheehaawHomework (CEOI22_homework)C++20
100 / 100
59 ms38680 KiB
#include <bits/stdc++.h> using namespace std; int n, x; string s; pair<int, int> solve() { if(s[x++] == '?') return {1, n}; char c = s[x]; x += 3; pair<int, int> a = solve(); x++; pair<int, int> b = solve(); x++; if(c == 'i') { return {min(a.first, b.first), a.second + b.second - n - 1}; } else { return {a.first + b.first, max(a.second, b.second)}; } } int main() { ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0); cin>>s; for(int i = 0; i < s.size(); i++) if(s[i] == '?') n++; pair<int, int> rez = solve(); cout<<rez.second - rez.first + 1; return 0; }
#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...