Submission #1015924

#TimeUsernameProblemLanguageResultExecution timeMemory
1015924irmuunHomework (CEOI22_homework)C++17
53 / 100
1044 ms14284 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define ff first #define ss second #define all(s) s.begin(),s.end() #define rall(s) s.rbegin(),s.rend() string s; array<int,3>solve(int l,int r){ if(l==r) return {1,1,1}; int cur=0; for(int i=l;i<=r;i++){ if(s[i]=='(') cur++; if(s[i]==')') cur--; if(s[i]==','&&cur==1){ auto L=solve(l+4,i-1); auto R=solve(i+1,r-1); if(s[l+1]=='a'){//max return {L[0]+R[0],max(L[1]+R[2],R[1]+L[2]),L[2]+R[2]}; } else{ return {min(L[0],R[0]),L[1]+R[1]-1,L[2]+R[2]}; } break; } } return {0,0,0}; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin>>s; auto ans=solve(0,s.size()-1); cout<<ans[1]-ans[0]+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...