# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
974147 | nextgenxing | The Xana coup (BOI21_xanadu) | C++14 | 49 ms | 25948 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;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define ff first
#define ss second
#define all(x) begin(x), end(x)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define F0R(i, x) FOR(i, 0, x)
#define FORd(i, a, b) for(int i = (b)-1; i >= (a); i--)
#define F0Rd(i, x) FORd(i, 0, x)
#define ckif(a, b, c) ((c) ? (a) : (b))
const int MAX_N = 2e5+69;
const ll INF = 0x3f3f3f3f;
int n;
vector<int> adj[MAX_N];
int dp[MAX_N][2][2], a[MAX_N]; // what it is, whether it has toggled
void solve(int curr, int par = -1){
int dp2[2][2] = {0}; // what the it is, what all the children are
dp2[a[curr]^1][0] = INF, dp2[a[curr]^1][1] = INF;
for(auto x : adj[curr]){
if(x == par) continue;
solve(x, curr);
F0R(i1, 2) F0R(i2, 2) F0R(j1, 2) F0R(j2, 2) if(dp2[i1][i2] < INF && dp[x][j1][j2] < INF && i2 == j1)
dp[curr][i1^j2][i2] = min(dp[curr][i1^j2][i2], dp2[i1][i2]+dp[x][j1][j2]);
F0R(i, 2) F0R(j, 2) dp2[i][j] = dp[curr][i][j], dp[curr][i][j] = INF;
# | 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... |