# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1017251 | n3rm1n | Friend (IOI14_friend) | C++17 | 0 ms | 348 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];
int 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], other);
ans = max(dp[beg], ans);
// cout << "* " << beg << " " << dp[beg] << endl;
}
int findSample(int n, int confidence[], int host[], int protocol[])
{
for (int i = 1; i < n; ++ i)
g[host[i]].push_back(i);
for (int i = 1; i < n; ++ i)
{
cnt[protocol[i]] ++;
}
// cout << cnt[1] << endl;
if(cnt[1] == n-1)
{
/// cout << "here " << endl;
for (int i = 0; i < n; ++ i)
{
sum[i] = confidence[i];
for (int j = 0; j < g[i].size(); ++ j)
sum[i] += confidence[g[i][j]];
}
dfs(0);
return ans;
}
// cout << "opa" << 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... |