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;
typedef long long ll;
typedef pair<int, int> pll;
#define fastio ios::sync_with_stdio(false), cin.tie(0)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define f first
#define s second
const int INF = 1e9;
const int maxn = 2e5 + 5;
int main(void){
fastio;
int n, m;
cin>>n>>m;
vector<int> org(n), c(n);
string s;
cin>>s;
REP(i, n) {
org[i] = (s[i] == 'R');
}
vector<int> a(m);
REP(i, m) cin>>a[i], a[i] --;
auto play = [&](int pos) -> void{
c[pos] = 1;
while(pos >= 0 && pos < n){
c[pos] ^= 1;
if(c[pos]) pos--;
else pos++;
}
};
int q;
cin>>q;
while(q--){
int l, r;
cin>>l>>r;
l--, r--;
c = org;
for(int i = l; i <= r; i++) play(a[i]);
int cnt = 0;
REP(i, n) if(c[i]) cnt++;
cout<<cnt<<"\n";
}
}
# | 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... |