제출 #1289108

#제출 시각아이디문제언어결과실행 시간메모리
1289108elotelo966Homework (CEOI22_homework)C++20
100 / 100
68 ms70016 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define OYY LLONG_MAX #define mod 1000000007 #define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define FOR for(int i=1;i<=n;i++) #define mid (start+end)/2 #define lim 300005 #define fi first #define se second #define pb push_back int n; string s; int i,top; inline pair<int,int> f(){ while(s[i]==',' || s[i]==')')i++; if(s[i]=='?'){top++;return make_pair(0,0);} bool kim=0; int mini=OYY,maxi=OYY; if(s[i+1]=='a')kim=1; i+=4; pair<int,int> gec=f(); if(kim)maxi=min(maxi,gec.se); else mini=min(mini,gec.fi); i++; while(s[i]==',' || s[i]==')')i++; pair<int,int>gec2=f(); if(kim){ maxi=min(maxi,gec2.se); mini=min(mini,gec.fi+gec2.fi+1); } else{ mini=min(mini,gec2.fi); maxi=min(maxi,gec.se+gec2.se+1); } i++; return make_pair(mini,maxi); } int32_t main(){ faster cin>>s; n=s.length(); pair<int,int>pq=f(); int cev; cev=pq.fi+pq.se; // cout<<top<<" "<<pq.fi<<" "<<pq.se<<endl; cout<<top-cev<<'\n'; 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...