# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
446020 | apostoldaniel854 | The Xana coup (BOI21_xanadu) | C++14 | 78 ms | 23156 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 ll = long long;
#define dbg(x) cerr << #x << " " << x << "\n"
const int MAX_N = 1e5;
vector <int> gr[1 + MAX_N];
ll dp[1 + MAX_N][2][2];
int on[1 + MAX_N];
/// dp[node][switched 0/1][value given 0/1] =
void calc_dp (int node, int par) {
ll offset1 = 1, offset2 = 0;
ll flip_offset1 = (1 << 30), flip_offset2 = (1 << 30);
bool state1 = not on[node], state2 = on[node];
for (int son : gr[node]) {
if (son != par) {
calc_dp (son, node);
/// we switch node
if (dp[son][0][1] < dp[son][1][1]) {
offset1 += dp[son][0][1];
flip_offset1 = min (flip_offset1, dp[son][1][1] - dp[son][0][1]);
}
else {
offset1 += dp[son][1][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... |