제출 #809033

#제출 시각아이디문제언어결과실행 시간메모리
809033Kerim친구 (IOI14_friend)C++17
11 / 100
24 ms3984 KiB
#include "friend.h" #include "bits/stdc++.h" #define pb(x) push_back(x) using namespace std; const int N = 1005; vector<int> adj[N]; void add_edge(int u, int v){ adj[u].pb(v); adj[v].pb(u); } int findSample(int n,int arr[],int host[],int protocol[]){ for (int i = 0; i < n; i++) adj[i].clear(); for (int i = 1; i < n; i++){ int v = host[i]; if (protocol[i] == 0){//IAmYourFriend add_edge(v, i); } else if(protocol[i] == 1){//MyFriendsAreYourFriends for (auto to: adj[v]) add_edge(to, i); } else{//WeAreYourFriends for (auto to: adj[v]) add_edge(to, i); add_edge(v, i); } } int answer = 0; if (n <= 10){ for (int mask = 0; mask < (1<<n); mask++){ bool bad = 0; int sum = 0; for (int i = 0; i < n; i++) if (mask>>i&1){ sum += arr[i]; for (auto to: adj[i]) bad |= (mask>>to&1); } if (!bad) answer = max(answer, sum); } } return answer; }
#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...