Submission #415114

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
4151142021-05-31 14:40:15achibasadzishviliThe Xana coup (BOI21_xanadu)C++17
0 / 100
75 ms19004 KiB
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
using namespace std;
ll n,c[100005];
vector<ll>v[100005];
ll dp[100005][2][2];
void solve(ll x,ll par){
ll keon = 1e9,luon = 0,keof = 1e9,luof = 0;
for(auto to : v[x]){
if(to == par)continue;
solve(to , x);
ll wk = keon,wl = luon;
keon = min(wk + dp[to][0][1] , wl + dp[to][1][1]);
luon = min(wl + dp[to][0][1] , wk + dp[to][1][1]);
wk = keof , wl = luof;
keof = min(wk + dp[to][0][0] , wl + dp[to][1][0]);
luof = min(wl + dp[to][0][0] , wk + dp[to][1][0]);
}
for(int i=0; i<2; i++)
for(int j=0; j<2; j++)
dp[x][i][j] = 1e9;
dp[x][0][1 ^ c[x]] = min(dp[x][0][1 ^ c[x]] , keof);
dp[x][0][c[x]] = min(dp[x][0][c[x]] , luof);
dp[x][1][c[x]] = min(dp[x][1][c[x]] , keon + 1);
dp[x][1][c[x] ^ 1] = min(dp[x][1][c[x]] , luon + 1);
/*cout << x << '\n';
for(int i=0; i<2; i++)
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...