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>
#include "friend.h"
using namespace std;
#define vt vector
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,x) for(int (i) = 0; (i) < (x); (i)++ )
typedef long long ll;
typedef long double ld;
typedef vt<int> vi;
typedef pair<int,int> pii;
set<int> adjlist[1002];
int ass[1002];
bool visited[1002];
void dfs(int node){
visited[node] = true;
for(auto& e: adjlist[node]){
if(!visited[e]){
ass[e] = ass[node]^1;
dfs(e);
}
}
}
int findSample(int n, int confidence[], int host[], int protocol[]){
for(int i = 1; i < n; i++){
if(protocol[i]==0){
adjlist[i].insert(host[i]);
adjlist[host[i]].insert(i);
}else if(protocol[i]==1){
for(int j = 0; j < i; j++){
if(adjlist[host[i]].find(j)!=adjlist[host[i]].end()){
adjlist[i].insert(j);
adjlist[j].insert(i);
}
}
}
}
int ans = 0;
set<int> st;
for(int i = 0; i < n; i++){
if(!visited[i]){
int ans1 = 0, ans2 = 0;
ass[i] = 0;
dfs(i);
for(int j = 0; j < n; j++){
if(visited[j]&&st.find(j)==st.end()){
st.insert(j);
if(ass[j]==1)ans1++;
else ans2++;
}
}
ans+=max(ans1,ans2);
}
}
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... |