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>
using namespace std;
typedef long long ll;
vector<ll> cad[200001];
vector<int> sol;
void dfs(int node, int p, int a, int b, int c, int pr)
{
if(pr<a)
{
sol[node]=1;
}
else if(pr<b)
{
sol[node]=2;
}
else if(pr<c)
{
sol[node]=3;
}
for(auto i:cad[node])
{
if(i!=p)
{
dfs(i,node, a, b, c, pr+1);
}
}
}
vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) {
sol.assign(n,0);
vector<ll> asd(n,0);
if(a+b+c!=n) return sol;
for(int i=0; i<p.size(); i++)
{
asd[p[i]]++;
asd[q[i]]++;
cad[p[i]].push_back(q[i]);
cad[q[i]].push_back(p[i]);
}
ll pl=0;
for(int i=0; i<n; i++)
{
if(asd[i]==1)
{
pl=i;
}
}
dfs(pl,-1,a,b+a,c+a+b,0);
return sol;
}
Compilation message (stderr)
split.cpp: In function 'std::vector<int> find_split(int, int, int, int, std::vector<int>, std::vector<int>)':
split.cpp:32:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
32 | for(int i=0; i<p.size(); i++)
| ~^~~~~~~~~
# | 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... |