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"
#include "friend.h"
using namespace std;
vector<set<int>> adj;
set<int> em;
vector<bool> denied;
int dfs(int u, int n, int c[])
{
int r = c[u];
int temp = c[u];
denied[u] = true;
for(auto v: adj[u])
denied[v] = true;
for(int i = 0; i<n; i++)
{
if(!denied[i])
{
int val = dfs(i, n, c);
r = max(r, temp + val);
}
}
return r;
}
int findSample(int n, int confidence[], int host[], int protocol[])
{
adj.assign(n, em);
for(int i = 1; i<n; i++)
{
if(protocol[i]==0)
{
int x = host[i];
adj[x].insert(i);
adj[i].insert(x);
}
else if(protocol[i]==1)
{
int x = host[i];
for(auto v: adj[x])
{
adj[v].insert(i);
adj[i].insert(v);
}
}
else
{
int x = host[i];
adj[x].insert(i);
adj[i].insert(x);
for(auto v: adj[x])
{
adj[v].insert(i);
adj[i].insert(v);
}
}
}
int res = 0;
for(int i = 0; i<n; i++)
{
denied.assign(n, false);
int maxi = dfs(i, n, confidence);
res = max(res, maxi);
}
return res;
}
# | 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... |