# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
145987 | JovanK26 | Split the Attractions (IOI19_split) | C++14 | 123 ms | 15524 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;
vector< vector<int> > v(200001);
bool vis[200001];
int sett[4];
int color;
vector<int> temp(200001);
void dfs(int start)
{
vis[start]=1;
while(sett[color]==0)
{
color++;
}
temp[start]=color;
sett[color]--;
for(int i=0;i<v[start].size();i++)
{
if(!vis[v[start][i]])
{
dfs(v[start][i]);
}
}
}
vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q)
{
vector<int> rez(n);
sett[1]=a;
sett[2]=b;
sett[3]=c;
for(int i=0;i<p.size();i++)
{
v[p[i]].push_back(q[i]);
v[q[i]].push_back(p[i]);
}
int ind=-1;
for(int i=0;i<n;i++)
{
if(v[i].size()==1)
{
ind=i;
break;
}
}
if(ind==-1)ind=0;
color=1;
dfs(ind);
for(int i=0;i<n;i++)
{
rez[i]=temp[i];
}
return rez;
}
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... |