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 <bits/stdc++.h>
#include "friend.h"
using namespace std;
// vector<vector<int>> friendGraph;
// vector<int> value;
// vector<int> visited;
// int dfs(int v) {
// if (visited[v]) return 0;
// visited[v] = 1;
// int res = value[v];
// for (int i: friendGraph[v]) {
// res = max(res, dfs(i));
// }
// return res;
// }
// Find out best sample
int findSample(int n,int confidence[],int host[],int protocol[]){
// friendGraph.clear();
// // friendGraph.clear();
// friendGraph.resize(n);
// // friendGraph.resize(n);
// visited.assign(n, 0);
// value.assign(n, 0);
// for (int i = 0; i<n; i++) {
// value[i] = confidence[i];
// }
// vector<set<int>> friends(n);
// for (int i = 0; i<n; i++) {
// int v = host[i];
// int type = protocol[i];
// // int value = confidence[i];
// if (type == 0) {
// for (int j = 0; j<i; j++) {
// if (j == v) {
// friends[i].insert(j);
// friends[j].insert(i);
// friendGraph[j].push_back(i);
// friendGraph[i].push_back(j);
// continue;
// }
// }
// }
// if (type == 1) {
// for (int j = 0; j<i; j++) {
// if (friends[v].count(j)) {
// friends[i].insert(j);
// friends[j].insert(i);
// friendGraph[j].push_back(i);
// friendGraph[i].push_back(j);
// continue;
// }
// }
// }
// if (type == 2) {
// for (int j = 0; j<i; j++) {
// if (friends[v].count(j) || j == v) {
// friends[i].insert(j);
// friends[j].insert(i);
// friendGraph[j].push_back(i);
// friendGraph[i].push_back(j);
// continue;
// }
// }
// }
// }
// int res = 0;
// for (int i = 0; i<n; i++) {
// res += dfs(i);
// }
int res = 0;
if (protocol[0] == 1) {
for (int i = 0; i<n; i++) {
res += confidence[i];
}
}
if (protocol[0] == 2) {
for (int i = 0; i<n; i++) {
res = max(res, confidence[i]);
}
}
return res;
}
# | 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... |