# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
582335 | kamelfanger83 | Friend (IOI14_friend) | C++14 | 1094 ms | 340 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 <iostream>
#include <vector>
#include "friend.h"
using namespace std;
int findSample(int n, int confidence[], int host[], int protocol[]){
if(n <= 10){
vector<vector<bool>> cons (n, vector<bool> (n, false));
for(int hoster = 1; hoster < n; hoster++){
if(protocol[hoster] == 0){
cons[hoster][host[hoster]] = true;
cons[host[hoster]][hoster] = true;
}
if(protocol[hoster] == 1){
for(int friender = 0; friender < n; friender++){
if(cons[host[hoster]][friender]) cons[friender][hoster] = cons[hoster][friender] = true;
}
}
else {
for(int friender = 0; friender < n; friender++){
if(cons[host[hoster]][friender]) cons[friender][hoster] = cons[hoster][friender] = true;
}
cons[hoster][host[hoster]] = true;
cons[host[hoster]][hoster] = true;
}
}
int best = 0;
for(int bitmask = 0; bitmask < (1 << n); bitmask++){
int summ = 0;
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
if(cons[i][j] && ((bitmask & (1 << i)) != 0) && ((bitmask & (1 << j)) != 0)) goto no;
}
}
for(int summer = 0; summer < n; summer++){
summ += confidence[summer] * ((bitmask & (1 << summer)) != 0);
}
best = max(best, summ);
no:
;
}
return best;
}
}
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... |