# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
53390 | zetapi | Friend (IOI14_friend) | C++14 | 22 ms | 11124 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;
#define pb push_back
#define mp make_pair
#define ll long long
#define itr ::iterator
const int MAX=1e5;
vector<int> lol,vec[MAX];
int odd,even,arr[MAX],mark[MAX],dp[MAX][2],maps[1009][1009];
void dfs(int node,int par)
{
int f=0,s=0;
mark[node]=1;
for(auto A:vec[node])
{
if(A==par)
continue;
dfs(A,node);
f+=dp[A][0];
s+=dp[A][1];
}
dp[node][0]=max(f,arr[node]+s);
dp[node][1]=f;
return ;
}
int findSample(int n,int confidence[],int host[],int protocol[])
{
int ans=0,ok,N=n,cur;
for(int A=0;A<N;A++)
arr[A]=confidence[A];
for(int A=1;A<N;A++)
{
if(protocol[A]==0)
{
vec[host[A]].pb(A);
vec[A].pb(host[A]);
}
else if(protocol[A]==1)
{
for(auto B:vec[host[A]])
{
vec[B].pb(A);
vec[A].pb(B);
}
}
else
{
for(auto B:vec[host[A]])
{
vec[B].pb(A);
vec[A].pb(B);
}
vec[host[A]].pb(A);
vec[A].pb(host[A]);
}
}
for(int A=0;A<N;A++)
for(auto B:vec[A])
maps[A][B]=1;
for(int A=0;A<N;A++)
{
int cur=0;
for(int B=0;B<N;B++)
cur+=(maps[A][B]^1)*arr[B];
ans=max(ans,cur);
}
return ans;
}
/*int main()
{
ios_base::sync_with_stdio(false);
int n=
cout<<findSample()
return 0;
}*/
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... |