# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1017291 | vivkostov | Friend (IOI14_friend) | C++14 | 0 ms | 0 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<bits/stdc++.h>
#define endl '\n'
#include "friend.h"
using namespace std;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
int n,a,b,br[15][15],mas[15],otg,con[15];
void check()
{
int seg=0;
for(int i=1;i<=n;i++)
{
if(!mas[i])continue;
for(int j=i+1;j<=n;j++)
{
if(!mas[j])continue;
if(br[i][j])return;
}
seg+=con[i];
}
otg=max(otg,seg);
}
void rec(int step)
{
if(step==n)
{
check();
return;
}
for(int i=0;i<=1;i++)
{
mas[step+1]=i;
rec(step+1);
mas[step+1]=0;
}
}
int findSample(int N, int confidence[], int host[], int protocol[])
{
n=N;
for(int i=1;i<=n;i++)
{
if(protocol[i]==0)
{
br[a][i]=1;
br[i][a]=1;
}
if(protocol[i]==1)
{
for(int i=1;i<=n;i++)
{
br[b][i]=br[a][i];
br[i][b]=br[i][a];
}
}
if(protocol[i]==2)
{
for(int i=1;i<=n;i++)
{
br[b][i]=br[a][i];
br[i][b]=br[i][a];
}
br[a][i]=1;
br[i][a]=1;
}
}
for(int i=1;i<=n;i++)
{
con[i]=confidence[i-1];
}
rec(0);
retunr otg;
}
int main()
{
speed();
read();
return 0;
}