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 <iostream>
// Find out best sample
using namespace std;
long long int ans,n,map[1005][1005],cost[1005],t[15],p=0;
int find(int x,long long int tmp)
{
ans=max(ans,tmp);
if(x==n)return 0;
find(x+1,tmp);
for(int i=1;i<=p;i++)
{
if(map[x][t[i]]==1)return 0;
}
p++;
t[p]=x;
find(x+1,tmp+cost[x]);
p--;
}
int findSample(int N,int confidence[],int host[],int protocol[]){
n=N;
for(int i=0;i<n;i++)cost[i]=confidence[i];
int cmp=0;
for(int i=1;i<n;i++)if(protocol[i]==1)cmp++;
for(int i=0;i<n;i++)ans+=cost[i];
if(cmp==n)return ans;
ans=0;
for(int i=1;i<n;i++)
{
int now=host[i];
if(protocol[i]==0 || protocol[i]==2)
{
map[now][i]=1;
map[i][now]=1;
}
if(protocol[i]==1 || protocol[i]==2)
{
for(int j=0;j<n;j++)
{
if(map[now][j]==1)
{
map[i][j]=1;
map[j][i]=1;
}
}
}
}
find(0,0);
return ans;
}
Compilation message (stderr)
friend.cpp: In function 'int find(int, long long int)':
friend.cpp:19:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# | 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... |