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;
int A, B, C, N;
const int MXN = 100005;
vector<int> adj[MXN];
int res[MXN];
vector<int> order;
void dfsord(int node, int last) {
order.push_back(node);
for (int i=0; i<adj[node].size(); i++) {
int ot = adj[node][i];
if (ot == last) continue;
dfsord(ot, node);
return;
}
}
void line(int end) {
dfsord(end, -1);
}
vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) {
A = a;
B = b;
C = c;
N = n;
for (int i=0; i<n-1; i++) {
adj[p[i]].push_back(q[i]);
adj[q[i]].push_back(p[i]);
}
int mn = 0;
for (int i=0; i<n; i++) {
if (adj[i].size() < adj[mn].size()) {
mn = i;
}
}
line(mn);
vector<int> re(n);
for (int i=0; i<n; i++) {
if (i < a) re[order[i]] = 1;
else if (i - a < b) re[order[i]] = 2;
else re[order[i]] = 3;
}
return re;
}
Compilation message (stderr)
split.cpp: In function 'void dfsord(int, int)':
split.cpp:13:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i=0; i<adj[node].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... |