# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
313494 | kylych03 | Friend (IOI14_friend) | C++14 | 251 ms | 65540 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>
//#include "grader.cpp"
using namespace std;
// Find out best sample
bool f[3];
vector <int> g[100001];
int findSample(int n,int confidence[],int host[],int protocol[]){
int sum=0, mx=0;
f[0]=f[1]=f[2]=false;
for(int i = 1 ; i < n;i++){
f[protocol[i]]=true;
}
for(int i =0; i < n; i++){
sum +=confidence[i];
mx = max(mx, confidence[i] );
}
if( f[0]==false && f[2]==false )
return sum;
if( f[0]==false && f[1]==false )
return mx;
for(int i = 1 ; i <n ;i++){
if(protocol[i]==0){
g[host[i]].push_back(i);
g[i].push_back(host[i]);
}
if(protocol[i]==1){
for(auto j : g[host[i]]){
g[i].push_back(j);
g[j].push_back(i);
}
}
if(protocol[i]==2){
for(auto j : g[host[i]]){
g[i].push_back(j);
g[j].push_back(i);
}
g[host[i]].push_back(i);
g[i].push_back(host[i]);
}
}
if(n<=10){
for(int j = 0 ; j< (1<<n) ;j++){
bool res=true;
sum = 0;
for(int k = 0; k < n ;k++){
if(j & (1<<k)){
sum+=confidence[k];
for(int t = k+1 ; t < n; t++){
if(j &(1 << t)){
for(int s:g[k])
if(s==t){
res=false;
break;
}
}
}
}
}
if(res)
mx = max (mx, sum);
}
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... |