Submission #500750

#TimeUsernameProblemLanguageResultExecution timeMemory
500750InternetPerson10Friend (IOI14_friend)C++17
27 / 100
24 ms1488 KiB
#include "friend.h" #include <bits/stdc++.h> using namespace std; vector<vector<int>> adj; int findSample(int n, int confidence[], int host[], int protocol[]){ int mip = 4, map = 0; for(int i = 1; i < n; i++) { mip = min(mip, protocol[i]); map = max(map, protocol[i]); } if(n <= 10) { // Subtask 1 adj.resize(n); for(int i = 1; i < n; i++) { int x, y; if(protocol[i] == 0) { tie(x, y) = {i, host[i]}; adj[x].push_back(y); adj[y].push_back(x); } if(protocol[i] == 1) { for(int g : adj[host[i]]) { adj[i].push_back(g); adj[g].push_back(i); } } if(protocol[i] == 2) { for(int g : adj[host[i]]) { adj[i].push_back(g); adj[g].push_back(i); } tie(x, y) = {i, host[i]}; adj[x].push_back(y); adj[y].push_back(x); } } int best = 0; for(int i = 0; i < (1 << n); i++) { vector<int> goods; for(int j = 0; j < n; j++) { if(i & (1 << j)) goods.push_back(j); } bool ok = true; for(int g : goods) { for(int h : goods) { if(g == h) continue; for(int k : adj[g]) { if(k == h) ok = false; } } } if(!ok) continue; int ans = 0; for(int g : goods) { ans += confidence[g]; } best = max(best, ans); vector<int>().swap(goods); } return best; } else if(mip == map && mip == 1) { // Subtask 2 int ans = 0; for(int i = 0; i < n; i++) ans += confidence[i]; return ans; } else if(mip == map && mip == 2) { // Subtask 3 sort(confidence, confidence+n); return confidence[n-1]; } else if(mip == map) { // Subtask 4 // It is a tree } else if(map - mip == 1) { // Subtask 5 } // Subtask 6 return -1; }
#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...