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>
#define MAX 1005
std::vector<int> con[MAX];
// Find out best sample
int findSample(int n,int confidence[],int host[],int protocol[]){
for(int i=1;i!=n;++i){
if(protocol[i]==0){
int alfa = host[i];
con[alfa].push_back(i);
con[i].push_back(alfa);
}else {
for(auto&x:con[host[i]]){
con[i].push_back(x);
con[x].push_back(i);
}
}
}
bool foi[n]={};
int cor[n]={};
int ans=0;
for(int i=0;i!=n;++i){
if(foi[i])continue;
std::queue<int> queue;
queue.push(i);
foi[i]=true;
int alfa=0,beta=0;
while(queue.size()){
auto __ = queue.front();
queue.pop();
for(auto&x:con[__]){
if(foi[x])continue;
if(!cor[__])++alfa;else ++beta;
cor[x]=!cor[__];
queue.push(x);
foi[x]=true;
}
}
ans+=std::max(alfa,beta);
}
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... |