Submission #1053986

#TimeUsernameProblemLanguageResultExecution timeMemory
1053986hotboy2703Homework (CEOI22_homework)C++17
100 / 100
76 ms124880 KiB
#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 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...