이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
#include "friend.h"
using namespace std;
int findSample(int n, int val[], int host[], int type[]){
bool IAm = count(type + 1, type + n, 0) > 0;
bool MyFriends = count(type + 1, type + n, 1) > 0;
bool WeAre = count(type + 1, type + n, 2) > 0;
if (MyFriends && !IAm && !WeAre){
return accumulate(val, val + n, 0);
}
if (n <= 10){
vector<vector<int>> g(n);
for (int i = 1; i < n; i++){
if (type[i] == 0){
g[i].push_back(host[i]);
g[host[i]].push_back(i);
}
if (type[i] == 1){
for (int j : g[host[i]]){
if (j == host[i]) continue;
g[i].push_back(j);
g[j].push_back(i);
}
}
if (type[i] == 2){
g[i].push_back(host[i]);
g[host[i]].push_back(i);
for (int j : g[host[i]]){
if (j == host[i]) continue;
g[i].push_back(j);
g[j].push_back(i);
}
}
}
vector<vector<int>> gg(n, vector<int>(n, 0));
// cout << "\nedges\n";
for (int i = 0; i < n; i++){
for (int j : g[i]) gg[i][j] = 1;
// for (int j : g[i]) cout << i << ' ' << j << endl;
}
// cout << "\nedges\n";
int ans = 0;
for (int mask = 0; mask < (1 << n); mask++){
vector<int> vec;
int cur = 0;
for (int i = 0; i < n; i++){
if (!(mask & (1 << i))) continue;
vec.push_back(i);
cur += val[i];
}
bool ok = true;
for (int i : vec){
for (int j : vec){
if (i != j && gg[i][j]) ok = false;
}
}
if (ok) ans = max(ans, cur);
}
return ans;
}
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... |