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>
#include "split.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define pb push_back
#define ff first
#define ss second
const int nax = 1e5 + 4;
int n, m, a, b, c;
vi adj[nax];
vi find_split(int N, int A, int B, int C, vi P, vi Q)
{
n = N, a = A, b = B, c = C;
m = P.size();
for(int i = 0; i < m; i ++)
{
adj[P[i]].pb(Q[i]);
adj[Q[i]].pb(P[i]);
}
int root;
for(int i =0; i < n ;i ++)
{
if(adj[i].size() == 1)
root = i;
}
int prec = -1;
vi ans(n);
for(int i =0; i < n; i++)
{
if(i >= a)
{
if(i >= a + b)
ans[root] = 3;
else
ans[root] = 2;
}
else
ans[root] = 1;
for(auto e: adj[root])
{
if(e != prec)
{
root = e;
break;
}
}
prec = root;
}
return ans;
}
/*
int32_t main()
{
int N, M, A, B, C;
cin >> N >> M >> A >> B >> C;
vi P(M), Q(M);
for(int i = 0; i < M; i++)
cin >> P[i] >> Q[i];
vi ANS = find_split(N, A, B, C, P, Q);
for(auto e: ANS)
cout << e << ' ';
}
*/
Compilation message (stderr)
split.cpp: In function 'vi find_split(int, int, int, int, vi, vi)':
split.cpp:40:25: warning: 'root' may be used uninitialized in this function [-Wmaybe-uninitialized]
40 | ans[root] = 3;
| ^
# | 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... |