이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
void dfs(ll u, ll lev, ll &even, ll &odd){
if (lev%2) odd+=conf[u];
else even+=conf[u];
for (auto v:A[u]){
dfs(v, lev+1, even, odd);
}
}
int findSample(int n,int confidence[],int host[],int protocol[]){
A.clear(); A.resize(n);
conf.clear(); conf.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);
}
ll even=0, odd=0;
dfs(0, 0, even, odd);
return max(even, odd);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |