This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 pares, impares;
vector<lli> hijos[1002];
lli conf[1002];
void DFS(lli pos, lli padre, lli prof) {
if (prof%2 == 0) pares += conf[pos];
else impares += conf[pos];
for (auto h : hijos[pos]) {
if (h == padre) continue;
DFS(h,pos,prof+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];
pares = 0;
impares = 0;
DFS(0,0,0);
pares = max(pares,impares);
return pares;
}
# | 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... |