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 ll long long
#define sz(x) (int)(x).size()
using namespace std;
set<int> edges[1000];
int findSample(int n, int confidence[], int host[], int protocol[])
{
int ans=0,cur;
for (int i=1;i<n;++i)
{
if (protocol[i]==0)
{
edges[host[i]].insert(i);
edges[i].insert(host[i]);
}
else if (protocol[i]==1)
for (int j : edges[host[i]])
{
edges[i].insert(j);
edges[j].insert(i);
}
else
{
for (int j : edges[host[i]])
{
edges[i].insert(j);
edges[j].insert(i);
}
edges[host[i]].insert(i);
edges[i].insert(host[i]);
}
}
bool ok;
for (int i=1;i<(1<<n);++i)
{
ok=1;cur=0;
for (int j=0;j<n;++j)
{
if ((1<<j)&i)
{
cur+=confidence[j];
for (int k=0;k<n;++k)
if ((1<<k)&i)
if (edges[j].find(k)!=edges[j].end())
ok=0;
}
}
if (ok)
ans=max(ans,cur);
}
return ans;
}
/**int main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
int n;
cin>>n;
int c[n];
for (int i=0;i<n;++i)
cin>>c[i];
int h[n];
for (int i=1;i<n;++i)
cin>>h[i];
int p[n];
for (int i=1;i<n;++i)
cin>>p[i];
cout<<findSample(n,c,h,p);
return 0;
}**/
# | 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... |