Submission #253364

#TimeUsernameProblemLanguageResultExecution timeMemory
253364eohomegrownappsFriend (IOI14_friend)C++14
27 / 100
37 ms1528 KiB
#include "friend.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; // Find out best sample int subtask1(int n,int confidence[],int host[],int protocol[]){ vector<vector<int>> adjlist(n); for (int i = 1; i<n; i++){ if (protocol[i]==0){ adjlist[host[i]].push_back(i); adjlist[i].push_back(host[i]); } else if (protocol[i]==1){ for (int x : adjlist[host[i]]){ adjlist[i].push_back(x); adjlist[x].push_back(i); } } else { for (int x : adjlist[host[i]]){ adjlist[i].push_back(x); adjlist[x].push_back(i); }; adjlist[host[i]].push_back(i); adjlist[i].push_back(host[i]); } } ll mx = 0; for (int i = 0; i<(1<<n); i++){ //check if ok bool works = true; ll tot = 0; for (int j = 0; j<n; j++){ if ((1<<j)&i){ tot+=confidence[j]; for (int k : adjlist[j]){ if ((1<<k)&i){ works=false; break; } } } if (works==false){ break; } } if (works==false){ continue; } mx=max(mx,tot); } return mx; } int subtask2(int n,int confidence[],int host[],int protocol[]){ int tot = 0; for (int i = 0; i<n; i++){ tot+=confidence[i]; } return tot; } int subtask3(int n,int confidence[],int host[],int protocol[]){ int mx = 0; for (int i = 0; i<n; i++){ mx=max(mx,confidence[i]); } return mx; } int subtask4(int n,int confidence[],int host[],int protocol[]){ return 0; } int subtask5(int n,int confidence[],int host[],int protocol[]){ return 0; } int subtask6(int n,int confidence[],int host[],int protocol[]){ return 0; } int findSample(int n,int confidence[],int host[],int protocol[]){ if (n<=10){ return subtask1(n,confidence,host,protocol); } else { bool protocols[3]={0,0,0}; for (int i = 1; i<n; i++){ protocols[protocol[i]]=true; } //cout<<protocols[0]<<' '<<protocols[1]<<' '<<protocols[2]<<'\n'; if (protocols[0]==0&&protocols[1]==1&&protocols[2]==0){ return subtask2(n,confidence,host,protocol); } else if (protocols[0]==0&&protocols[1]==0&&protocols[2]==1){ return subtask3(n,confidence,host,protocol); } else if (protocols[0]==1&&protocols[1]==0&&protocols[2]==0){ return subtask4(n,confidence,host,protocol); } else if (protocols[0]==1&&protocols[1]==1&&protocols[2]==0){ return subtask5(n,confidence,host,protocol); } else { return subtask6(n,confidence,host,protocol); } } return 0; }
#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...