제출 #422535

#제출 시각아이디문제언어결과실행 시간메모리
422535Andyvanh1친구 (IOI14_friend)C++14
0 / 100
13 ms460 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...