Submission #581810

#TimeUsernameProblemLanguageResultExecution timeMemory
581810drdilyorFriend (IOI14_friend)C++17
0 / 100
1082 ms2720 KiB
#if defined(ONPC) && !defined(_GLIBCXX_ASSERTIONS)
    #define _GLIBCXX_ASSERTIONS
#endif
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#ifdef ONPC
    #include "t_debug.cpp"
#else
    #define debug(...) 42
#endif
#define allit(a) (a).begin(), (a).end()
#define sz(a) ((int) (a).size())
#include "friend.h"

using namespace std;
using ll = long long;
using vi = vector<int>;
namespace pd = __gnu_pbds;
template<typename K>
using ordered_set = pd::tree<K, pd::null_type, less<int>, pd::rb_tree_tag, pd::tree_order_statistics_node_update>;
template<typename... T>
using gp_hash_table = pd::gp_hash_table<T...>;//simple using statement gives warnings

const int INF = 1e9;
const ll INFL = 1e18;
const int N = 1e5;
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(RANDOM);

// Find out best sample
int findSample(int n, int* confidence, int* host, int* protocol) {
    bool adj[11][11];
    memset(adj, 0, sizeof(adj));

    for (int i = 1; i < n; i++) {
        if (protocol[i] == 0) {
            adj[i][host[i]] = 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] = adj[j][i] = 1;
            }
        }
        else if (protocol[i] == 2) {
            for (int j = 0; j < i; j++) {
                adj[i][j] = adj[j][i] = 1;
            }
        }
    }
    ll res = 0;
    for (int perm = 0; perm < (1 << n); perm++) {
        ll sum = 0;
        vi v;
        for (int i = 0; i < n; i++) {
            if (perm & (1 << i)) {
                v.push_back(i);
                sum += confidence[i];
            }
        }
        for (int i : v) {
            for (int j : v) {
                if (adj[i][j]) goto next_perm;
            }
        }
        res = max(res, sum);
next_perm: continue;
    }
    return res;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...