This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define pii pair<int,pair<int,int>>
#define ll long long
#define F first
#define S second
using namespace std;
pii rd(){
char c;
cin>>c;
if(c=='?'){
return {1,{1,1}};//len l r 1base;
}else{
cin>>c;
pii x,y;
pii ans;
if(c=='i'){//min
cin>>c>>c;
x=rd();
cin>>c;
y=rd();
ans.F=x.F+y.F;
ans.S.F=min(x.S.F,y.S.F);
ans.S.S=x.S.S+y.S.S-1;
}else{//max
cin>>c>>c;
x=rd();
cin>>c;
y=rd();
ans.F=x.F+y.F;
ans.S.F=x.S.F+y.S.F;
ans.S.S=max(x.F+y.S.S,x.S.S+y.F);
}
cin>>c;
return ans;
}
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
pii ans=rd();
cout<<ans.S.S-ans.S.F+1<<"\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |