This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int mxn = 2e5+10;
int N,M,Q,op[mxn];
string s;
void calc(int now){
s[now] = 'R';
while(now>=1&&now<=N){
if(s[now] == 'R'){
s[now] = 'B';
now++;
}
else{
s[now] = 'R';
now--;
}
}
return;
}
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>N>>M;
cin>>s;
for(int i = 1;i<=M;i++)cin>>op[i];
s = "#"+s;
string ss = s;
cin>>Q;
while(Q--){
int l,r;
cin>>l>>r;
s = ss;
for(int i = l;i<=r;i++)calc(op[i]);
int ans = 0;
for(int i = 1;i<=N;i++)if(s[i] == 'R')ans++;
cout<<ans<<'\n';
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |