Submission #708690

#TimeUsernameProblemLanguageResultExecution timeMemory
708690becaidoHomework (CEOI22_homework)C++17
100 / 100
79 ms76800 KiB
#pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx,popcnt,sse4,abm") #include <bits/stdc++.h> using namespace std; #ifdef WAIMAI #define debug(HEHE...) cout << "[" << #HEHE << "] : ", dout(HEHE) void dout() {cout << '\n';} template<typename T, typename...U> void dout (T t, U...u) {cout << t << (sizeof... (u) ? ", " : ""), dout (u...);} #else #define debug(...) 7122 #endif #define ll long long #define Waimai ios::sync_with_stdio(false), cin.tie(0) #define FOR(x,a,b) for (int x = a, I = b; x <= I; x++) #define pb emplace_back #define F first #define S second string s; int p; tuple<int, int, int> work() { while (s[p] == ')' || s[p] == ',' || s[p] == '(') p++; if (s[p] == '?') { p++; return {1, 1, 1}; } p += 2; int ty = s[p] == 'x' ? 0 : 1; p++; auto [l1, r1, n1] = work(); auto [l2, r2, n2] = work(); if (ty == 0) return {l1 + l2, max(n1 + r2, n2 + r1), n1 + n2}; else return {min(l1, l2), r1 + r2 - 1, n1 + n2}; } void solve() { cin >> s; auto [l, r, n] = work(); cout << r - l + 1 << '\n'; } int main() { Waimai; solve(); }
#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...