Submission #1064603

#TimeUsernameProblemLanguageResultExecution timeMemory
1064603NemanjaSo2005Friend (IOI14_friend)C++17
11 / 100
1099 ms65536 KiB
#include "friend.h" #include<bits/stdc++.h> #define ll long long using namespace std; const int maxn=1e5+5; int N,niz[maxn]; ll res=0; vector<int> graf[maxn]; void grana(int a,int b){ graf[a].push_back(b); graf[b].push_back(a); } bool uzeo[15]; void provera(){ for(int i=1;i<=N;i++){ if(!uzeo[i]) continue; for(int x:graf[i]) if(uzeo[x]) return; } ll skor=0; for(int i=1;i<=N;i++) if(uzeo[i]) skor+=niz[i]; res=max(res,skor); } void rek(int gde){ if(gde==N+1){ provera(); return; } uzeo[gde]=false; rek(gde+1); uzeo[gde]=true; rek(gde+1); return; } int findSample(int n,int confidence[],int host[],int protocol[]){ N=n; for(int i=1;i<=N;i++) niz[i]=confidence[i-1]; for(int i=1;i<N;i++){ int x=host[i]+1; int p=protocol[i]; if(p==1 or p==2){ for(int aa:graf[x]) grana(aa,i+1); } if(p==0 or p==2) grana(x,i+1); } rek(1); return res; }
#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...