# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
887373 | hmm789 | Cats or Dogs (JOI18_catdog) | C++14 | 145 ms | 32880 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 "catdog.h"
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000
struct node {
int s, e, m, v[2][2];
node *l, *r;
node(int _s, int _e) {
s = _s, e = _e, m = (s+e)/2;
if(s != e) {
v[0][0] = v[1][1] = 0;
v[0][1] = v[1][0] = 1;
l = new node(s, m);
r = new node(m+1, e);
} else {
v[0][0] = v[1][1] = 0;
v[0][1] = v[1][0] = INF;
}
}
void update(int x, int a, int b) {
if(s == e) {
v[0][0] += a;
v[1][1] += b;
return;
} else if(x > m) r->update(x, a, b);
else l->update(x, a, b);
for(int i = 0; i < 2; i++) for(int j = 0; j < 2; j++) v[i][j] = INF;
for(int i = 0; i < 2; i++) for(int j = 0; j < 2; j++) for(int k = 0; k < 2; k++) for(int w = 0; w < 2; w++) {
v[i][j] = min(v[i][j], l->v[i][k]+(k^w)+r->v[w][j]);
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |