Submission #874115

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
8741152023-11-16 09:24:01siewjhFriend (IOI14_friend)C++17
16 / 100
2 ms4456 KiB
#include "friend.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
vector<int> adj[MAXN];
int dp[MAXN][2], conf[MAXN];
int dfs(int x, bool take){
if (dp[x][take] != -1) return dp[x][take];
int ans = 0;
if (take){
ans = conf[x];
for (int nxt : adj[x]) ans += dfs(nxt, 0);
}
else{
for (int nxt : adj[x]) ans += max(dfs(nxt, 1), dfs(nxt, 0));
}
return dp[x][take] = ans;
}
// Find out best sample
int findSample(int n, int confidence[], int host[], int protocol[]){
if (protocol[1] == 0){
for (int i = 1; i < n; i++) adj[host[i]].push_back(i);
for (int i = 0; i < n; i++) conf[i] = confidence[i];
return max(dfs(0, 0), dfs(0, 1));
}
else if (protocol[1] == 1){
int ans = 0;
for (int i = 0; i < n; i++) ans += confidence[i];
return ans;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
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...
#Verdict Execution timeMemoryGrader output
Fetching results...