Submission #1009103

#TimeUsernameProblemLanguageResultExecution timeMemory
1009103phoenix친구 (IOI14_friend)C++17
35 / 100
1 ms456 KiB
#include "friend.h" #include <bits/stdc++.h> using namespace std; int findSample(int n, int confidence[], int host[], int protocol[]){ int pro_min = *min_element(protocol + 1, protocol + n); int pro_max = *max_element(protocol + 1, protocol + n); if (pro_min == 2 && pro_max == 2) { return *max_element(confidence, confidence + n); } if (pro_min == 1 && pro_max == 1) { bool color[n] = {}; color[0] = false; for (int i = 1; i < n; i++) color[i] = color[host[i]]; int ans[2] = {}; for (int i = 0; i < n; i++) ans[color[i]] += confidence[i]; return max(ans[0], ans[1]); } if (pro_min == 0 && pro_max == 0) { vector<vector<int>> g(n); for (int i = 1; i < n; i++) { g[host[i]].push_back(i); } int dp[n][2] = {}; function<void(int)> dfs = [&](int s) { dp[s][0] = 0; dp[s][1] = confidence[s]; for (int to : g[s]) { dfs(to); dp[s][0] += max(dp[to][0], dp[to][1]); dp[s][1] += dp[to][0]; } }; dfs(0); return max(dp[0][0], dp[0][1]); } return 0; }
#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...