제출 #1323905

#제출 시각아이디문제언어결과실행 시간메모리
1323905gohchingjaykHomework (CEOI22_homework)C++20
100 / 100
103 ms106952 KiB
#pragma GCC optimize("O3,inline") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; using ll = long long; #define int ll using ii = pair<int, int>; using iii = pair<ii, int>; constexpr int INF = 1e18 + 5; constexpr int MAXN = 1000000 + 5; constexpr int MOD = 1e9 + 7; string s; int ctr = 0; iii dfs() { if (s[ctr] == '?') return iii{ii{0, 1}, 0}; bool ismax = s[ctr] == 'a'; ctr++; iii ch1 = dfs(); ctr++; iii ch2 = dfs(); int sumall = ch1.first.first + ch1.first.second + ch1.second + ch2.first.first + ch2.first.second + ch2.second; iii ans; if (ismax) { ans.first.first = ch1.first.first + ch2.first.first + 1; ans.second = min(ch1.second, ch2.second); ans.first.second = sumall - ans.first.first - ans.second; } else { ans.first.first = min(ch1.first.first, ch2.first.first); ans.second = ch1.second + ch2.second + 1; ans.first.second = sumall - ans.second - ans.first.first; } return ans; } signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); string t; cin >> t; for (char c : t) { if (c != 'a' && c != 'i' && c != '?') continue; s += c; } int ans = dfs().first.second; cout << ans; }
#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...