Submission #1286000

#TimeUsernameProblemLanguageResultExecution timeMemory
1286000al95ireyizSplit the Attractions (IOI19_split)C++20
0 / 100
40 ms13848 KiB
#pragma GCC optimize("O3", "fast-math", "unroll-loops", "no-stack-protector")
#include <bits/stdc++.h>
using namespace std;
#if !defined(ONLINE_JUDGE) and !defined(EVAL)
#include "template/debug.h"
#else
#define d(x...)
#endif
#define fr first
#define er erase
#define in insert
#define sc second
#define ll long long
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
#define len(x) (ll) x.size()
#define all(x) x.begin(),x.end()
const ll INF = 1e9, INFL = 1e18;
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll maxn = 2e5 + 5;

ll n, m, k = 0;

vll g[maxn];
pair<vll, vll> f(ll x, ll y){
    if(x > y) swap(x, y);
    // 7 balliq subtask: cycledi
    vll a, b;
    ll nw = 1, p = -1;
    while(len(a) < x){
        a.pb(nw);
        if(g[nw][0] == p) p = nw, nw = g[nw][1];
        else p = nw, nw = g[nw][0];
    }
    while(len(b) < y){
        b.pb(nw);
        if(g[nw][0] == p) p = nw, nw = g[nw][1];
        else p = nw, nw = g[nw][0];
    }
    return {a, b};
}
vector<int> find_split(int _n, int _a, int _b, int _c, vector<int> p, vector<int> q){
    n = _n;
    for(ll i = 0; i <= n; i ++) g[i].clear();
    for(ll i = 0; i < len(p); i ++){
        p[i] ++, q[i] ++;
        g[p[i]].pb(q[i]);
        g[q[i]].pb(p[i]);
    }
    vector<int>cv(n);
    if(_a <= _c and _b <= _c){
        auto [av, bv] = f(_a, _b);
        if(_a > _b) swap(av, bv);
        for(ll i = 0; i < n; i ++) cv[i] = 3;
        for(auto i : av) cv[i - 1] = 1;
        for(auto i : bv) cv[i - 1] = 2;
        return cv;
    }
    if(_a <= _b and _c <= _b){
        auto [av, _cv] = f(_a, _c);
        if(_a > _c) swap(av, _cv);
        for(ll i = 0; i < n; i ++) cv[i] = 2;
        for(auto i : av) cv[i - 1] = 1;
        for(auto i : _cv) cv[i - 1] = 3;
        return cv;
    }
    auto [bv, _cv] = f(_b, _c);
    if(_b > _c) swap(bv, _cv);
    for(ll i = 0; i < n; i ++) cv[i] = 1;
    for(auto i : bv) cv[i - 1] = 2;
    for(auto i : _cv) cv[i - 1] = 3;
    return cv;
}

// void _() {

// }
// signed main() {
//     ll tm = clock();
//     cin.tie(0)->sync_with_stdio(0);
//     ll t = 1;
//     // cin >> t;
//     for(ll tt = 1; tt <= t; tt ++) _();
//     cerr << "\n\033[1;31mTime: \033[1;30m" \
//         << (double)(clock()-tm)/1000000 << "\033[1;32m seconds\n";
// }
#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...