Submission #171848

#TimeUsernameProblemLanguageResultExecution timeMemory
171848gs18103Friend (IOI14_friend)C++14
100 / 100
37 ms3576 KiB
#include "friend.h" #include <bits/stdc++.h> #define fi first #define se second #define eb emplace_back #define em emplace #define all(v) v.begin(), v.end() using namespace std; typedef long long ll; typedef pair <int, int> pii; typedef pair <ll, ll> pll; const int MAX = 101010; const int INF = INT_MAX >> 1; const ll LINF = LLONG_MAX >> 1; const ll mod = 1e9+9; pii arr[MAX]; int findSample(int n,int c[],int h[],int p[]){ for(int i = 0; i < n; i++) { arr[i].fi = c[i]; } for(int i = n - 1; i > 0; i--) { if(p[i] == 2) { arr[h[i]].fi = max(arr[h[i]].fi + arr[i].se, arr[h[i]].se + arr[i].fi); arr[h[i]].se = arr[h[i]].se + arr[i].se; } if(p[i] == 1) { arr[h[i]].fi = max({ arr[h[i]].fi + arr[i].se, arr[h[i]].se + arr[i].fi, arr[h[i]].fi + arr[i].fi }); arr[h[i]].se = arr[h[i]].se + arr[i].se; } if(p[i] == 0) { arr[h[i]].fi += arr[i].se; arr[h[i]].se += max(arr[i].se, arr[i].fi); } } return max(arr[0].fi, arr[0].se); }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...