이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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){
mx+=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 findSample(int n,int confidence[],int host[],int protocol[]){
if (n<=10){
return subtask1(n,confidence,host,protocol);
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |