# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
404189 | ly20 | Friend (IOI14_friend) | C++17 | 31 ms | 3972 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 = 15;
vector <int> grafo[MAXN];
int val[MAXN];
int tb[MAXN][MAXN];
int findSample(int n,int confidence[],int host[],int protocol[]){
for(int i = 0; i < n; i++) {
val[i] = confidence[i];
}
for(int i = 1; i < n; i++) {
int cur = host[i];
if(protocol[i] == 1 || protocol[i] == 2) {
for(int j = 0; j < grafo[cur].size(); j++) {
int viz = grafo[cur][j];
grafo[viz].push_back(i);
grafo[i].push_back(viz);
}
}
if(protocol[i] == 0 || protocol[i] == 2) {
grafo[i].push_back(cur);
grafo[cur].push_back(i);
}
}
for(int i = 0; i < n; i++) {
for(int j = 0; j < grafo[i].size(); j++) {
int viz = grafo[i][j];
tb[i][viz] = 1; tb[viz][i] = 1;
}
}
int resp = 0;
for(int i = 0; i < (1 << n); i++) {
int at = 0;
vector <int> temp;
for(int j = 0; j < n; j++) {
if((1 << j) & i) {
at += val[j];
temp.push_back(j);
}
}
bool vl = true;
for(int j = 0; j < temp.size(); j++) {
for(int k = j + 1; k < temp.size(); k++) {
if(tb[temp[j]][temp[k]] == 1) vl = false;
}
}
if(vl && at > resp) resp = at;
}
return resp;
}
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... |