Submission #731203

#TimeUsernameProblemLanguageResultExecution timeMemory
731203baokhue232005Homework (CEOI22_homework)C++14
100 / 100
434 ms165732 KiB
/* #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #pragma GCC optimize("unroll-loops") */ // lethal option #include<bits/stdc++.h> using namespace std; #define all(flg) flg.begin(), flg.end() #define int long long #define pb push_back #define fi first #define se second #define endl "\n" #define eb emplace_back #define ii pair<int, int> #define vi vector<int> #define PI 3.141592653589793238462643383279502884 #define ll long long #define ld long double #define for1(i, ff, gg) for(int i = ff; i <= gg; ++i) #define for2(i, ff, gg) for(int i = ff; i >= gg; --i) const ll mod = 1e9 + 7; const int maxN = 2e6 + 5; const ll oo = 1e18 + 7; int n = 0, a[maxN]; int x, y, z, k; vi vc[maxN]; bool tag[maxN]; int dfs_build(){ int node = ++z; char c; cin >> c; if(c == '?'){ ++n; return node; } cin >> c >> c; tag[node] = (c == 'n'); cin >> c; vc[node].pb(dfs_build()); cin >> c; vc[node].pb(dfs_build()); cin >> c; return node; } int dfs_calc(int node){ if(vc[node].empty()) return 1; int v1 = dfs_calc(vc[node][0]); int v2 = dfs_calc(vc[node][1]); if(tag[node]) return v1 + v2; else return min(v1, v2); } signed main(){ // freopen(".inp", "r", stdin); ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); z = 0; dfs_build(); int ans = n + 2; ans -= dfs_calc(1); for1(i, 1, z) tag[i] = !tag[i]; ans -= dfs_calc(1); cout << ans << 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...