| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 153127 | errorgorn | Split the Attractions (IOI19_split) | C++14 | 129 ms | 10472 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 <cstdio>
#include <vector>
using namespace std;
vector<int> al[100005];
int color,num;
vector<int> res;
void dfs(int i){
res[i]=color;
num--;
if (!num) return;
for (vector<int>::iterator it=al[i].begin();it!=al[i].end();it++){
if (!res[*it]) dfs(*it);
if (!num) return;
}
}
vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) {
res=vector<int> (n,0);
for (int x=0;x<p.size();x++){
al[p[x]].push_back(q[x]);
al[q[x]].push_back(p[x]);
}
if (a==1){
if (b>c) num=c,color=3;
else num=b,color=2;
dfs(0);
color=(color==2)?3:2;
bool lone=true;
for (int x=0;x<n;x++){
if (!res[x]){
if (lone){
lone=false;
res[x]=1;
}
else{
res[x]=color;
}
}
}
}
else{
int pos=0;
for (int x=0;x<n;x++){
if (al[x].size()==1){
pos=x;
break;
}
}
while (a--){
res[pos]=1;
if (res[al[pos][0]]==0) pos=al[pos][1];
else pos=al[pos][0];
}
while (b--){
res[pos]=2;
if (res[al[pos][0]]==0) pos=al[pos][1];
else pos=al[pos][0];
}
for (int x=0;x<n;x++) if (res[x]==0) res[x]=3;
}
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... | ||||
