이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |