제출 #874075

#제출 시각아이디문제언어결과실행 시간메모리
874075dzuizz친구 (IOI14_friend)C++14
27 / 100
23 ms7544 KiB
// Subtask 1 #include <bits/stdc++.h> using namespace std; int findSample(int n, int confidence[], int host[], int protocol[]) { bool subtask2 = 1, subtask3 = 1, subtask4 = 1; for (int i=1; i<n; i++) { if (protocol[i] != 1) subtask2 = 0; if (protocol[i] != 2) subtask3 = 0; if (protocol[i] != 0) subtask4 = 0; } if (subtask2) { int ans=0; for (int i=0; i<n; i++) ans += confidence[i]; return ans; } if (subtask3) { int ans=0; for (int i=0; i<n; i++) ans = max(ans, confidence[i]); return ans; } if (subtask4) { } vector<int> adjlist[n]; for (int i=1; i<n; i++) { if (protocol[i] != 1) { adjlist[host[i]].push_back(i); adjlist[i].push_back(host[i]); } if (protocol[i] != 0) { for (auto &nx : adjlist[host[i]]) { adjlist[i].push_back(nx); adjlist[nx].push_back(i); } } } int ans=0; for (int i=0; i<(1<<n); i++) { bool vis[n]; memset(vis, 0, sizeof(vis)); bool flag=1; int res=0; for (int j=0; j<n&&flag; j++) { int bit = (i>>j)&1; if (bit == 0) continue; res += confidence[j]; for (auto &nx : adjlist[j]) if (vis[nx]) flag = 0; vis[j] = 1; } if (flag) ans = max(ans, res); } 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...