# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
521021 | zsombor | Split the Attractions (IOI19_split) | C++17 | 96 ms | 10392 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 bcount;
vector <vector <int>> g(1e5);
vector <bool> bo(1e5,true);
vector<int> res;
void dfs(int x){
if (bcount==-1 || !bo[x]) return;
if (bcount==0){
res[x]=1;
bcount--;
return;
}
res[x]=2;
bcount--;
bo[x]=false;
for (int i : g[x]) dfs(i);
}
vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) {
res.resize(n,3);
int cur=0;
for (int i=0;i<p.size();i++){
g[p[i]].push_back(q[i]);
g[q[i]].push_back(p[i]);
}
if (a == 1) {
bcount=b;
dfs(0);
} else {
for (int i=0;i<n;i++) if (g[i].size()==1) cur = i;
for (int i = 0;i<a;i++){
res[cur]=1;
bo[cur]=false;
if (bo[g[cur][0]]){
cur=g[cur][0];
}else{
cur=g[i][1];
}
}
for (int i = 0;i<b;i++){
res[cur]=2;
bo[cur]=false;
if (bo[g[cur][0]]){
cur=g[cur][0];
}else{
cur=g[cur][1];
}
}
}
return res;
}
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... |