# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
53378 | zetapi | Friend (IOI14_friend) | C++14 | 6 ms | 3220 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[0]=max(arr[0],confidence[A]);
return arr[0];
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++)
if(!mark[A])
{
dfs(A,-1);
ans+=dp[A][0];
}
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... |