제출 #701984

#제출 시각아이디문제언어결과실행 시간메모리
701984PCTprobability친구 (IOI14_friend)C++17
11 / 100
28 ms3960 KiB
#include <bits/stdc++.h> #include "friend.h" using namespace std; using ll = long long; int findSample(int n, int confidence[], int host[], int protocol[]){ assert(n<=10); vector<vector<int>> a(n,vector<int>(n)); for(int i=1;i<n;i++){ if(protocol[i]==0){ a[i][host[i]]=a[host[i]][i]=1; } if(protocol[i]==1){ for(int j=0;j<n;j++){ if(a[host[i]][j]){ a[i][j]=a[j][i]=1; } } } if(protocol[i]==2){ for(int j=0;j<n;j++){ if(a[host[i]][j]){ a[i][j]=a[j][i]=1; } } a[i][host[i]]=a[host[i]][i]=1; } } int ans=0; for(int i=0;i<(1<<n);i++){ int sum=0,ok=1; for(int j=0;j<n;j++){ if((i>>j)&1){ sum+=confidence[j]; for(int k=j+1;k<n;k++){ if((i>>k)&1){ if(a[j][k]) ok=0; } } } } ans=max(ans,sum*ok); } 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...