이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "friend.h"
#include <bits/stdc++.h>
using namespace std;
namespace sub1{
bool adj[30][30];
bool check(int n,int confidence[],int host[],int protocol[]){
return n<=20;
}
int solve(int n,int confidence[],int host[],int protocol[]){
for (int i=1; i<n; ++i){
if (protocol[i]==0){
adj[i][host[i]]=1;
adj[host[i]][i]=1;
}else if (protocol[i]==1){
for (int j=0; j<i; ++j) if (adj[host[i]][j]){
adj[i][j]=1;
adj[j][i]=1;
}
}else{
for (int j=0; j<i; ++j) if (adj[host[i]][j] || j==host[i]){
adj[i][j]=1;
adj[j][i]=1;
}
}
}
int ans=0;
for (int i=0; i<(1<<n); ++i){
int cur=0;
bool check=1;
for (int j=0; j<n; ++j) if (i>>j&1){
cur+=confidence[j];
for (int k=j+1; k<n; ++k) if (i>>k&1){
check&=!adj[j][k];
}
}
if (check) ans=max(ans, cur);
}
return ans;
}
}
namespace sub2{
bool check(int n,int confidence[],int host[],int protocol[]){
return *min_element(protocol+1, protocol+n)==1 && *max_element(protocol+1, protocol+n)==1;
}
int solve(int n,int confidence[],int host[],int protocol[]){
return accumulate(confidence, confidence+n, 0);
}
}
// Find out best sample
int findSample(int n,int confidence[],int host[],int protocol[]){
if (sub2::check(n, confidence, host, protocol)) return sub2::solve(n, confidence, host, protocol);
if (sub1::check(n, confidence, host, protocol)) return sub1::solve(n, confidence, host, protocol);
return -1;
}
| # | 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... |