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<iostream>
#include<assert.h>
#include<vector>
using namespace std;
const int N = 1e4 + 123;
vector<int>g[N];
int c[N];
int used[N];
void dfs(int v, int &a, int &b) {
a += c[v];
used[v] = 1;
for (int to : g[v]) if (!used[to]) {
dfs(to, b, a);
}
}
int findSample(int n,int confidence[],int host[],int protocol[]){
for (int i = 0 ; i < n ; ++ i) {
c[i] = confidence[i];
}
for (int i = 1 ; i < n ; ++ i) {
int j = host[i];
g[j].emplace_back(i);
g[i].emplace_back(j);
}
int ans = 0;
for (int i = 0 ; i < n ; ++ i) {
if (used[i]) continue;
int a = 0, b = 0;
dfs(i, a, b);
ans += max(a, b);
}
return ans;
}
# | 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... |