제출 #1272934

#제출 시각아이디문제언어결과실행 시간메모리
1272934ThunnusHomework (CEOI22_homework)C++20
100 / 100
66 ms54344 KiB
#include<bits/stdc++.h> using namespace std; using i64 = long long; #define int i64 #define vi vector<int> #define vvi vector<vi> #define vb vector<bool> #define pii pair<int, int> #define fi first #define se second #define sz(x) (int)(x).size() signed main(){ ios_base::sync_with_stdio(false); cin.tie(0); string s; cin >> s; int n = count(s.begin(), s.end(), '?'); auto printp = [&](pii &p) -> void { cout << p.fi << " " << p.se << "\n"; }; int idx = 0; function<pii()> calc = [&]() -> pii { if(s[idx++] == '?') return {1, n}; char c = s[idx]; idx += 3; pii p1 = calc(); idx++; pii p2 = calc(); idx++; if(c == 'a'){ return {p1.fi + p2.fi, max(p1.se, p2.se)}; } else{ return {min(p1.fi, p2.fi), n - (2 * n - p1.se - p2.se) - 1}; } }; pii range = calc(); //printp(range); cout << range.se - range.fi + 1 << "\n"; 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...