Submission #1032248

#TimeUsernameProblemLanguageResultExecution timeMemory
1032248shmaxSplit the Attractions (IOI19_split)C++17
11 / 100
54 ms14928 KiB
#include "split.h"

#include <bits/stdc++.h>

using namespace std;
using i32 = int;
#define int long long
#define len(x) (int)(x.size())
#define inf 1000'000'000'000'000'000LL
#define all(x) x.begin(), x.end()
#define low_bit(x) (x & (-x))

template<typename T>
using vec = vector<T>;

vector<i32> find_split(i32 n, i32 a, i32 b, i32 c, vector<i32> p, vector<i32> q) {
    vec<vec<int>> g(n);
    for (int i = 0; i < len(p); i++) {
        g[p[i]].push_back(q[i]);
        g[q[i]].push_back(p[i]);
    }


    vec<i32> ans(n, -1);
    vec<int> sizes(n);

    int need = 0;
    int T = 0;
    vec<bool> used(n, false);
    function<void(int, int)> choose = [&](int v, int p) {
        if (need == 0)
            return;
        if (used[v]) return;
        used[v] = true;
        need--;
        ans[v] = T;
        for (auto u: g[v]) {
            if (u == p) continue;
            choose(u, v);
        }
    };
    need = b;
    T = 2;
    choose(0, -1);
    for (int i = 0; i < n; i++) {
        if (ans[i] == -1) {
            ans[i] = 1;
            break;
        }
    }
    for (int i = 0; i < n; i++) {
        if (ans[i] == -1) {
            ans[i] = 3;
        }
    }
    return ans;
}
#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...