Submission #297923

#TimeUsernameProblemLanguageResultExecution timeMemory
297923PlurmFriend (IOI14_friend)C++11
8 / 100
5 ms5120 KiB
#include "friend.h" #include <bits/stdc++.h> using namespace std; vector<int> g[100005]; vector<int> sg[100005]; int rn[100005]; int dp[100005][2]; // dp[u][including u?] void dfs(int u, int* confidence, int p = -1){ for(int v : g[u]){ dfs(v, confidence, u); } for(int v : sg[u]){ dfs(v, confidence, u); } // compute dp[u][0] for(int v : g[u]){ dp[u][0] += max(dp[v][0], dp[v][1]); } // compute dp[u][1] dp[u][1] = confidence[u]; for(int v : sg[u]){ dp[u][1] += dp[v][1]; } } // Find out best sample int findSample(int n,int confidence[],int host[],int protocol[]){ for(int i = 1; i < n; i++){ switch(protocol[i]){ case 0: g[rn[host[i]]].push_back(i); break; case 1: sg[rn[host[i]]].push_back(i); break; case 2: rn[i] = host[i]; confidence[host[i]] = max(confidence[host[i]], confidence[i]); break; } } dfs(0, confidence); return max(dp[0][0], dp[0][1]); }
#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...