# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1017841 | n3rm1n | Friend (IOI14_friend) | C++17 | 1076 ms | 3420 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;
vector < int > g[1005];
int cnt[4];
long long ans = 0, dp[1005], sum[1005];
void dfs(int beg)
{
// cout << beg << " " << sum[beg] << endl;
dp[beg] = sum[beg];
int other = 0;
int nb;
for (int j = 0; j < g[beg].size(); ++ j)
{
nb = g[beg][j];
dfs(nb);
other += dp[nb];
}
dp[beg] = max(dp[beg], 1LL * other);
ans = max(dp[beg], ans);
// cout << "* " << beg << " " << dp[beg] << endl;
}
long long are[1005][1005], c[1005];
long long N, used[1005];
void check()
{
vector < int > g;
long long all = 0;
for (int i = 0; i < N; ++ i)
{
if(used[i])
{
g.push_back(i);
all += c[i];
}
}
for (int i = 0; i < g.size(); ++ i)
{
for (int j = i+1; j < g.size(); ++ j)
if(are[g[i]][g[j]])return;
}
ans = max(ans, all);
}
void gen(int pos)
{
if(pos == N)
{
check();
return;
}
used[pos] = 0;
gen(pos+1);
used[pos] = 1;
gen(pos+1);
}
int findSample(int n, int confidence[], int host[], int protocol[])
{
N = n;
if(n <= 10)
{
c[0] = confidence[0];
for (int i = 1; i < n; ++ i)
{
c[i] = confidence[i];
if(protocol[i] == 0)
{
are[i][host[i]] = 1;
are[host[i]][i] = 1;
}
else
{
for (int j = 0; j < n; ++ j)
{
if(are[j][host[i]])
{
are[i][j] = 1;
are[j][i] = 1;
}
}
if(protocol[i] == 2)
{
are[i][host[i]] = 1;
are[host[i]][i] = 1;
}
}
}
gen(0);
cout << ans << endl;
}
}
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... |