제출 #1032961

#제출 시각아이디문제언어결과실행 시간메모리
1032961c2zi6Friend (IOI14_friend)C++14
16 / 100
1 ms448 KiB
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define replr(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define reprl(i, a, b) for (int i = int(a); i >= int(b); --i)
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define mkp(a, b) make_pair(a, b)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<VPI> VVPI;
typedef pair<ll, ll> PLL;
typedef vector<ll> VL;
typedef vector<PLL> VPL;
typedef vector<VL> VVL;
typedef vector<VVL> VVVL;
typedef vector<VPL> VVPL;
template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;}
template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;}
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T>
using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#include "friend.h"

int findSample(int n, int confidence[], int host[], int protocol[]){
    if (false && n <= 10) {
        VVI gp(n);
        replr(u, 1, n-1) {
            int p = host[u];
            int prot = protocol[u];
            if (prot == 0 || prot == 2) {
                gp[u].pb(p);
                gp[p].pb(u);
            }
            if (prot == 1 || prot == 2) {
                for (int v : gp[p]) if (v != u) {
                    gp[u].pb(v);
                    gp[v].pb(u);
                }
            }
        }
        VVI bad(n, VI(n));
        rep(u, n) for (int v : gp[u]) bad[u][v] = true;
        int maxvalue = 0;
        rep(s, (1<<n)) {
            VI a;
            rep(i, n) if (s & (1<<i)) a.pb(i);
            int value = 0;
            for (int u : a) for (int v : a) {
                if (bad[u][v]) {
                    goto vat;
                }
            }
            for (int u : a) value += confidence[u];
            vat:
            setmax(maxvalue, value);
        }
        return maxvalue;
    }
    bool ka[3]{};
    replr(u, 1, n-1) ka[protocol[u]] = true;
    if (!ka[0] && ka[1] && !ka[2]) {
        int ans = 0;
        rep(u, n) ans += confidence[u];
        return ans;
    } else if (!ka[0] && !ka[1] && ka[2]) {
        int ans = 0;
        rep(u, n) setmax(ans, confidence[u]);
        return ans;
    } else if (ka[0] && !ka[1] && !ka[2]) {
        return -1;
    }
	return 0;
}



#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...