제출 #1064763

#제출 시각아이디문제언어결과실행 시간메모리
1064763Gray친구 (IOI14_friend)C++17
19 / 100
1 ms600 KiB
#include "friend.h" #include<bits/stdc++.h> #define ll long long #define ff first #define ss second #define ln "\n" #define ld long double using namespace std; vector<vector<int>> A; vector<int> conf; vector<pair<int, int>> dp; void dfs(ll u){ dp[u].ff+=conf[u]; for (auto v:A[u]){ dfs(v); dp[u].ff+=dp[v].ss; dp[u].ss+=max(dp[v].ss, dp[v].ff); } } int findSample(int n,int confidence[],int host[],int protocol[]){ A.clear(); A.resize(n); conf.clear(); conf.resize(n); dp.clear(); dp.resize(n); for (int i=0; i<n; i++) conf[i]=confidence[i]; for (int i=1; i<n; i++){ A[host[i]].push_back(i); } dfs(0); return max(dp[0].ff, dp[0].ss); }
#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...