Submission #772689

#TimeUsernameProblemLanguageResultExecution timeMemory
772689Valters07Homework (CEOI22_homework)C++14
0 / 100
1077 ms10652 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()); string str; int go2(int l, int r) { if(l==r) return 0; int op = 0, pos = l+4; while(1) { if(str[pos]=='(') op++; else if(str[pos]==')') op--; else if(str[pos]==','&&op==0) break; pos++; } int l1 = go2(l+4,pos-1), r1 = go2(pos+1,r-1); if(str[l+1]=='i') return min(l1,0)+min(r1,0)-1; else return max(l1,0)+max(r1,0)+1; } int main() { fio // ifstream cin("in.in"); cin >> str; int n = 0; for(auto x:str) n+=(x=='?'); cout << n-abs(go2(0,str.size()-1)); // 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...