제출 #430404

#제출 시각아이디문제언어결과실행 시간메모리
430404frodakcin친구 (IOI14_friend)C++17
11 / 100
29 ms2548 KiB
#include "friend.h" #include <vector> template<typename T> bool ckmax(T& a, const T& b) {return b>a?a=b,1:0;} template<typename T> bool ckmin(T& a, const T& b) {return b<a?a=b,1:0;} // Find out best sample const int MN = 10; std::vector<int> a[MN]; void adde(int u, int v) {a[u].push_back(v), a[v].push_back(u);} int findSample(int n,int confidence[],int host[],int protocol[]) { if(n>10) return -1; for(int i=1;i<n;++i) { if(protocol[i] == 1 || protocol[i] == 2) for(int x:a[host[i]]) adde(x, i); if(protocol[i] == 0 || protocol[i] == 2) adde(host[i], i); } int ans=0; for(int i=1;i<(1<<n);++i) { bool ok=1; for(int j=0;ok&&j<n;++j) if(i>>j&1) for(int k:a[j]) if(i>>k&1) { ok=0; break; } int v=0; for(int j=0;j<n;++j) if(i>>j&1) v += confidence[j]; if(ok) ckmax(ans, v); } 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...