Submission #983359

#TimeUsernameProblemLanguageResultExecution timeMemory
983359alexddHomework (CEOI22_homework)C++17
100 / 100
98 ms109564 KiB
#include<iostream> using namespace std; string e; int poz; pair<pair<int,int>,int> famax(pair<pair<int,int>,int> x, pair<pair<int,int>,int> y) { if(x.second==-1) return y; if(y.second==-1) return x; return {{x.first.first+y.first.first, x.second+y.second - min(x.second-x.first.second,y.second-y.first.second)},x.second+y.second}; } pair<pair<int,int>,int> famin(pair<pair<int,int>,int> x, pair<pair<int,int>,int> y) { if(x.second==-1) return y; if(y.second==-1) return x; return {{min(x.first.first,y.first.first), x.first.second+y.first.second-1},x.second+y.second}; } pair<pair<int,int>,int> mare() { if(poz>=(int)e.size()) return {{-1,-1},-1}; if(e[poz]=='?') { poz++; return {{1,1},1}; } else { if(e[poz+1]=='a')///max { //cout<<poz<<" max\n"; poz += 4; pair<pair<int,int>,int> aux = mare(); poz++; aux = famax(aux,mare()); poz++; return aux; } else///min { //cout<<poz<<" min\n"; poz += 4; pair<pair<int,int>,int> aux = mare(); poz++; aux = famin(aux,mare()); poz++; return aux; } } } signed main() { ios_base::sync_with_stdio(0);cin.tie(0); cin>>e; pair<pair<int,int>,int> rez = mare(); cout<<rez.first.second-rez.first.first+1; 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...