# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1040039 | LaMatematica14 | Split the Attractions (IOI19_split) | C++17 | 32 ms | 9820 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 <bits/stdc++.h>
using namespace std;
vector<int> sz, pr;
vector<vector<int>> adj;
vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) {
array<pair<int, int>, 3> t;
t[0] = {a, 1}; t[1] = {b, 2}; t[2] = {c, 3};
sort(t.begin(), t.end());
sz.resize(n); pr.resize(n); adj.resize(n);
vector<int> g(n, 0);
for (int i = 0; i < p.size(); i++) {
adj[p[i]].push_back(q[i]); adj[q[i]].push_back(p[i]);
}
int beg = 0;
for (int i = 0; i < n; i++) {
if (adj[i].size() == 1) beg = i;
}
g[beg] = t[0].second; t[0].first--;
for (int i = 0; i < n; i++) {
for (int x : adj[beg]) {
if (g[x] > 0) continue;
if (t[0].first > 0) {
g[x] = t[0].second;
t[0].first--;
}
else if (t[1].first > 0) {
g[x] = t[1].second;
t[1].first--;
}
else {
g[x] = t[2].second;
t[2].first--;
}
beg = x;
break;
}
}
return g;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |