# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
404152 | ly20 | Friend (IOI14_friend) | C++17 | 65 ms | 25384 KiB |
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;
const int MAXN = 1123;
int marc[MAXN];
int val[MAXN];
vector <int> grafo[MAXN];
// Find out best sample
int br, pt;
void dfs(int v) {
if(marc[v] == 0) br += val[v];
else pt += val[v];
for(int i = 0; i < grafo[v].size(); i++) {
int viz = grafo[v][i];
if(marc[viz] != -1) {
continue;
}
marc[viz] = 1 - marc[v];
dfs(viz);
}
}
int findSample(int n,int confidence[],int host[],int protocol[]){
int tot = 0;
int mx = 0;
for(int i = 0; i < n; i++) {
marc[i] = -1;
val[i] = confidence[i];
mx = max(mx, val[i]);
}
for(int i = 1; i < n - 1; i++) {
int cur = host[i];
if(protocol[i] == 0 || protocol[i] == 2) {
grafo[i].push_back(cur);
grafo[cur].push_back(i);
}
if(protocol[i] == 1 || protocol[i] == 2) {
for(int j = 0; j < grafo[cur].size(); j++) {
int viz = grafo[cur][j];
grafo[i].push_back(viz);
grafo[viz].push_back(i);
}
}
}
int resp = 0;
for(int i = 0; i < n; i++) {
if(marc[i] == -1) {
br = 0; pt = 0;
marc[i] = 0;
dfs(i);
resp += max(br, pt);
tot += br + pt;
}
}
return mx;
}
Compilation message (stderr)
# | 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... |