Submission #129340

#TimeUsernameProblemLanguageResultExecution timeMemory
129340antimirageFriend (IOI14_friend)C++14
16 / 100
2 ms504 KiB
#include "friend.h" //#include "grader.cpp" #include <bits/stdc++.h> #define fr first #define sc second #define mk make_pair #define pb push_back #define all(s) s.begin(), s.end() using namespace std; const int N = 1005; vector <int> g[N]; int a[N], cn; void dfs (int v, int color, int &sum, int p = -1) { if (color) sum += a[v]; cn++; for (auto to : g[v]) { if (to == p) continue; dfs(to, color ^ 1, sum, v); } } int findSample(int n, int val[], int batya[], int type[]) { int ans = 0, res = 0; if (type[1] == 1) { for (int i = 0; i < n; i++) { ans += val[i]; } } else if (type[1] == 2) { for (int i = 0; i < n; i++) { ans = max(ans, val[i]); } } else { a[0] = val[0]; for (int i = 1; i < n; i++) { assert(batya[i] < i); g[batya[i]].pb(i); g[i].pb(batya[i]); a[i] = val[i]; } dfs(0, 0, ans); assert(cn == n); dfs(0, 1, res); ans = max(ans, res); } return ans; }
#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...