# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1022824 | gyg | The Xana coup (BOI21_xanadu) | C++17 | 101 ms | 28452 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>
using namespace std;
using lint = long long;
const int MAX_N = 1e5 + 5;
const lint INF = 1e9;
int n;
array<vector<int>, MAX_N> adj;
array<bool, MAX_N> a;
array<vector<int>, MAX_N> children;
void dfs1(int u = 1, int par = -1) {
for (int v : adj[u])
if (v != par) children[u].push_back(v), dfs1(v, u);
}
array<array<array<lint, 2>, 2>, MAX_N> dp1;
void dfs2(int u = 1) {
for (int v : children[u]) dfs2(v);
for (bool state : {false, true}) {
for (bool toggle : {false, true}) {
vector<array<lint, 2>> dp2(children[u].size() + 5);
dp2[0][1] = INF;
for (int i = 1; i <= children[u].size(); i++) {
int v = children[u][i - 1];
for (bool parity : {false, true}) {
lint leave = dp1[v][a[v] ^ toggle][0] + dp2[i - 1][parity];
lint take = dp1[v][a[v] ^ toggle ^ 1][1] + 1 + dp2[i - 1][parity ^ 1];
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |