Submission #1014465

#TimeUsernameProblemLanguageResultExecution timeMemory
1014465shiomusubi496Homework (CEOI22_homework)C++17
100 / 100
193 ms108256 KiB
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define rep2(i, a, b) for (int i = (int)(a); i < (int)(b); ++i) #define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i) #define all(v) begin(v), end(v) using namespace std; using ll = long long; template<class T, class U> bool chmin(T& a, const U& b) { return a > b ? a = b, true : false; } template<class T, class U> bool chmax(T& a, const U& b) { return a < b ? a = b, true : false; } struct Data { int l, r, n; }; Data expr(typename string::iterator& itr) { if (*itr == '?') { ++itr; return {0, 1, 1}; } assert(*itr == 'm'); ++itr; if (*itr == 'i') { ++itr; ++itr; ++itr; auto [l1, r1, n1] = expr(itr); assert(*itr == ','); ++itr; auto [l2, r2, n2] = expr(itr); assert(*itr == ')'); ++itr; return {min(l1, l2), r1 + r2 - 1, n1 + n2}; } else { ++itr; ++itr; ++itr; auto [l1, r1, n1] = expr(itr); assert(*itr == ','); ++itr; auto [l2, r2, n2] = expr(itr); assert(*itr == ')'); ++itr; return {l1 + l2 + 1, max(n1 + r2, n2 + r1), n1 + n2}; } } int main() { string S; cin >> S; auto itr = S.begin(); auto [l, r, n] = expr(itr); cout << r - l << endl; }
#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...