This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "friend.h"
#include <vector>
#include <iostream>
#define MAXN 1005
using namespace std;
// Find out best sample
vector <int> adj[MAXN];
int wt[MAXN], dp[MAXN][2];
int findSample(int n,int C[],int H[],int P[]){ //confidence, host, protocol
bool SB1=n <= 12, SB2=true, SB3=true, SB4=true, SB5=true;
for (int i=1; i<n; i++) {
if (P[i] != 1) {SB2=false;} //myfriends
if (P[i] != 2) {SB3 = false;} //ourfriends
if (P[i] != 0) {SB4 = false;} //Ifriends
if (P[i] == 2) {SB5 = false;}
}
for (int i=1; i<n; i++) {
if (P[i] == 0) { //I am friend
adj[i].push_back(H[i]);
adj[H[i]].push_back(i);
//printf("%d %d\n",i,H[i]);
} else if (P[i] == 1) { //My friends
for (int v: adj[H[i]]) {
adj[i].push_back(v);
adj[v].push_back(i);
//printf("%d %d\n",v,i);
}
} else { //everything
//printf("%d %d\n",i,H[i]);
for (int v: adj[H[i]]) {
adj[i].push_back(v);
adj[v].push_back(i);
//printf("%d %d\n",v,i);
}
adj[i].push_back(H[i]);
adj[H[i]].push_back(i);
}
}
if (SB1) {
int ans = 0;
for (int i=0; i<(1<<n); i++) {
bool ok = true;
for (int a=0; a<n; a++) {
for (int b: adj[a]) {
if ((i&(1<<a)) && (i&(1<<b))) {
ok = false;
}
}
}
if (ok) {
int res = 0;
for (int j=0; j<n; j++) {
if (i&(1<<j)) {res += C[j];}
}
ans = max(ans, res);
}
}
return(ans);
} else if (SB3) { //no edges with myfriends
int mx = 0;
for (int i=0; i<n; i++) {
mx = max(mx, C[i]);
}
return(mx);
} else if (SB2) { //everything connected
int Sum = 0;
for (int i=0; i<n; i++) {
Sum += C[i];
}
return(Sum);
} else if (SB4) {
} else if (SB5) {
}
}
Compilation message (stderr)
friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:76:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# | 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... |