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>
#define F first
#define S second
using namespace std;
const int N = 1e5 + 10;
int n , ar[N] , col[N] , cnt , sum;
bool marked[N];
vector <pair<int , int>> adj[N];
void Dfs(int v)
{
cnt++;
sum += col[v];
marked[v] = true;
for(auto u : adj[v])
{
col[u.F] = (col[v] ^ u.S);
Dfs(u.F);
}
}
int findSample(int nn,int confidence[],int host[],int protocol[]){
n = nn;
for(int i = 0 ; i < n ; i++)
ar[i] = confidence[i];
for(int i = 1 ; i < n ; i++)
{
if(protocol[i] == 0)
{
adj[host[i]].push_back({i , 1});
marked[i] = true;
marked[host[i]] = true;
}
else if(marked[host[i]])
{
adj[host[i]].push_back({i , 0});
marked[i] = true;
}
}
for(int i = 0 ; i < n ; i++)
marked[i] = false;
int ans = 0;
for(int i = 0 ; i < n ; i++) if(!marked[i])
{
cnt = sum = 0;
Dfs(i);
ans += max(sum , cnt - sum);
}
return ans;
}
# | 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... |