This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//Challenge: Accepted
#include <bits/stdc++.h>
using namespace std;
#ifdef zisk
void debug(){cout << endl;}
template<class T, class ... U> void debug(T a, U ... b){cout << a << " ", debug(b...);}
template<class T> void pary(T l, T r){
while (l != r)cout << *l << " ", l++;
cout << endl;
}
#else
#define debug(...) 0
#define pary(...) 0
#endif
#define ll long long
#define maxn 1005
#define pii pair<int, int>
#define ff first
#define ss second
#include "friend.h"
// Find out best sample
vector<int> adj[maxn];
int dp[maxn][2], wei[maxn];
/*
bool vis[maxn];
void dfs(int n, int par) {
vis[n] = 1;
for (int v:adj[n]) {
if (!vis[v]) {
dfs(v, n);
dp[n][0] += max(dp[v][1], dp[v][0]);
dp[n][1] += dp[v][0];
}
}
dp[n][1] += wei[n];
}
*/
int findSample(int n,int C[],int h[],int type[]){
for (int i = 0;i < n;i++) wei[i] = C[i];
for (int i = 1;i < n;i++) {
if (type[i] == 1 || type[i] == 2){
for (int j:adj[h[i]]) {
adj[i].push_back(j);
adj[j].push_back(i);
}
}
if (type[i] == 0 || type[i] == 2) {
adj[h[i]].push_back(i);
adj[i].push_back(h[i]);
}
}
int ans = 0;
for (int i = 0;i < (1<<n);i++) {
vector<bool> p(n, 0);
int tot = 0;
for (int j = 0;j < n;j++) {
if ((i>>j)&1) p[j] = 1, tot += wei[j];
}
bool good = 1;
for (int x = 0;x < n;x++) {
for (int y:adj[x]) {
if (p[x] && p[y]) {
good = 0;
break;
}
}
}
if (good) ans = max(ans, tot);
}
return ans;
}
# | 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... |