제출 #742211

#제출 시각아이디문제언어결과실행 시간메모리
742211MODDI친구 (IOI14_friend)C++14
19 / 100
2 ms468 KiB
#include "friend.h" #include <bits/stdc++.h> #define ll long long #define pii pair<int,int> #define pll pair<ll,ll> #define pb push_back #define mp make_pair #define vi vector<int> using namespace std; vi G[1101], add; // Find out best sample ll dp[1101][2]; void dfs(int at, int p){ dp[at][0] = add[at]; dp[at][1] = 0; vi children; for(auto next : G[at]){ if(next == p) continue; dfs(next, at); children.pb(next); } for(auto t :children){ dp[at][0] += dp[t][1]; dp[at][1] += max(dp[t][0], dp[t][1]); } } int findSample(int n,int confidence[],int host[],int protocol[]){ add.resize(n); for(int i = 0; i < n; i++) add[i] = confidence[i]; for(int i = 1; i < n; i++){ G[host[i]].pb(i); G[i].pb(host[i]); } dfs(0, 0); 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...