# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1024304 | vjudge1 | Friend (IOI14_friend) | C++17 | 17 ms | 2804 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;
vector<int>adj[1010];
void AE(int x,int y){
adj[x].push_back(y);
adj[y].push_back(x);
}
int bruteforce(int n,int confidence[],int host[],int protocol[]){
for(int i=1;i<n;i++){
if(protocol[i])
for(auto x:adj[host[i]])
AE(x,i);
if(protocol[i]%2==0)
AE(i,host[i]);
}
int ans=0;
for(int msk=1;msk<1<<n;msk++){
int conf=0;
for(int i=0;i<n;i++) if(msk&1<<i)
conf+=confidence[i];
for(int i=0;i<n;i++) if(msk&1<<i)
for(auto y:adj[i]) if(msk&1<<y)
conf=-1; ans=max(ans,conf);
}
return ans;
}
int findSample(int n,int confidence[],int host[],int protocol[]){
if(n<=10) return bruteforce(n,confidence,host,protocol);
int ans=0,ans2=0;
for(int i=0;i<n;i++)
ans+=confidence[i],ans2=max(ans2,confidence[i]);
return protocol[1]==1?ans:ans2;
}
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... |