# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
471238 | disastah | Election (BOI18_election) | C++17 | 971 ms | 39436 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 ar array
using namespace std;
typedef long double ld;
typedef long long ll;
const int inf=2e9+9;
const ll linf=4e18+18;
const int N=5e5;
struct segtr {
struct node {
int ans, ansup, ansdown;
};
string s;
vector<int> a, b;
vector<node> t;
int n;
segtr(string &s, int n): s(s), n(n) {
a.resize(n+1); a[0]=0;
b.resize(n+1); b[n]=0;
for (int i=0; i<n; ++i) a[i+1]=a[i]+(s[i]=='C'?1:-1);
for (int i=n-1; ~i; --i) b[i]=b[i+1]+(s[i]=='C'?1:-1);
t.resize(n*4);
}
void comb(int v, int l, int r) {
int m=(l+r)/2;
t[v].ans=t[2*v+1].ansup+t[2*v+2].ansdown;
int x1=max(0,t[2*v+1].ans-t[2*v+1].ansup-t[2*v+2].ansdown-(b[m]-b[r]));
int x2=max(0,t[2*v+2].ans-t[2*v+2].ansdown-t[2*v+1].ansup-(a[m]-a[l]));
t[v].ans+=max(x1,x2);
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |