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>
using ll = long long;
using namespace std;
#define pll pair <ll,ll>
#define fi first
#define se second
#define MP make_pair
#define sz(a) (ll((a).size()))
#define BIT(mask,i) (((mask) >> (i))&1)
#define MASK(i) (1LL << (i))
struct result{
ll l,r,s;
};
string s;
ll ptr = 0;
result solve(){
// cout<<"SUS "<<ptr<<endl;
if (s[ptr] == 'm'){
bool type = (s[ptr+1]=='i');
ptr+=4;
result a,b,res;
a=solve(),ptr++,b=solve(),ptr++;
res.s = a.s+b.s;
if (type){
res.l = min(a.l,b.l);
res.r = res.s-(a.s-a.r+1+b.s-b.r+1)+1;
}
else{
res.l = a.l+b.l;
res.r = res.s - min(a.s-a.r+1,b.s-b.r+1)+1;
}
return res;
}
else{
ptr++;
return {1,1,1};
}
}
int main(){
ios_base::sync_with_stdio(0);cin.tie(nullptr);
cin>>s;
result tmp = solve();
cout<<(tmp.r-tmp.l+1);
}
# | 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... |