# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
281717 | SamAnd | Friend (IOI14_friend) | C++17 | 1094 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>
using namespace std;
const int N = 100005;
int n;
vector<int> g[N];
int q1, q2;
bool c[N];
void dfs(int x, int gg)
{
c[x] = true;
if (gg == 1)
++q1;
else
++q2;
for (int i = 0; i < g[x].size(); ++i)
{
int h = g[x][i];
if (!c[h])
dfs(h, 3 - gg);
}
}
int findSample(int n, int confidence[], int host[], int protocol[])
{
::n = n;
for (int i = 1; i < n; ++i)
{
if (protocol[i] == 0)
{
g[host[i]].push_back(i);
g[i].push_back(host[i]);
}
else if (protocol[i] == 1)
{
for (int j = 0; j < g[host[i]].size(); ++j)
{
int h = g[host[i]][j];
g[h].push_back(i);
g[i].push_back(h);
}
}
else
{
for (int j = 0; j < g[host[i]].size(); ++j)
{
int h = g[host[i]][j];
g[h].push_back(i);
g[i].push_back(h);
}
g[host[i]].push_back(i);
g[i].push_back(host[i]);
}
}
for (int i = 0; i < n; ++i)
sort(g[i].begin(), g[i].end());
int ans = 0;
for (int x = 0; x < (1 << n); ++x)
{
int yans = 0;
bool z = true;
for (int i = 0; i < n; ++i)
{
if (!(x & (1 << i)))
continue;
yans += confidence[i];
for (int j = 0; j < n; ++j)
{
if (!(x & (1 << j)))
continue;
if (binary_search(g[i].begin(), g[i].end(), j))
{
z = false;
break;
}
}
if (!z)
break;
}
if (z)
ans = max(ans, yans);
}
return ans;
}
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... |