# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
294987 | theStaticMind | Split the Attractions (IOI19_split) | C++14 | 128 ms | 12024 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>
#include "split.h"
using namespace std;
vector<int> ans;
vector<int> adj[100000];
void greedy(int x, int& rem, int v){
if(!rem) return;
ans[x] = v;
rem--;
for(auto y : adj[x]){
if(ans[y]) continue;
greedy(y, rem, v);
}
}
vector<int> find_split(int n, int a, int b, int c, vector<int> u, vector<int> v) {
ans = vector<int>(n, 0);
int w[3] = {a, b, c};
vector<int> q = {0, 1, 2};
sort(q.begin(), q.end(), [&](int x, int y){return w[x] < w[y];});
for(int i = 0; i < u.size(); i++){
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
}
greedy(0, w[q[1]], q[1] + 1);
for(int i = 0; i < n; i++){
if(!ans[i]){
greedy(i, w[q[0]], q[0] + 1);
break;
}
}
for(int i = 0; i < n; i++){
if(!ans[i]) ans[i] = q[2] + 1;
}
return ans;
}
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... |