Submission #471446

#TimeUsernameProblemLanguageResultExecution timeMemory
471446KarukElection (BOI18_election)C++17
28 / 100
3075 ms1104 KiB
#include<bits/stdc++.h> using namespace std; int main() { int n,q; cin>>n; string s; cin>>s; s="$"+s; cin>>q; for(int i=0;i<q;i++) { int x,y; cin>>x>>y; int sum=0; int counter=0; for(int j=x;j<=y;j++) { if(sum==0 && s[j]=='T'){counter++;s[j]='F';} else if(s[j]=='T')sum--; else sum++; } sum=0; for(int j=y;j>=x;j--) { if(sum==0 && s[j]=='T'){counter++;s[j]='F';} else if(s[j]=='T')sum--; else if(s[j]=='C')sum++; } for(int j=x;j<=y;j++) { if(s[j]=='F')s[j]='T'; } cout<<counter<<endl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...