Submission #772778

#TimeUsernameProblemLanguageResultExecution timeMemory
772778Valters07Homework (CEOI22_homework)C++14
100 / 100
153 ms131416 KiB
#include <bits/stdc++.h> #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt") #define fio ios_base::sync_with_stdio(0);cin.tie(0); #define ll long long #define en cin.close();return 0; #define pb push_back #define fi first//printf("%lli\n",cur); #define se second//scanf("%lli",&n); using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int N = 1e6+5; vector<int> mid[N]; string str; pair<int,int> go2(int l, int r, int op) { if(l==r) return {0,0}; int pos = mid[op].back(); mid[op].pop_back(); auto l1 = go2(l+4,pos-1,op+1), r1 = go2(pos+1,r-1,op+1); if(str[l+1]=='i') return {min(l1.fi,r1.fi),l1.se+r1.se+1}; else return {l1.fi+r1.fi+1,min(l1.se,r1.se)}; } int main() { fio // ifstream cin("in.in"); cin >> str; int n = 0, op = 0; for(int i = str.size()-1;i>=0;i--) { n+=(str[i]=='?'); op+=(str[i]==')')-(str[i]=='('); if(str[i]==',') mid[op].pb(i); } auto t = go2(0,str.size()-1,1); cout << n-t.fi-t.se << endl; // cin.close(); 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...