Submission #931529

#TimeUsernameProblemLanguageResultExecution timeMemory
931529pccModern Machine (JOI23_ho_t5)C++14
3 / 100
3063 ms1372 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...