# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
583767 | joelau | Split the Attractions (IOI19_split) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "split.h"
#include <bits/stdc++.h>
using namespace std;
int N,M,A,B,C;
vector<int> lst[100005], ans;
queue<int> q;
vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) {
N = n, M = p.size(), A = a, B = b, C = c;
for (int i = 0; i < M; ++i) lst[p[i]].push_back(q[i]), lst[q[i]].push_back(p[i]);
ans.assign(N,3);
ans[0] = 2;
q.push(0);
int cnt = 1;
while (!q.empty() && cnt < B) {
int u = q.front(); q.pop();
for (int v: lst[u]) if (ans[v] == 3) {
ans[v] = 2, cnt++;
if (cnt >= B) break;
}
}
for (int i = 0; i < N; ++i) if (ans[i] == 3) {
ans[i] = 1;
break;
}
return ans;
}