# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
908769 | dsyz | The Xana coup (BOI21_xanadu) | C++17 | 61 ms | 18544 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 MAXN (100005)
ll N;
vector<ll> v[MAXN];
ll dp[MAXN][2][2]; //index, press node x's button, final state of node x
bool initial[MAXN];
void dfs(ll x,ll p){
if(initial[x]){
dp[x][1][0] = 1;
dp[x][0][1] = 0;
}else{
dp[x][1][1] = 1;
dp[x][0][0] = 0;
}
for(auto u : v[x]){
if(u != p){
dfs(u,x);
ll a = dp[x][0][0], b = dp[x][0][1], c = dp[x][1][0], d = dp[x][1][1];
dp[x][0][0] = min(a + dp[u][0][0],b + dp[u][1][0]);
dp[x][0][1] = min(b + dp[u][0][0],a + dp[u][1][0]);
dp[x][1][0] = min(c + dp[u][0][1],d + dp[u][1][1]);
dp[x][1][1] = min(d + dp[u][0][1],c + dp[u][1][1]);
}
}
}
int main() {
ios_base::sync_with_stdio(false);cin.tie(0);
cin>>N;
# | 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... |