Submission #892463

#TimeUsernameProblemLanguageResultExecution timeMemory
892463maxFedorchukElection (BOI18_election)C++14
28 / 100
3075 ms1448 KiB
#include <bits/stdc++.h> using namespace std; const long long MX=500002; string s; int n,q; int masnm[MX]; void zap(int l,int r,int nmzp) { int zrsum=0,kop=0; for(int i=l;i<=r;i++) { if(s[i]=='C') { zrsum++; } else { if(zrsum==0) { masnm[i]=nmzp; kop++; } else { zrsum--; } } } zrsum=0; for(int i=r;i>=l;i--) { if(s[i]=='C') { zrsum++; } else { if(masnm[i]!=nmzp) { if(zrsum==0) { kop++; } else { zrsum--; } } } } cout<<kop<<"\n"; return; } int main() { cin.tie(0); ios_base::sync_with_stdio(0); cin>>n>>s>>q; s="*"+s; for(int i=1;i<=q;i++) { int l,r; cin>>l>>r; zap(l,r,i); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...