# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
870362 | Alora | Election (BOI18_election) | C++17 | 3063 ms | 1408 KiB |
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>
#define Alora "cownav"
#define fi(i,a,b) for(int i = a; i <= b; i++)
#define fid(i,a,b) for(int i = a; i >= b; i--)
#define ll long long
#define f first
#define se second
#define pii pair<int, int>
#define getbit(i, j) ((i >> j) & 1)
#define all(v) v.begin(), v.end()
#define pb push_back
#define maxn 300005
const int M = 1e9 + 7;
using namespace std;
int n, q, xd[maxn];
string s;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(NULL);
if(fopen(Alora".inp","r")){
freopen(Alora".inp","r",stdin);
freopen(Alora".out","w",stdout);}
cin >> n >> s; s = ' ' + s;
cin >> q;
while(q--){
int l, r; cin >> l >> r;
fi(i, 1, n) xd[i] = 0;
int c = 0, t = 0;
fi(i, l, r){
if(s[i] == 'C') c++;
else{
if(t < c) t++;
else xd[i] = 1;
}
}
c = t = 0;
fid(i, r, l){
if(s[i] == 'C') c++;
else if(xd[i] == 0){
if(t < c) t++;
else xd[i] = 1;
}
}
int ans = 0;
fi(i, 1, n) ans += xd[i];
cout << ans << '\n';
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |