Submission #1089810

#TimeUsernameProblemLanguageResultExecution timeMemory
1089810lucriElection (BOI18_election)C++17
28 / 100
3063 ms1092 KiB
#include <bits/stdc++.h> using namespace std; char a[500010]; bool e[500010]; int n,q,x,y; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin>>n>>a+1>>q; while(q--) { cin>>x>>y; int sum=0; for(int i=x;i<=y;++i) { if(a[i]=='C') ++sum; else --sum; if(sum>=0) e[i]=true; else { e[i]=false; ++sum; } } sum=0; int ans=0; for(int i=y;i>=x;--i) { if(e[i]==false) { ++ans; continue; } if(a[i]=='C') ++sum; else --sum; if(sum>=0) e[i]=true; else { ++ans; e[i]=false; ++sum; } } cout<<ans<<'\n'; } return 0; }

Compilation message (stderr)

election.cpp: In function 'int main()':
election.cpp:11:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   11 |     cin>>n>>a+1>>q;
      |             ~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...