Submission #479372

#TimeUsernameProblemLanguageResultExecution timeMemory
479372lacitoFriend (IOI14_friend)C++14
0 / 100
1 ms332 KiB
#include "friend.h" #include <bits/stdc++.h> using namespace std; vector<vector<int>> g; vector<int> par; vector<bool> vis; bool dfs(int v){ vis[v] = true; for(int u : g[v]) if(par[u] == -1 && (!vis[par[u]] || dfs(par[u]))) { par[v] = u; par[u] = v; return true; } return false; } // Find out best sample int findSample(int n,int confidence[],int host[],int protocol[]){ vector<bool> color(n); g.resize(n); for (int i = 1; i < n; i++) { if (protocol[i] == 0) { color[i] = !color[host[i]]; g[i].push_back(host[i]); g[host[i]].push_back(i); } else { color[i] = color[host[i]]; for (int u : g[host[i]]) { g[i].push_back(u); g[u].push_back(i); } } } par.assign(n, -1); int ans = 0; for (int i = 0; i < n; i++) { if (color[i]) continue; vis.assign(n, false); if (dfs(i)) ans++; } return n - 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...