Submission #988573

#TimeUsernameProblemLanguageResultExecution timeMemory
988573OtalpModern Machine (JOI23_ho_t5)C++14
15 / 100
3075 ms3164 KiB
#include<bits/stdc++.h> using namespace std; int a[200100], b[200100], c[200100]; void solve(){ int n, m; cin>>n>>m; for(int i=1; i<=n; i++){ char c; cin>>c; if(c == 'R') a[i] = 1; else a[i] = 0; b[i] = a[i]; } for(int i=1; i<=m; i++){ cin>>c[i]; } int t; cin>>t; while(t--){ int l, r; cin>>l>>r; for(int i=1; i<=n; i++){ a[i] = b[i]; } for(int j=l; j<=r; j++){ int d = c[j]; int c1=0, c2=0; for(int i=1; i<d; i++){ if(a[i] == 1) c1 ++; } for(int i = d + 1; i<=n; i++){ if(a[i] == 0) c2 ++; } if(c1 < c2){ for(int i=d + 1, k=0; k < c1 + 1; i++){ if(a[i] == 0) k ++; a[i] = 1; } for(int i=1; i<=d; i++) a[i] = 1; } else{ for(int i=d - 1, k=0; k<c2; i--){ if(a[i] == 1) k++; a[i] = 0; } for(int i=n; i>=d; i--) a[i] = 0; } } int ans = 0; for(int i=1; i<=n; i++){ ans += a[i]; } cout<<ans<<'\n'; } } int main(){ solve(); }
#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...