# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1070510 | duckindog | The Xana coup (BOI21_xanadu) | C++17 | 40 ms | 17012 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;
const int N = 100'000 + 10;
int n;
vector<int> ad[N];
int a[N];
long long f[N][2][2], dp[2][2];
void dfs(int u, int p = -1) {
f[u][0][0] = f[u][0][1] = f[u][1][0] = f[u][1][1] = N;
f[u][a[u]][0] = 0;
f[u][a[u] ^ 1][1] = 1;
for (const auto& v : ad[u]) {
if (v == p) continue;
dfs(v, u);
for (int i = 0; i < 2; ++i) {
for (int j = 0; j < 2; ++j) dp[i][j] = f[u][i][j];
}
for (int a = 0; a < 2; ++a) {
for (int b = 0; b < 2; ++b) {
auto& ret = f[u][a][b];
ret = min(dp[a][b] + f[v][b][0], dp[a ^ 1][b] + f[v][b][1]);
}
}
}
}
# | 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... |