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>
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, s, n) for(ll i = ll(s); i < ll(n); i++)
#define rrep(i, n) for(ll i = ll(n)-1; i >= 0; i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<P>;
using vvp = vector<vp>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;
template<class T>
bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T>
bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
const int inf = 1001001001;
const ll linf = 1001001001001001001;
vi find_split(int n, int a, int b, int c, vi p, vi q) {
vvi G(n);
rep(i, p.size()) {
G[p[i]].pb(q[i]);
G[q[i]].pb(p[i]);
}
vi ls;
auto dfs = [&](auto &dfs, int u, int p) -> void {
ls.pb(u);
for (int v : G[u]) {
if (v == p) continue;
dfs(dfs, v, u);
}
};
rep(i, n) {
if (G[i].size() == 1) {
dfs(dfs, i, -1);
break;
}
}
vi ans(n);
rep(i, a) ans[ls[i]] = 1;
rep2(i, a, a + b) ans[ls[i]] = 2;
rep2(i, a + b, n) ans[ls[i]] = 3;
return ans;
}
# | 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... |