# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
832219 | tranxuanbach | Split the Attractions (IOI19_split) | C++17 | 60 ms | 12664 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;
#define isz(a) ((signed)a.size())
const int N = 1e5 + 5, M = 2e5 + 5;
int n, m;
vector <pair <int, int>> vcolor;
vector <int> adj[N];
vector <int> ans;
namespace subtask12{
bool check(){
for (auto &[cnt, col]: vcolor){
if (col == 1 and cnt == 1){
return true;
}
}
for (int u = 0; u < n; u++){
if (isz(adj[u]) > 2){
return false;
}
}
return true;
}
vector <bool> chosen;
void dfs(int u){
chosen[u] = true;
ans[u] = vcolor.back().second;
vcolor.back().first--;
if (vcolor.back().first == 0){
vcolor.pop_back();
}
for (auto v: adj[u]){
if (chosen[v]){
continue;
}
dfs(v);
}
}
vector <int> solve(){
chosen.assign(n, false);
int s = 0;
for (int u = 1; u < n; u++){
if (isz(adj[u]) == 1){
s = u;
break;
}
}
dfs(s);
return ans;
}
}
vector <int> find_split(int _n, int a, int b, int c, vector <int> _u, vector <int> _v){
n = _n; m = isz(_u);
vcolor = {{a, 1}, {b, 2}, {c, 3}};
sort(vcolor.begin(), vcolor.end());
for (int i = 0; i < m; i++){
int u = _u[i], v = _v[i];
adj[u].emplace_back(v);
adj[v].emplace_back(u);
}
ans.assign(n, 0);
if (subtask12::check()){
return subtask12::solve();
}
}
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... |