# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
53373 | zetapi | Friend (IOI14_friend) | C++14 | 787 ms | 147456 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],maps[1009][1009];
void dfs(int node,int par,int hei)
{
mark[node]=1;
if(hei==0)
even+=arr[node];
else
odd+=arr[node];
for(auto A:vec[node])
{
if(A==par)
continue;
dfs(A,node,hei^1);
}
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++)
if(!mark[A])
{
odd=0;
even=0;
dfs(A,-1,0);
ans+=max(odd,even);
}
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... |