# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
587981 | dxz05 | Friend (IOI14_friend) | C++14 | 22 ms | 1364 KiB |
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 "bits/stdc++.h"
#include "friend.h"
using namespace std;
int findSample(int n, int val[], int host[], int type[]){
bool IAm = count(type, type + n, 0) > 0;
bool MyFriends = count(type, type + n, 1) > 0;
bool WeAre = count(type, type + n, 2) > 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 accumulate(val, val + n, 0);
}
Compilation message (stderr)
# | 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... |