이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "friend.h"
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i <= (b); i++)
#define repa(i,a,b) for (int i = (a); i >= (b); i--)
#define lli long long int
#define debugsl(a) cout << #a << " = " << a << ", "
#define debug(a) cout << #a << " = " << a << endl
lli dp[1002][2];
vector<lli> hijos[1002];
lli conf[1002];
void DFS(lli pos, lli padre) {
for (auto h : hijos[pos]) {
if (h == padre) continue;
DFS(h,pos);
dp[pos][1] += dp[h][0];
dp[pos][0] += max(dp[h][0], dp[h][1]);
}
}
int findSample(int n,int confidence[],int host[],int protocol[]){
rep(i,1,n-1) {
hijos[i].push_back(host[i]);
hijos[host[i]].push_back(i);
}
rep(i,0,n-1) conf[i] = confidence[i];
DFS(0,0);
lli a = max(dp[0][0],dp[0][1]);
return a;
}
# | 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... |