Submission #298840

#TimeUsernameProblemLanguageResultExecution timeMemory
298840Aldas25Split the Attractions (IOI19_split)C++14
18 / 100
147 ms14456 KiB
#include "split.h"
#include <bits/stdc++.h>

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define f first
#define s second
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll> vl;

const int MAXN = 100100;

vi adj[MAXN];
vi seq;
bool ch[MAXN];

void dfs (int v) {
    seq.pb(v);
    ch[v] = true;
    for (int u : adj[v]) {
        if (!ch[u])
            dfs(u);
    }
}

vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) {
	vector<int> res(n, 0);

    int m = (int)p.size();
    FOR(i, 0, m-1) {
        int u = p[i], v = q[i];
        adj[u].pb(v);
        adj[v].pb(u);
    }

    int st = 0;
    FOR(i, 0, n-1) if ((int)adj[i].size() == 1) st = i;
    dfs (st);

    FOR(i, 0, a-1) res[seq[i]] = 1;
    FOR(i, a, a+b-1) res[seq[i]] = 2;
    FOR(i, a+b, a+b+c-1) res[seq[i]] = 3;

	return res;
}

/*
9 10
4 2 3
0 1
0 2
0 3
0 4
0 6
0 8
1 7
3 7
4 5
5 6
ans:
1 1 3 1 2 2 3 1 3

6 5
2 2 2
0 1
0 2
0 3
0 4
0 5
ans:
0 0 0 0 0 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...