제출 #1065365

#제출 시각아이디문제언어결과실행 시간메모리
1065365Mr_Husanboy친구 (IOI14_friend)C++17
23 / 100
2 ms604 KiB
#include "friend.h" #include<vector> #include <algorithm> #include <iostream> #include "assert.h" using namespace std; // Find out best sample vector<vector<int>> g; vector<int> vis, col, mt; void paint(int i, int c){ col[i] = c; for(auto u : g[i]){ if(col[u]) {assert(col[u] == -c); continue;} paint(u, -c); } } bool kuhn(int i){ assert(col[i] == 1); if(vis[i]) return false; vis[i] = 1; for(auto u : g[i]){ if(mt[u] == -1 || kuhn(mt[u])){ mt[u] = i; return true; } } return false; } int findSample(int n,int confidence[],int host[],int protocol[]){ g.resize(n); col.resize(n); mt.assign(n, -1); for(int i = 1; i < n; i ++){ if(protocol[i] == 0){ g[host[i]].push_back(i); g[i].push_back(host[i]); } if(protocol[i] == 1){ for(auto u : g[host[i]]){ g[u].push_back(i); g[i].push_back(u); } } } for(int i = 0; i < n; i ++){ if(!col[i]) paint(i, 1); } // for(int i = 0; i < n; i ++){ // if(col[i] == -1) continue; // for(auto u : g[i]){ // if(mt[u] == -1){ // mt[u] = i; // break; // } // } // } for(int i = 0; i < n; i ++){ if(col[i] == -1) continue; vis.assign(n, 0); kuhn(i); } int ans = n; for(int i = 0; i < n; i ++){ if(mt[i] != -1) ans --; } 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...