QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#723898 | #9607. 熟练 | hos_lyric | 100 ✓ | 1460ms | 144172kb | C++14 | 13.5kb | 2024-11-08 02:49:39 | 2024-11-08 02:49:41 |
Judging History
answer
#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using Int = long long;
template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }
#define COLOR(s) ("\x1b[" s "m")
struct Hld {
int n, rt;
// needs to be tree
// vertex lists
// modified in build(rt) (parent removed, heavy child first)
vector<vector<int>> graph;
vector<int> sz, par, dep;
int zeit;
vector<int> dis, fin, sid;
// head vertex (minimum depth) in heavy path
vector<int> head;
Hld() : n(0), rt(-1), zeit(0) {}
explicit Hld(int n_) : n(n_), rt(-1), graph(n), zeit(0) {}
void ae(int u, int v) {
assert(0 <= u); assert(u < n);
assert(0 <= v); assert(v < n);
graph[u].push_back(v);
graph[v].push_back(u);
}
void dfsSz(int u) {
sz[u] = 1;
for (const int v : graph[u]) {
auto it = std::find(graph[v].begin(), graph[v].end(), u);
if (it != graph[v].end()) graph[v].erase(it);
par[v] = u;
dep[v] = dep[u] + 1;
dfsSz(v);
sz[u] += sz[v];
}
}
void dfsHld(int u) {
dis[u] = zeit++;
const int deg = graph[u].size();
if (deg > 0) {
int vm = graph[u][0];
int jm = 0;
for (int j = 1; j < deg; ++j) {
const int v = graph[u][j];
if (sz[vm] < sz[v]) {
vm = v;
jm = j;
}
}
swap(graph[u][0], graph[u][jm]);
head[vm] = head[u];
dfsHld(vm);
for (int j = 1; j < deg; ++j) {
const int v = graph[u][j];
head[v] = v;
dfsHld(v);
}
}
fin[u] = zeit;
}
void build(int rt_) {
assert(0 <= rt_); assert(rt_ < n);
rt = rt_;
sz.assign(n, 0);
par.assign(n, -1);
dep.assign(n, -1);
dep[rt] = 0;
dfsSz(rt);
zeit = 0;
dis.assign(n, -1);
fin.assign(n, -1);
head.assign(n, -1);
head[rt] = rt;
dfsHld(rt);
assert(zeit == n);
sid.assign(n, -1);
for (int u = 0; u < n; ++u) sid[dis[u]] = u;
}
friend ostream &operator<<(ostream &os, const Hld &hld) {
const int maxDep = *max_element(hld.dep.begin(), hld.dep.end());
vector<string> ss(2 * maxDep + 1);
int pos = 0, maxPos = 0;
for (int j = 0; j < hld.n; ++j) {
const int u = hld.sid[j];
const int d = hld.dep[u];
if (hld.head[u] == u) {
if (j != 0) {
pos = maxPos + 1;
ss[2 * d - 1].resize(pos, '-');
ss[2 * d - 1] += '+';
}
} else {
ss[2 * d - 1].resize(pos, ' ');
ss[2 * d - 1] += '|';
}
ss[2 * d].resize(pos, ' ');
ss[2 * d] += std::to_string(u);
if (maxPos < static_cast<int>(ss[2 * d].size())) {
maxPos = ss[2 * d].size();
}
}
for (int d = 0; d <= 2 * maxDep; ++d) os << ss[d] << '\n';
return os;
}
bool contains(int u, int v) const {
return (dis[u] <= dis[v] && dis[v] < fin[u]);
}
int lca(int u, int v) const {
assert(0 <= u); assert(u < n);
assert(0 <= v); assert(v < n);
for (; head[u] != head[v]; ) (dis[u] > dis[v]) ? (u = par[head[u]]) : (v = par[head[v]]);
return (dis[u] > dis[v]) ? v : u;
}
int jumpUp(int u, int d) const {
assert(0 <= u); assert(u < n);
assert(d >= 0);
if (dep[u] < d) return -1;
const int tar = dep[u] - d;
for (u = head[u]; ; u = head[par[u]]) {
if (dep[u] <= tar) return sid[dis[u] + (tar - dep[u])];
}
}
int jump(int u, int v, int d) const {
assert(0 <= u); assert(u < n);
assert(0 <= v); assert(v < n);
assert(d >= 0);
const int l = lca(u, v);
const int du = dep[u] - dep[l], dv = dep[v] - dep[l];
if (d <= du) {
return jumpUp(u, d);
} else if (d <= du + dv) {
return jumpUp(v, du + dv - d);
} else {
return -1;
}
}
// [u, v) or [u, v]
template <class F> void doPathUp(int u, int v, bool inclusive, F f) const {
assert(contains(v, u));
for (; head[u] != head[v]; u = par[head[u]]) f(dis[head[u]], dis[u] + 1);
if (inclusive) {
f(dis[v], dis[u] + 1);
} else {
if (v != u) f(dis[v] + 1, dis[u] + 1);
}
}
// not path order, include lca(u, v) or not
template <class F> void doPath(int u, int v, bool inclusive, F f) const {
const int l = lca(u, v);
doPathUp(u, l, false, f);
doPathUp(v, l, inclusive, f);
}
// (vs, ps): compressed tree
// vs: DFS order (sorted by dis)
// vs[ps[x]]: the parent of vs[x]
// ids[vs[x]] = x, not set for non-tree vertex
vector<int> ids;
pair<vector<int>, vector<int>> compress(vector<int> us) {
// O(n) first time
ids.resize(n, -1);
std::sort(us.begin(), us.end(), [&](int u, int v) -> bool {
return (dis[u] < dis[v]);
});
us.erase(std::unique(us.begin(), us.end()), us.end());
int usLen = us.size();
assert(usLen >= 1);
for (int x = 1; x < usLen; ++x) us.push_back(lca(us[x - 1], us[x]));
std::sort(us.begin(), us.end(), [&](int u, int v) -> bool {
return (dis[u] < dis[v]);
});
us.erase(std::unique(us.begin(), us.end()), us.end());
usLen = us.size();
for (int x = 0; x < usLen; ++x) ids[us[x]] = x;
vector<int> ps(usLen, -1);
for (int x = 1; x < usLen; ++x) ps[x] = ids[lca(us[x - 1], us[x])];
return make_pair(us, ps);
}
};
////////////////////////////////////////////////////////////////////////////////
// T: monoid representing information of an interval.
// T() should return the identity.
// T(S s) should represent a single element of the array.
// T::push(T &l, T &r) should push the lazy update.
// T::pull(const T &l, const T &r) should pull two intervals.
template <class T> struct SegmentTreeRange {
int logN, n;
vector<T> ts;
SegmentTreeRange() : logN(0), n(0) {}
explicit SegmentTreeRange(int n_) {
for (logN = 0, n = 1; n < n_; ++logN, n <<= 1) {}
ts.resize(n << 1);
}
template <class S> explicit SegmentTreeRange(const vector<S> &ss) {
const int n_ = ss.size();
for (logN = 0, n = 1; n < n_; ++logN, n <<= 1) {}
ts.resize(n << 1);
for (int i = 0; i < n_; ++i) at(i) = T(ss[i]);
build();
}
T &at(int i) {
return ts[n + i];
}
void build() {
for (int u = n; --u; ) pull(u);
}
inline void push(int u) {
ts[u].push(ts[u << 1], ts[u << 1 | 1]);
}
inline void pull(int u) {
ts[u].pull(ts[u << 1], ts[u << 1 | 1]);
}
// Applies T::f(args...) to [a, b).
template <class F, class... Args>
void ch(int a, int b, F f, Args &&... args) {
assert(0 <= a); assert(a <= b); assert(b <= n);
if (a == b) return;
a += n; b += n;
for (int h = logN; h; --h) {
const int aa = a >> h, bb = b >> h;
if (aa == bb) {
if ((aa << h) != a || (bb << h) != b) push(aa);
} else {
if ((aa << h) != a) push(aa);
if ((bb << h) != b) push(bb);
}
}
for (int aa = a, bb = b; aa < bb; aa >>= 1, bb >>= 1) {
if (aa & 1) (ts[aa++].*f)(args...);
if (bb & 1) (ts[--bb].*f)(args...);
}
for (int h = 1; h <= logN; ++h) {
const int aa = a >> h, bb = b >> h;
if (aa == bb) {
if ((aa << h) != a || (bb << h) != b) pull(aa);
} else {
if ((aa << h) != a) pull(aa);
if ((bb << h) != b) pull(bb);
}
}
}
// Calculates the product for [a, b).
T get(int a, int b) {
assert(0 <= a); assert(a <= b); assert(b <= n);
if (a == b) return T();
a += n; b += n;
for (int h = logN; h; --h) {
const int aa = a >> h, bb = b >> h;
if (aa == bb) {
if ((aa << h) != a || (bb << h) != b) push(aa);
} else {
if ((aa << h) != a) push(aa);
if ((bb << h) != b) push(bb);
}
}
T prodL, prodR, t;
for (int aa = a, bb = b; aa < bb; aa >>= 1, bb >>= 1) {
if (aa & 1) { t.pull(prodL, ts[aa++]); prodL = t; }
if (bb & 1) { t.pull(ts[--bb], prodR); prodR = t; }
}
t.pull(prodL, prodR);
return t;
}
// Calculates T::f(args...) of a monoid type for [a, b).
// op(-, -) should calculate the product.
// e() should return the identity.
template <class Op, class E, class F, class... Args>
#if __cplusplus >= 201402L
auto
#else
decltype((std::declval<T>().*F())())
#endif
get(int a, int b, Op op, E e, F f, Args &&... args) {
assert(0 <= a); assert(a <= b); assert(b <= n);
if (a == b) return e();
a += n; b += n;
for (int h = logN; h; --h) {
const int aa = a >> h, bb = b >> h;
if (aa == bb) {
if ((aa << h) != a || (bb << h) != b) push(aa);
} else {
if ((aa << h) != a) push(aa);
if ((bb << h) != b) push(bb);
}
}
auto prodL = e(), prodR = e();
for (int aa = a, bb = b; aa < bb; aa >>= 1, bb >>= 1) {
if (aa & 1) prodL = op(prodL, (ts[aa++].*f)(args...));
if (bb & 1) prodR = op((ts[--bb].*f)(args...), prodR);
}
return op(prodL, prodR);
}
// Find min b s.t. T::f(args...) returns true,
// when called for the partition of [a, b) from left to right.
// Returns n + 1 if there is no such b.
template <class F, class... Args>
int findRight(int a, F f, Args &&... args) {
assert(0 <= a); assert(a <= n);
if ((T().*f)(args...)) return a;
if (a == n) return n + 1;
a += n;
for (int h = logN; h; --h) push(a >> h);
for (; ; a >>= 1) if (a & 1) {
if ((ts[a].*f)(args...)) {
for (; a < n; ) {
push(a);
if (!(ts[a <<= 1].*f)(args...)) ++a;
}
return a - n + 1;
}
++a;
if (!(a & (a - 1))) return n + 1;
}
}
// Find max a s.t. T::f(args...) returns true,
// when called for the partition of [a, b) from right to left.
// Returns -1 if there is no such a.
template <class F, class... Args>
int findLeft(int b, F f, Args &&... args) {
assert(0 <= b); assert(b <= n);
if ((T().*f)(args...)) return b;
if (b == 0) return -1;
b += n;
for (int h = logN; h; --h) push((b - 1) >> h);
for (; ; b >>= 1) if ((b & 1) || b == 2) {
if ((ts[b - 1].*f)(args...)) {
for (; b <= n; ) {
push(b - 1);
if (!(ts[(b <<= 1) - 1].*f)(args...)) --b;
}
return b - n - 1;
}
--b;
if (!(b & (b - 1))) return -1;
}
}
};
////////////////////////////////////////////////////////////////////////////////
constexpr int INF = 1001001001;
struct Node {
pair<int, int> mn;
int lz;
Node() : mn(INF, INF), lz(0) {}
void push(Node &l, Node &r) {
if (lz) {
l.add(lz);
r.add(lz);
lz = 0;
}
}
void pull(const Node &l, const Node &r) {
mn = min(l.mn, r.mn);
}
void add(int a) {
mn.first += a;
lz += a;
}
};
int subtaskId;
int N, M;
vector<int> A, B;
vector<int> S, T;
int main() {
for (int numCases; ~scanf("%d%d", &subtaskId, &numCases); ) { for (int caseId = 1; caseId <= numCases; ++caseId) {
scanf("%d%d", &N, &M);
A.resize(N - 1);
B.resize(N - 1);
for (int i = 0; i < N - 1; ++i) {
scanf("%d%d", &A[i], &B[i]);
--A[i];
--B[i];
}
S.resize(M);
T.resize(M);
for (int m = 0; m < M; ++m) {
scanf("%d%d", &S[m], &T[m]);
--S[m];
--T[m];
}
Hld hld(N);
for (int i = 0; i < N - 1; ++i) {
hld.ae(A[i], B[i]);
}
hld.build(0);
#ifdef LOCAL
cerr<<endl<<hld<<endl;
cerr<<"S = "<<S<<endl;
cerr<<"T = "<<T<<endl;
#endif
vector<vector<int>> mss(N);
SegmentTreeRange<Node> seg(N);
for (int u = 0; u < N; ++u) seg.at(hld.dis[u]).mn = make_pair(0, u);
seg.build();
for (int m = 0; m < M; ++m) {
mss[hld.lca(S[m], T[m])].push_back(m);
hld.doPath(S[m], T[m], true, [&](int l, int r) -> void {
seg.ch(l, r, &Node::add, -1);
});
}
const int mx = -seg.ts[1].mn.first;
vector<int> ans(M, -1);
for (; seg.ts[1].mn.first; ) {
// most covered, tie-break: min dis
const int u = seg.ts[1].mn.second;
assert(mss[u].size());
const int m = mss[u].back();
ans[m] = mx + seg.ts[1].mn.first;
mss[u].pop_back();
hld.doPath(S[m], T[m], true, [&](int l, int r) -> void {
seg.ch(l, r, &Node::add, +1);
});
}
printf("%d\n", mx);
for (int m = 0; m < M; ++m) {
if (m) printf(" ");
printf("%d", ans[m] + 1);
}
puts("");
}
#ifndef LOCAL
break;
#endif
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 3
Accepted
Test #1:
score: 3
Accepted
time: 169ms
memory: 3804kb
input:
1 100000 1 2 1 1 1 1 3 5 1 2 2 3 2 1 2 3 1 1 1 1 3 3 1 3 1 1 1 1 1 1 4 4 1 2 2 3 3 4 3 3 2 1 3 3 4 2 5 3 1 2 1 3 1 4 2 5 1 1 3 3 3 1 1 5 1 1 1 1 1 1 1 1 1 1 2 5 1 2 2 1 1 2 1 2 1 2 1 2 2 2 1 2 2 2 2 2 4 2 1 2 1 3 1 4 4 4 2 3 2 3 1 2 1 2 1 1 1 1 1 4 1 1 1 1 1 1 1 1 5 3 1 2 2 3 3 4 4 5 3 4 4 5 5 2 2 1...
output:
2 2 1 3 3 2 2 1 3 3 3 2 1 3 3 3 1 2 2 2 2 1 5 5 4 3 2 1 5 5 4 3 2 1 2 2 1 1 1 1 3 3 2 1 4 4 3 2 1 3 2 1 3 1 1 2 2 1 4 4 3 2 1 3 3 2 3 1 3 3 2 3 1 1 1 2 1 2 2 2 1 4 4 3 2 1 3 1 3 2 3 4 4 3 2 1 4 1 1 4 4 3 2 1 1 1 5 5 4 3 2 1 1 1 1 5 5 4 3 2 1 2 2 1 2 3 3 2 3 1 3 3 2 1 3 3 2 1 4 4 3 2 1 1 1 1 1 2 2 2 ...
result:
ok ok
Subtask #2:
score: 14
Accepted
Dependency #1:
100%
Accepted
Test #2:
score: 14
Accepted
time: 93ms
memory: 71180kb
input:
2 1005 489417 5 1 2 1 3 2 4 2 5 3 6 3 7 4 8 4 9 5 10 5 11 6 12 6 13 7 14 7 15 8 16 8 17 9 18 9 19 10 20 10 21 11 22 11 23 12 24 12 25 13 26 13 27 14 28 14 29 15 30 15 31 16 32 16 33 17 34 17 35 18 36 18 37 19 38 19 39 20 40 20 41 21 42 21 43 22 44 22 45 23 46 23 47 24 48 24 49 25 50 25 51 26 52 26 5...
output:
4 2 1 4 4 3 4 2 1 3 2 4 3 1 1 3 3 2 3 3 2 2 2 1 4 1 4 3 2 3 1 3 2 2 3 4 1 4 3 2 3 3 3 2 1 2 4 2 4 3 1 4 4 3 2 2 1 3 3 2 3 1 4 4 3 2 1 5 5 4 1 3 2 3 1 2 3 3 2 5 5 4 3 2 1 5 5 4 1 3 2 4 4 1 3 2 3 3 1 2 2 4 4 3 2 1 4 3 2 1 4 4 2 4 4 3 1 5 2 5 4 3 1 3 3 3 1 2 1 2 2 1 1 2 5 3 1 2 5 4 3 3 2 3 1 3 3 3 3 2 ...
result:
ok ok
Test #3:
score: 14
Accepted
time: 194ms
memory: 86348kb
input:
2 9250 403459 5 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 5...
output:
5 5 4 2 3 1 4 2 4 3 2 1 4 4 3 2 1 4 4 3 2 1 2 2 2 2 1 4 4 1 3 2 5 5 4 3 2 1 3 3 3 2 2 1 2 2 2 2 1 4 4 3 2 1 2 2 2 1 2 4 4 2 3 3 1 3 3 3 3 2 1 4 3 4 2 1 3 2 3 2 2 1 2 2 2 1 1 2 4 1 3 2 4 3 3 1 2 1 3 4 4 2 1 3 3 3 3 3 2 1 3 3 3 1 2 5 4 5 3 1 2 4 3 1 3 2 4 2 2 2 1 1 4 4 3 4 2 1 4 4 3 2 1 4 3 1 3 2 3 2 ...
result:
ok ok
Test #4:
score: 14
Accepted
time: 100ms
memory: 30136kb
input:
2 120 55394 5 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 ...
output:
3 1 1 3 2 3 2 2 2 1 1 2 4 3 4 1 3 2 4 4 4 3 2 1 4 2 4 3 3 1 3 2 3 1 3 2 5 5 4 3 2 1 4 4 3 2 1 3 3 2 2 1 3 3 2 1 3 2 1 2 1 2 3 1 1 3 2 2 5 5 4 3 2 1 5 5 4 3 2 1 4 4 3 2 1 3 3 2 2 1 3 3 3 1 2 3 3 3 2 1 4 4 3 2 4 1 5 5 4 3 2 1 4 4 3 4 2 1 3 2 3 1 1 3 3 3 2 1 3 5 5 4 3 2 1 4 1 2 4 3 4 4 2 4 1 3 3 2 3 2 ...
result:
ok ok
Test #5:
score: 14
Accepted
time: 143ms
memory: 32156kb
input:
2 6024 82100 5 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 5 13 10 14 8 15 6 16 15 17 3 18 9 19 14 20 19 21 4 22 1 23 22 24 21 25 25 26 11 27 18 28 23 29 7 30 26 31 12 32 2 33 29 34 17 35 34 36 31 37 32 38 13 39 30 40 36 41 33 42 41 43 40 44 16 45 42 46 39 47 20 48 48 49 43 50 46 51 37 52 52 53 4...
output:
5 5 4 3 2 1 4 4 1 4 3 2 4 1 3 4 4 2 4 4 4 3 2 1 4 4 3 2 4 1 3 1 3 3 2 3 1 3 2 3 3 3 1 2 3 5 5 4 3 2 1 3 3 2 3 1 4 4 2 1 3 3 3 3 2 1 3 3 2 2 1 3 3 2 1 3 2 4 4 4 3 2 1 4 4 3 4 1 2 4 4 3 2 1 2 2 2 2 1 5 2 5 4 1 3 3 3 2 2 1 1 5 5 2 4 1 3 4 4 2 3 1 5 3 5 2 4 1 3 3 2 1 2 4 2 4 3 2 1 4 1 4 3 2 3 3 2 1 3 4 ...
result:
ok ok
Test #6:
score: 14
Accepted
time: 84ms
memory: 4528kb
input:
2 483 2200 5 1 2 2 3 1 4 4 5 2 6 2 7 1 8 5 9 7 10 5 11 8 12 3 13 2 14 2 15 1 16 9 17 5 18 6 19 7 20 2 21 3 22 7 23 9 24 11 25 3 26 10 27 11 28 7 29 3 30 3 31 7 32 12 33 1 34 8 35 1 36 8 37 11 38 11 39 3 40 11 41 3 42 10 43 11 44 7 45 9 46 7 47 8 48 7 49 5 50 8 51 9 52 4 53 8 54 11 55 2 56 2 57 8 58 ...
output:
4 2 4 1 3 2 2 1 2 2 2 1 2 2 2 2 1 1 4 3 1 3 2 4 4 4 2 3 2 1 3 3 1 2 3 2 5 5 4 3 2 1 4 4 3 3 1 2 4 4 2 1 3 4 4 4 4 2 3 1 5 5 4 3 2 1 5 4 3 5 1 2 4 2 4 4 1 3 3 3 3 1 3 2 3 1 2 3 3 3 2 2 1 1 2 1 2 2 2 2 1 2 3 3 2 3 3 1 3 1 2 2 3 2 5 5 4 3 2 1 5 5 4 1 3 2 4 1 2 3 3 4 3 2 1 3 1 2 3 3 3 3 1 2 4 1 3 2 4 4 ...
result:
ok ok
Test #7:
score: 14
Accepted
time: 88ms
memory: 4512kb
input:
2 400 2260 5 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 5...
output:
3 3 1 2 1 2 4 1 4 4 3 2 5 5 4 3 2 1 4 4 4 3 1 2 3 3 3 1 2 3 5 5 4 3 2 1 4 2 3 4 2 1 4 4 3 2 3 1 5 1 5 4 3 2 4 4 4 3 2 1 5 4 3 2 1 5 5 5 4 3 2 1 4 4 4 3 2 1 4 4 3 2 1 1 3 3 3 2 2 1 3 3 2 3 1 1 3 3 2 3 2 1 5 5 4 3 2 1 5 3 2 5 4 1 5 5 4 3 2 1 3 2 3 3 2 1 4 4 3 2 1 4 3 3 2 2 3 1 5 5 4 3 2 1 3 2 2 3 1 3 ...
result:
ok ok
Test #8:
score: 14
Accepted
time: 134ms
memory: 30816kb
input:
2 9990 124660 5 1 2 2 3 1 4 4 5 4 6 1 7 6 8 7 9 8 10 1 11 7 12 6 13 8 14 11 15 5 16 12 17 6 18 9 19 17 20 13 21 21 22 20 23 15 24 16 25 10 26 7 27 6 28 1 29 8 30 26 31 17 32 13 33 18 34 13 35 9 36 18 37 28 38 18 39 34 40 10 41 30 42 9 43 17 44 37 45 5 46 26 47 15 48 6 49 28 50 19 51 15 52 45 53 36 5...
output:
4 4 3 2 1 4 4 4 3 3 1 2 5 5 2 4 1 3 5 2 5 3 4 1 4 4 3 2 1 4 4 3 2 1 4 5 5 4 3 2 1 4 4 4 3 2 1 4 2 4 1 4 3 4 4 4 1 3 2 4 4 3 3 2 1 2 2 2 2 1 3 2 1 2 3 3 4 4 3 2 1 4 3 2 3 1 2 3 2 1 3 2 3 2 1 3 3 3 4 4 4 2 3 1 5 5 4 3 1 2 3 3 1 2 2 3 3 1 3 1 2 4 4 2 3 2 1 4 4 3 2 1 4 3 4 3 2 1 5 5 4 3 2 1 2 1 2 1 2 4 ...
result:
ok ok
Test #9:
score: 14
Accepted
time: 145ms
memory: 32568kb
input:
2 9078 76509 5 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51...
output:
3 2 1 1 3 3 4 1 4 3 2 4 4 1 3 4 4 2 5 5 4 3 2 1 3 3 2 1 2 5 5 1 4 3 2 4 4 2 1 3 4 3 4 1 2 4 4 4 1 3 4 2 2 2 2 1 1 4 1 4 4 2 3 4 4 1 2 3 5 3 2 1 5 4 4 4 3 2 1 4 4 3 2 1 5 5 4 1 3 2 5 3 2 5 1 4 3 3 2 3 3 1 4 3 1 4 2 3 3 3 2 3 2 1 4 2 1 4 3 5 4 1 2 3 5 3 3 3 2 1 2 3 3 3 2 2 1 4 3 4 3 2 1 4 4 4 3 2 1 3 ...
result:
ok ok
Test #10:
score: 14
Accepted
time: 169ms
memory: 70588kb
input:
2 4147 456368 5 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 6 12 3 13 11 14 5 15 14 16 15 17 13 18 10 19 17 20 2 21 12 22 20 23 9 24 22 25 19 26 25 27 26 28 4 29 8 30 24 31 1 32 16 33 31 34 29 35 34 36 27 37 33 38 38 39 28 40 35 41 18 42 41 43 39 44 7 45 44 46 40 47 37 48 21 49 36 50 46 51 45 52 32 53...
output:
5 5 4 3 2 1 5 4 1 3 2 5 4 3 4 1 2 1 3 3 2 1 3 4 4 4 1 3 2 3 2 3 1 2 4 4 3 3 2 1 4 4 3 2 1 5 5 3 4 2 1 4 4 2 3 1 4 4 3 2 1 5 5 2 4 1 3 3 3 3 1 3 2 5 5 2 4 1 3 3 3 3 2 1 2 1 2 2 1 3 3 1 2 1 3 3 2 3 1 1 4 3 2 1 4 5 5 4 3 2 1 3 3 2 1 3 4 2 4 1 3 4 4 4 3 2 1 5 5 2 1 4 3 3 3 3 2 1 2 2 2 1 2 5 5 2 4 1 3 5 ...
result:
ok ok
Subtask #3:
score: 9
Accepted
Test #11:
score: 9
Accepted
time: 579ms
memory: 139576kb
input:
3 1769 481318 428631 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50...
output:
66 60 20 52 20 48 41 24 50 45 62 27 43 65 39 29 35 45 53 53 17 18 63 22 40 11 13 34 38 66 28 15 45 41 32 46 58 46 51 53 31 39 47 23 36 55 21 40 57 48 44 30 62 57 61 32 23 12 56 66 51 59 65 55 49 66 33 51 34 59 48 36 64 52 37 25 15 63 50 43 56 61 16 21 42 56 32 26 60 58 56 42 58 64 54 19 33 34 59 33 ...
result:
ok ok
Test #12:
score: 9
Accepted
time: 398ms
memory: 39392kb
input:
3 5246 78503 54670 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 5...
output:
12758 1821 8519 12420 2959 5060 6413 10752 12683 2541 7660 6711 10350 9608 3662 4670 4110 12700 4498 2449 9720 2652 6911 1936 6029 9371 11625 9640 151 11891 3675 9659 6809 9286 11148 2447 9315 12438 8188 7064 5630 3524 11999 6388 5387 313 2722 12194 10481 6445 12438 5699 487 4959 190 4072 5479 1536 ...
result:
ok ok
Test #13:
score: 9
Accepted
time: 443ms
memory: 4556kb
input:
3 396 1125 1442 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 5...
output:
160 123 132 117 145 137 22 95 142 52 56 58 106 154 112 66 47 38 84 160 79 19 101 126 91 107 156 152 105 30 87 114 158 56 121 106 76 140 136 105 103 94 122 137 64 118 160 85 86 70 124 125 109 131 104 136 92 138 127 84 113 83 20 100 158 149 51 96 113 148 102 42 119 44 117 74 143 140 158 63 32 129 77 2...
result:
ok ok
Test #14:
score: 9
Accepted
time: 456ms
memory: 4492kb
input:
3 487 1664 2238 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 5...
output:
558 411 22 447 342 350 149 423 299 364 184 349 244 325 267 400 344 217 301 259 379 475 264 137 539 86 363 293 102 421 280 164 558 490 273 249 232 33 166 279 117 459 291 209 452 200 392 314 245 499 217 490 158 253 542 262 205 528 311 269 354 526 499 454 232 386 377 28 93 507 377 482 151 94 554 21 550...
result:
ok ok
Test #15:
score: 9
Accepted
time: 827ms
memory: 144172kb
input:
3 130 498610 459330 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 ...
output:
28970 24653 20803 28929 10177 26153 15770 23153 22231 9884 26118 9644 17761 10982 27087 5319 12233 18200 1090 16940 7768 12599 25330 14517 24825 21084 21561 16949 19910 21863 26585 23103 27600 3579 27663 18240 14484 28846 23569 25922 20030 11943 14452 25369 25926 7258 26974 7557 13104 9752 13571 131...
result:
ok ok
Test #16:
score: 9
Accepted
time: 701ms
memory: 135592kb
input:
3 3566 462541 448340 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50...
output:
183 182 37 138 66 118 84 113 116 114 164 100 33 100 104 130 50 61 145 152 158 126 87 88 148 170 60 155 98 111 134 177 126 165 43 180 144 108 131 110 137 121 63 89 120 154 178 94 132 91 172 64 68 51 59 177 163 99 133 152 173 65 75 147 175 90 155 136 102 183 78 169 128 174 69 175 45 158 164 102 160 98...
result:
ok ok
Subtask #4:
score: 20
Accepted
Test #17:
score: 20
Accepted
time: 3ms
memory: 3980kb
input:
4 37 923 917 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 10 13 4 14 11 15 9 16 8 17 5 18 18 19 2 20 13 21 12 22 14 23 19 24 3 25 16 26 15 27 22 28 28 29 21 30 6 31 31 32 23 33 1 34 17 35 30 36 26 37 37 38 34 39 20 40 40 41 39 42 41 43 38 44 24 45 33 46 42 47 25 48 45 49 29 50 36 51 48 52 43 53 51...
output:
839 839 839 838 838 837 836 835 834 833 832 839 831 830 829 828 827 826 825 824 823 822 839 821 820 839 819 818 817 816 838 815 814 813 812 838 811 839 810 839 809 808 807 806 805 804 803 802 833 801 800 799 798 797 796 795 794 793 832 792 791 790 789 788 787 786 785 839 784 783 839 782 781 780 779 ...
result:
ok ok
Test #18:
score: 20
Accepted
time: 7ms
memory: 4044kb
input:
4 26 910 955 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 5...
output:
417 265 335 185 21 109 349 360 369 328 305 296 247 135 330 363 221 407 413 203 397 208 369 264 415 301 284 275 245 94 410 260 382 220 408 251 100 208 51 219 396 353 369 383 166 405 240 374 385 410 177 358 189 389 176 410 310 272 400 198 389 214 390 290 321 305 387 412 138 384 369 66 394 410 417 20 3...
result:
ok ok
Test #19:
score: 20
Accepted
time: 6ms
memory: 4020kb
input:
4 27 932 945 1 2 1 3 2 4 2 5 3 6 3 7 4 8 4 9 5 10 5 11 6 12 6 13 7 14 7 15 8 16 8 17 9 18 9 19 10 20 10 21 11 22 11 23 12 24 12 25 13 26 13 27 14 28 14 29 15 30 15 31 16 32 16 33 17 34 17 35 18 36 18 37 19 38 19 39 20 40 20 41 21 42 21 43 22 44 22 45 23 46 23 47 24 48 24 49 25 50 25 51 26 52 26 53 2...
output:
161 161 160 159 159 114 158 161 160 161 161 160 157 161 160 156 35 157 158 159 155 154 161 153 27 143 152 159 157 161 151 156 150 149 26 157 153 148 155 146 158 160 154 159 35 147 152 155 156 160 142 141 153 161 153 160 34 140 158 159 152 146 158 157 156 145 155 160 159 159 35 154 139 160 160 153 15...
result:
ok ok
Test #20:
score: 20
Accepted
time: 6ms
memory: 4080kb
input:
4 27 915 930 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 5...
output:
473 204 463 452 341 237 405 220 418 304 198 186 452 233 202 456 181 167 121 55 376 316 305 397 202 92 302 407 137 436 344 140 361 199 411 99 458 339 359 411 434 91 148 265 273 357 177 344 420 329 449 463 379 351 150 466 394 278 449 448 343 472 224 276 248 378 111 159 237 264 282 224 462 349 95 73 13...
result:
ok ok
Test #21:
score: 20
Accepted
time: 6ms
memory: 3980kb
input:
4 20 966 940 1 2 2 3 1 4 4 5 5 6 2 7 2 8 6 9 2 10 10 11 3 12 4 13 6 14 11 15 2 16 1 17 13 18 15 19 16 20 16 21 20 22 5 23 6 24 18 25 21 26 18 27 18 28 7 29 25 30 29 31 21 32 3 33 4 34 32 35 16 36 14 37 15 38 16 39 17 40 4 41 7 42 22 43 1 44 33 45 31 46 37 47 15 48 5 49 30 50 43 51 16 52 47 53 13 54 ...
output:
196 169 196 151 92 195 73 194 193 192 191 60 167 190 59 55 160 192 189 188 54 53 187 195 186 52 185 184 196 183 51 50 182 196 181 180 179 178 177 187 176 175 194 174 195 49 173 48 172 47 171 170 169 46 192 168 193 167 166 45 44 165 196 164 43 151 163 162 161 160 194 42 41 149 159 158 141 157 156 155...
result:
ok ok
Test #22:
score: 20
Accepted
time: 6ms
memory: 4060kb
input:
4 28 920 959 1 2 2 3 1 4 3 5 2 6 4 7 6 8 3 9 4 10 6 11 11 12 8 13 3 14 4 15 8 16 13 17 3 18 17 19 11 20 14 21 7 22 19 23 7 24 12 25 3 26 12 27 22 28 9 29 15 30 17 31 14 32 8 33 2 34 7 35 12 36 13 37 22 38 25 39 20 40 37 41 11 42 29 43 17 44 23 45 36 46 7 47 27 48 24 49 30 50 28 51 17 52 26 53 46 54 ...
output:
216 216 213 215 216 210 214 213 215 118 116 214 213 113 212 211 210 112 209 208 207 206 205 204 203 208 109 215 108 213 202 207 215 206 107 105 201 214 212 216 200 199 155 92 103 215 91 198 212 102 100 197 216 196 215 216 195 211 203 194 214 193 192 191 190 209 189 93 188 212 211 92 187 186 185 184 ...
result:
ok ok
Test #23:
score: 20
Accepted
time: 6ms
memory: 4060kb
input:
4 24 935 984 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 5...
output:
175 83 92 149 137 165 169 168 128 130 173 146 93 101 8 57 69 166 121 46 123 94 154 114 80 77 133 117 91 156 121 131 173 52 143 111 112 53 146 28 111 41 36 153 99 59 17 91 155 38 72 73 50 124 161 156 139 90 56 88 128 49 175 40 147 122 108 120 99 23 146 39 68 170 98 32 160 49 161 140 163 166 153 65 90...
result:
ok ok
Test #24:
score: 20
Accepted
time: 7ms
memory: 4364kb
input:
4 31 919 917 1 2 1 3 2 4 2 5 3 6 3 7 4 8 4 9 5 10 5 11 6 12 6 13 7 14 7 15 8 16 8 17 9 18 9 19 10 20 10 21 11 22 11 23 12 24 12 25 13 26 13 27 14 28 14 29 15 30 15 31 16 32 16 33 17 34 17 35 18 36 18 37 19 38 19 39 20 40 20 41 21 42 21 43 22 44 22 45 23 46 23 47 24 48 24 49 25 50 25 51 26 52 26 53 2...
output:
588 500 122 121 120 122 119 588 587 586 588 585 584 583 121 582 587 581 587 118 580 579 117 578 577 576 575 116 574 573 585 120 572 119 118 571 570 117 115 569 568 585 584 588 567 566 565 564 116 588 563 562 561 560 559 558 557 115 556 114 588 586 113 555 112 111 554 114 583 553 110 552 551 550 109 ...
result:
ok ok
Test #25:
score: 20
Accepted
time: 5ms
memory: 4368kb
input:
4 22 986 926 1 2 2 3 1 4 2 5 4 6 6 7 3 8 5 9 7 10 4 11 3 12 4 13 7 14 5 15 3 16 8 17 1 18 8 19 3 20 1 21 5 22 2 23 4 24 8 25 4 26 3 27 2 28 1 29 4 30 2 31 2 32 5 33 3 34 6 35 5 36 5 37 6 38 1 39 8 40 5 41 6 42 3 43 8 44 1 45 8 46 6 47 8 48 4 49 6 50 3 51 8 52 7 53 4 54 5 55 6 56 5 57 4 58 8 59 2 60 ...
output:
123 123 123 123 122 122 123 121 122 123 122 122 123 121 120 120 122 121 120 121 119 120 119 122 121 119 120 119 118 118 121 118 122 121 120 120 117 117 118 117 121 116 117 119 115 116 115 116 119 119 116 114 115 118 114 113 117 118 112 115 111 116 118 117 114 110 116 117 109 120 113 113 119 112 118 ...
result:
ok ok
Test #26:
score: 20
Accepted
time: 6ms
memory: 4072kb
input:
4 22 931 950 1 2 1 3 2 4 3 5 3 6 2 7 6 8 3 9 7 10 7 11 8 12 5 13 3 14 4 15 2 16 3 17 8 18 1 19 3 20 5 21 5 22 6 23 8 24 3 25 1 26 8 27 8 28 8 29 5 30 6 31 4 32 6 33 3 34 8 35 6 36 6 37 7 38 2 39 3 40 8 41 8 42 3 43 8 44 5 45 6 46 7 47 2 48 2 49 1 50 4 51 7 52 7 53 6 54 3 55 3 56 5 57 1 58 5 59 7 60 ...
output:
648 648 646 647 646 645 644 641 647 648 643 642 641 644 640 639 639 638 638 637 619 636 635 634 633 647 616 646 632 631 630 634 629 628 644 647 627 626 631 625 624 623 622 621 620 619 618 617 616 615 614 645 613 626 646 612 611 622 610 611 609 642 621 608 607 606 644 605 604 581 603 643 574 602 618 ...
result:
ok ok
Test #27:
score: 20
Accepted
time: 7ms
memory: 4336kb
input:
4 24 990 970 1 2 2 3 3 4 4 5 4 6 3 7 5 8 6 9 2 10 2 11 5 12 3 13 4 14 6 15 9 16 7 17 3 18 17 19 10 20 7 21 12 22 2 23 13 24 23 25 20 26 26 27 20 28 11 29 16 30 16 31 16 32 1 33 31 34 26 35 24 36 24 37 13 38 12 39 15 40 29 41 33 42 21 43 6 44 44 45 10 46 29 47 24 48 24 49 30 50 6 51 12 52 21 53 26 54...
output:
675 675 675 666 664 588 587 663 658 656 654 586 674 673 650 675 645 667 637 629 585 584 673 583 582 671 674 669 675 581 580 579 620 578 617 577 576 575 611 609 574 667 608 604 573 572 602 674 571 570 601 569 568 567 597 591 663 675 588 586 566 575 662 565 564 563 562 561 661 674 670 560 574 673 672 ...
result:
ok ok
Test #28:
score: 20
Accepted
time: 6ms
memory: 4004kb
input:
4 22 971 961 1 2 2 3 1 4 3 5 4 6 6 7 2 8 3 9 2 10 10 11 8 12 11 13 11 14 9 15 9 16 8 17 8 18 10 19 10 20 20 21 13 22 10 23 12 24 12 25 23 26 4 27 18 28 23 29 4 30 5 31 19 32 7 33 20 34 7 35 4 36 36 37 28 38 14 39 15 40 14 41 34 42 19 43 33 44 3 45 33 46 35 47 31 48 9 49 42 50 8 51 36 52 27 53 44 54 ...
output:
377 365 342 377 376 376 376 375 337 374 377 375 327 373 375 377 322 373 372 371 370 369 374 368 367 366 377 365 299 364 280 376 363 375 362 361 360 359 372 370 358 248 357 356 355 354 353 352 372 351 377 188 171 369 170 368 350 349 348 166 165 372 347 162 154 323 346 377 345 151 145 377 143 344 135 ...
result:
ok ok
Test #29:
score: 20
Accepted
time: 6ms
memory: 4076kb
input:
4 25 994 999 1 2 1 3 1 4 1 5 1 6 1 7 1 8 8 9 3 10 7 11 9 12 1 13 12 14 11 15 15 16 5 17 16 18 13 19 6 20 4 21 17 22 19 23 2 24 10 25 23 26 20 27 24 28 27 29 18 30 22 31 31 32 32 33 14 34 34 35 26 36 36 37 29 38 21 39 30 40 39 41 28 42 35 43 41 44 25 45 33 46 44 47 42 48 38 49 40 50 50 51 46 52 45 53...
output:
261 260 261 260 259 258 257 256 255 254 253 252 252 251 250 249 248 247 246 245 244 243 242 241 261 240 239 253 238 253 237 236 235 234 233 232 231 230 229 228 227 226 225 224 223 222 221 220 219 218 217 216 215 214 213 212 211 210 209 208 260 259 207 206 205 204 203 260 202 201 200 199 198 197 196 ...
result:
ok ok
Test #30:
score: 20
Accepted
time: 5ms
memory: 4096kb
input:
4 31 943 994 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 5...
output:
34 23 34 26 28 30 31 29 18 30 26 9 20 9 34 18 26 30 26 25 32 25 29 20 31 21 13 23 16 28 34 33 28 25 27 33 29 26 32 19 23 33 30 31 22 9 4 25 21 25 9 31 26 22 26 15 26 25 23 33 18 18 9 26 19 32 33 10 27 28 33 3 16 29 23 24 20 27 28 32 15 27 31 24 28 20 31 21 27 17 33 21 29 30 34 34 32 26 25 31 17 34 2...
result:
ok ok
Test #31:
score: 20
Accepted
time: 6ms
memory: 4348kb
input:
4 27 981 972 1 2 1 3 2 4 3 5 5 6 6 7 7 8 1 9 9 10 4 11 11 12 8 13 13 14 14 15 15 16 12 17 16 18 17 19 10 20 20 21 19 22 18 23 21 24 22 25 25 26 23 27 24 28 27 29 29 30 30 31 31 32 28 33 32 34 33 35 35 36 26 37 34 38 38 39 39 40 36 41 41 42 40 43 42 44 37 45 43 46 46 47 44 48 45 49 49 50 50 51 47 52 ...
output:
19 19 18 17 16 15 14 13 12 3 18 17 15 19 15 19 19 19 14 18 19 14 14 13 15 18 19 19 18 19 19 19 12 19 19 19 19 18 19 18 19 19 15 16 19 19 19 18 10 15 16 15 19 18 19 18 18 19 17 19 19 19 14 14 16 19 18 19 14 11 19 19 12 19 18 18 19 17 19 15 12 19 19 10 19 14 19 9 18 17 17 19 19 19 15 18 19 19 14 13 19...
result:
ok ok
Test #32:
score: 20
Accepted
time: 3ms
memory: 3992kb
input:
4 27 941 912 1 2 1 3 2 4 3 5 1 6 5 7 1 8 8 9 6 10 1 11 2 12 10 13 3 14 12 15 7 16 1 17 13 18 12 19 6 20 13 21 14 22 16 23 1 24 11 25 16 26 9 27 4 28 1 29 2 30 2 31 4 32 14 33 7 34 7 35 5 36 7 37 7 38 15 39 1 40 5 41 5 42 11 43 7 44 15 45 17 46 3 47 11 48 5 49 13 50 4 51 14 52 6 53 6 54 8 55 2 56 1 5...
output:
150 150 150 149 149 149 148 150 147 148 147 148 150 146 147 148 145 149 144 147 146 150 149 145 147 149 144 143 143 142 146 141 142 149 145 140 148 146 148 139 149 149 147 141 145 138 145 150 141 150 150 140 147 150 145 146 145 144 143 147 144 144 143 140 142 142 141 148 137 141 139 143 140 148 142 ...
result:
ok ok
Subtask #5:
score: 22
Accepted
Dependency #4:
100%
Accepted
Test #33:
score: 22
Accepted
time: 203ms
memory: 19400kb
input:
5 496 94286 94269 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 9 12 4 13 3 14 13 15 1 16 5 17 16 18 15 19 18 20 2 21 10 22 12 23 23 24 14 25 19 26 20 27 26 28 8 29 29 30 27 31 21 32 25 33 28 34 22 35 30 36 17 37 32 38 33 39 7 40 38 41 37 42 39 43 11 44 44 45 35 46 40 47 41 48 43 49 24 50 34 51 45 52 47...
output:
27238 27238 27237 27236 27235 27115 27185 27234 27100 27233 27232 27231 27230 27229 27228 27227 27226 27225 27224 27223 27142 27222 27221 27220 27219 27218 27217 27216 27215 27214 27213 27212 27211 27210 27209 27208 27207 27206 27205 27204 27203 27202 27201 27200 27202 27199 27198 27116 27197 27196 ...
result:
ok ok
Test #34:
score: 22
Accepted
time: 324ms
memory: 17836kb
input:
5 102 87302 98915 1 2 2 3 3 4 4 5 1 6 2 7 3 8 1 9 7 10 3 11 9 12 5 13 2 14 13 15 3 16 9 17 7 18 13 19 19 20 16 21 4 22 20 23 14 24 18 25 17 26 26 27 7 28 4 29 3 30 28 31 16 32 32 33 5 34 13 35 17 36 10 37 19 38 14 39 22 40 22 41 36 42 25 43 43 44 12 45 6 46 33 47 24 48 38 49 8 50 31 51 26 52 47 53 2...
output:
43611 43609 43611 43610 43609 43589 43578 43608 43477 43607 43607 43377 43348 43606 43327 43611 43609 43320 43299 43239 43605 43228 43608 43604 43607 43223 43606 43603 43197 43611 43176 43173 43602 43604 43601 43162 43601 43119 43600 43600 43116 43599 43610 43113 43065 43598 43595 43598 43597 43053 ...
result:
ok ok
Test #35:
score: 22
Accepted
time: 368ms
memory: 18684kb
input:
5 465 95072 88256 1 2 1 3 2 4 2 5 3 6 3 7 4 8 4 9 5 10 5 11 6 12 6 13 7 14 7 15 8 16 8 17 9 18 9 19 10 20 10 21 11 22 11 23 12 24 12 25 13 26 13 27 14 28 14 29 15 30 15 31 16 32 16 33 17 34 17 35 18 36 18 37 19 38 19 39 20 40 20 41 21 42 21 43 22 44 22 45 23 46 23 47 24 48 24 49 25 50 25 51 26 52 26...
output:
58693 58693 34194 58692 58691 22781 18837 18837 58692 58690 58689 18836 58688 58687 58686 18835 18834 58685 58684 58683 58692 58682 58691 58693 58689 18833 58681 58680 58679 18836 18832 58678 58677 58676 58675 58674 58689 58688 58673 58685 58691 18831 18830 18829 58672 58671 58670 58693 58669 18828 ...
result:
ok ok
Test #36:
score: 22
Accepted
time: 106ms
memory: 7780kb
input:
5 911 9670 12225 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 8 11 6 12 5 13 4 14 7 15 9 16 16 17 11 18 1 19 14 20 15 21 13 22 3 23 20 24 12 25 24 26 26 27 23 28 18 29 27 30 22 31 2 32 19 33 32 34 25 35 34 36 29 37 10 38 28 39 33 40 30 41 38 42 17 43 41 44 36 45 37 46 45 47 40 48 44 49 48 50 50 51 51 52 49 ...
output:
11000 11000 10999 10998 10997 10992 10996 10995 10998 10994 10993 10992 10991 10990 10989 10975 10988 10987 10984 10986 10981 10985 10984 10983 10982 10981 10980 10979 10978 10977 10976 10975 10963 10974 10973 10997 10972 10971 10970 10969 10934 10968 10967 10966 10965 10964 10963 10962 10961 10960 ...
result:
ok ok
Test #37:
score: 22
Accepted
time: 111ms
memory: 8324kb
input:
5 1077 7078 10459 1 2 1 3 3 4 2 5 3 6 4 7 7 8 3 9 4 10 7 11 9 12 1 13 2 14 8 15 6 16 5 17 5 18 11 19 6 20 14 21 8 22 11 23 12 24 15 25 10 26 10 27 7 28 2 29 7 30 1 31 14 32 7 33 1 34 13 35 11 36 5 37 11 38 8 39 3 40 14 41 3 42 7 43 14 44 6 45 11 46 8 47 13 48 9 49 6 50 4 51 10 52 2 53 12 54 14 55 10...
output:
3386 3386 3385 3382 3384 3383 3382 3381 3381 3380 3379 3371 3367 3366 3357 3386 3378 3377 3386 3376 3327 3375 3323 3374 3373 3386 3321 3385 3372 3304 3371 3370 3369 3386 3284 3368 3283 3280 3367 3366 3365 3278 3384 3364 3363 3362 3361 3384 3277 3360 3359 3358 3380 3357 3356 3274 3267 3355 3354 3353 ...
result:
ok ok
Test #38:
score: 22
Accepted
time: 146ms
memory: 6972kb
input:
5 942 12731 14938 1 2 2 3 3 4 3 5 2 6 1 7 2 8 4 9 4 10 7 11 7 12 4 13 8 14 6 15 4 16 2 17 10 18 4 19 9 20 3 21 17 22 14 23 6 24 20 25 2 26 3 27 22 28 7 29 15 30 27 31 5 32 19 33 6 34 31 35 11 36 33 37 21 38 10 39 34 40 6 41 20 42 19 43 22 44 27 45 41 46 27 47 34 48 36 49 49 50 26 51 47 52 25 53 35 5...
output:
1051 1050 1038 1046 1051 1051 1042 1018 1050 1049 998 979 955 1050 1048 1048 946 921 919 915 1045 1047 1042 902 883 1041 854 1040 851 1046 1050 1045 846 1045 843 840 1044 838 794 1043 1039 1049 1042 789 1038 1041 1042 743 1040 1041 1039 1039 736 1038 1035 1049 1051 1050 1050 1051 1051 1037 1051 1037...
result:
ok ok
Test #39:
score: 22
Accepted
time: 123ms
memory: 4576kb
input:
5 147 1196 1056 1 2 2 3 2 4 3 5 3 6 5 7 3 8 2 9 3 10 10 11 2 12 3 13 12 14 4 15 4 16 3 17 6 18 6 19 10 20 3 21 9 22 8 23 2 24 2 25 6 26 1 27 4 28 3 29 1 30 11 31 8 32 5 33 5 34 7 35 3 36 9 37 1 38 9 39 6 40 4 41 7 42 5 43 4 44 12 45 2 46 8 47 5 48 8 49 6 50 9 51 11 52 5 53 6 54 2 55 9 56 8 57 10 58 ...
output:
451 451 447 451 450 449 450 437 416 449 449 414 448 401 447 385 448 446 369 445 451 444 447 443 367 442 446 441 445 440 439 364 438 362 357 329 444 437 436 321 435 434 433 432 431 318 430 429 428 443 295 427 277 442 268 444 426 425 449 261 424 260 451 441 450 440 450 259 423 422 421 420 439 438 437 ...
result:
ok ok
Test #40:
score: 22
Accepted
time: 116ms
memory: 4420kb
input:
5 123 1403 768 1 2 1 3 3 4 1 5 1 6 6 7 2 8 8 9 1 10 3 11 2 12 5 13 5 14 2 15 8 16 10 17 6 18 7 19 8 20 10 21 10 22 10 23 6 24 4 25 4 26 7 27 3 28 3 29 8 30 9 31 4 32 4 33 10 34 8 35 6 36 2 37 3 38 5 39 9 40 2 41 1 42 3 43 1 44 9 45 7 46 2 47 3 48 2 49 3 50 8 51 9 52 5 53 10 54 3 55 3 56 1 57 5 58 2 ...
output:
118 118 118 117 116 117 115 114 113 112 111 110 116 109 108 107 106 105 104 103 118 112 102 117 101 100 99 98 97 96 95 94 93 115 92 91 90 89 88 87 86 85 84 83 82 113 110 81 118 118 118 118 117 112 109 80 118 79 117 116 78 115 114 109 117 115 114 107 77 116 104 108 115 116 76 107 113 102 75 116 114 1...
result:
ok ok
Test #41:
score: 22
Accepted
time: 122ms
memory: 4484kb
input:
5 227 1768 690 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51...
output:
345 23 182 205 178 267 332 243 258 230 238 139 99 105 317 224 32 216 343 223 224 74 73 218 260 291 77 164 206 80 242 308 237 41 328 203 294 116 213 190 210 48 325 71 198 174 192 121 320 233 302 130 110 325 259 101 123 216 295 262 68 289 258 165 53 147 57 212 240 272 238 331 74 304 283 117 241 343 17...
result:
ok ok
Test #42:
score: 22
Accepted
time: 116ms
memory: 4836kb
input:
5 139 2287 2214 1 2 1 3 2 4 2 5 3 6 3 7 4 8 4 9 5 10 5 11 6 12 6 13 7 14 7 15 8 16 8 17 9 18 9 19 10 20 10 21 11 22 11 23 12 24 12 25 13 26 13 27 14 28 14 29 15 30 15 31 16 32 16 33 17 34 17 35 18 36 18 37 19 38 19 39 20 40 20 41 21 42 21 43 22 44 22 45 23 46 23 47 24 48 24 49 25 50 25 51 26 52 26 5...
output:
695 695 640 694 693 693 693 692 438 695 691 692 690 695 218 691 695 693 690 689 689 694 688 687 686 689 691 171 685 694 694 684 143 688 160 694 143 695 170 142 691 687 692 169 686 141 683 685 682 142 684 688 681 680 168 140 167 166 139 138 683 679 678 695 141 165 695 682 677 695 676 694 164 163 695 ...
result:
ok ok
Test #43:
score: 22
Accepted
time: 189ms
memory: 25104kb
input:
5 85 99108 97396 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 ...
output:
48829 42215 47337 46321 32537 46384 47452 36103 46329 38007 23328 32859 41514 34521 44184 47342 35117 34994 4797 45383 39335 22063 26116 43863 28087 42997 24373 39936 43587 42282 14845 29357 41805 40549 35298 31433 48749 41490 30809 33749 37080 34049 28649 45524 31261 34668 1417 38119 3330 48264 485...
result:
ok ok
Test #44:
score: 22
Accepted
time: 146ms
memory: 19836kb
input:
5 221 97581 86531 1 2 1 3 1 4 4 5 5 6 1 7 4 8 4 9 7 10 2 11 2 12 2 13 9 14 10 15 13 16 4 17 12 18 10 19 16 20 17 21 6 22 18 23 8 24 17 25 22 26 16 27 22 28 8 29 8 30 11 31 21 32 23 33 19 34 9 35 25 36 10 37 1 38 7 39 38 40 38 41 6 42 35 43 36 44 20 45 20 46 16 47 22 48 21 49 43 50 17 51 17 52 39 53 ...
output:
126 126 123 126 125 124 123 122 121 121 120 119 118 126 117 116 115 118 114 113 112 117 125 111 110 109 123 126 108 107 106 105 104 117 103 102 101 100 99 122 98 97 96 120 95 94 93 92 126 125 91 90 124 89 116 88 87 122 86 85 84 83 82 81 121 80 79 78 77 76 119 75 74 120 121 114 73 72 71 70 69 117 68 ...
result:
ok ok
Test #45:
score: 22
Accepted
time: 107ms
memory: 19728kb
input:
5 125 98543 89905 1 2 2 3 1 4 4 5 4 6 1 7 6 8 1 9 3 10 4 11 7 12 9 13 1 14 4 15 7 16 8 17 5 18 8 19 3 20 6 21 5 22 7 23 6 24 4 25 9 26 8 27 8 28 2 29 9 30 3 31 2 32 1 33 1 34 3 35 9 36 2 37 5 38 8 39 5 40 3 41 6 42 1 43 1 44 8 45 3 46 7 47 5 48 3 49 5 50 9 51 8 52 7 53 7 54 8 55 4 56 9 57 6 58 5 59 ...
output:
10182 10182 10182 10181 10176 10180 10179 10178 10177 10176 10175 10182 10174 10173 10182 10179 10181 10182 10177 10180 10175 10181 10182 10179 10180 10182 10180 10178 10179 10175 10172 10171 10175 10181 10180 10174 10177 10179 10177 10174 10176 10179 10179 10174 10173 10172 10171 10173 10170 10172 ...
result:
ok ok
Test #46:
score: 22
Accepted
time: 128ms
memory: 28288kb
input:
5 1256 83133 86248 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 5...
output:
31782 27311 30744 23936 15041 15139 7277 3598 20743 28981 26190 21919 4339 4900 20312 9522 16847 26625 29460 22805 3085 12056 7771 14427 19754 12075 11550 10311 13603 2083 22334 9875 19998 13849 18103 16666 19234 16882 17189 12199 28397 26678 16665 27056 19972 19744 6886 17937 29763 23881 30452 2585...
result:
ok ok
Test #47:
score: 22
Accepted
time: 108ms
memory: 8132kb
input:
5 337 8058 14070 1 2 1 3 2 4 2 5 1 6 1 7 6 8 3 9 1 10 8 11 4 12 11 13 8 14 1 15 10 16 4 17 11 18 7 19 8 20 4 21 1 22 8 23 3 24 11 25 12 26 3 27 9 28 6 29 4 30 3 31 11 32 7 33 4 34 9 35 10 36 4 37 4 38 5 39 8 40 3 41 9 42 9 43 4 44 10 45 4 46 5 47 4 48 4 49 6 50 10 51 7 52 11 53 5 54 12 55 12 56 5 57...
output:
4114 4114 4113 4112 4111 4110 4109 4108 4110 4107 4106 4105 4104 4103 4109 4102 4101 4100 4106 4099 4098 4097 4114 4096 4095 4094 4093 4092 4091 4090 4113 4114 4089 4113 4088 4087 4086 4085 4111 4084 4083 4082 4081 4114 4080 4114 4111 4079 4078 4107 4112 4077 4076 4112 4075 4074 4103 4102 4073 4072 ...
result:
ok ok
Test #48:
score: 22
Accepted
time: 148ms
memory: 7540kb
input:
5 443 9541 12325 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 ...
output:
2862 495 1264 2424 1873 2628 2446 2360 345 1613 1603 2318 2722 2483 1352 1029 1771 2506 569 2445 1714 2433 2400 2286 2791 2461 114 549 2308 2158 1480 779 2614 2218 2852 2064 2418 2793 30 1737 2425 2763 1278 2743 1790 1825 2270 2484 1020 2726 713 307 669 2669 2844 209 2060 1934 1008 2527 1177 2328 81...
result:
ok ok
Subtask #6:
score: 32
Accepted
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
100%
Accepted
Dependency #4:
100%
Accepted
Dependency #5:
100%
Accepted
Test #49:
score: 32
Accepted
time: 555ms
memory: 143256kb
input:
6 178 497927 412086 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 ...
output:
120 59 116 98 103 63 118 119 38 69 59 61 67 96 114 42 116 55 110 46 28 102 33 107 90 66 31 61 77 49 106 9 117 115 65 42 25 87 52 103 30 16 72 110 111 107 105 43 36 113 79 49 59 74 71 50 53 18 114 117 116 58 15 116 99 41 108 103 120 118 51 63 118 95 63 92 57 118 105 27 95 114 50 64 100 92 97 102 68 3...
result:
ok ok
Test #50:
score: 32
Accepted
time: 811ms
memory: 133996kb
input:
6 3234 454553 464302 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50...
output:
232572 201217 168502 121309 60239 186598 217236 108098 2750 190435 217803 195318 228110 16092 208807 200448 112164 173047 85256 228239 84187 127214 218948 102025 192369 229413 229262 195184 104572 173111 57415 108455 130147 186004 104281 200178 143475 46513 205149 146722 229010 225473 167399 175232 ...
result:
ok ok
Test #51:
score: 32
Accepted
time: 1460ms
memory: 71524kb
input:
6 5593 417535 438611 1 2 1 3 1 4 1 5 1 6 1 7 4 8 2 9 1 10 8 11 9 12 12 13 10 14 11 15 14 16 15 17 7 18 6 19 19 20 3 21 20 22 22 23 23 24 16 25 24 26 26 27 25 28 18 29 13 30 27 31 21 32 5 33 30 34 31 35 32 36 34 37 17 38 33 39 38 40 40 41 28 42 36 43 42 44 29 45 37 46 43 47 44 48 35 49 47 50 39 51 50...
output:
347915 347915 347914 347913 347912 347911 347910 347909 344695 347908 347907 347906 347905 347904 347903 347902 347901 347900 347899 347898 347897 347896 347895 347894 347893 347892 347891 347890 347832 347889 347888 347887 347886 347885 347884 347883 345199 347882 347351 347881 347880 347879 347878...
result:
ok ok
Test #52:
score: 32
Accepted
time: 1139ms
memory: 21456kb
input:
6 13826 84978 124376 1 2 2 3 3 4 4 5 3 6 1 7 4 8 8 9 7 10 7 11 3 12 5 13 12 14 10 15 6 16 14 17 9 18 15 19 8 20 13 21 12 22 20 23 16 24 23 25 4 26 5 27 2 28 5 29 5 30 17 31 5 32 24 33 11 34 14 35 11 36 25 37 22 38 16 39 11 40 29 41 38 42 17 43 38 44 41 45 17 46 44 47 33 48 42 49 6 50 29 51 51 52 3 5...
output:
80099 80099 80083 80099 80098 80037 80032 80021 80097 79913 80099 80096 79895 79708 79638 80095 80099 79566 80096 79513 80098 80094 80093 80092 79500 80091 79448 80097 80090 79424 79355 80096 79276 79138 79083 79003 80099 78950 78778 80089 79952 80088 78754 80093 80087 78653 78565 78543 80099 80086 ...
result:
ok ok
Test #53:
score: 32
Accepted
time: 901ms
memory: 48096kb
input:
6 3480 135245 82221 1 2 1 3 1 4 1 5 1 6 4 7 3 8 5 9 2 10 6 11 1 12 11 13 13 14 14 15 8 16 10 17 12 18 16 19 7 20 19 21 18 22 20 23 15 24 23 25 24 26 26 27 17 28 22 29 29 30 9 31 31 32 21 33 33 34 25 35 30 36 27 37 37 38 38 39 39 40 36 41 40 42 35 43 34 44 42 45 32 46 43 47 47 48 44 49 45 50 28 51 50...
output:
8376 8376 8375 8374 6684 4745 6553 3902 8136 6253 8202 5486 3454 6162 8204 8373 8053 2391 2615 6806 5625 5133 6903 5300 4372 8179 7911 6988 8367 8372 7987 4693 7844 6702 4054 8364 7880 7847 8371 7786 3828 8370 8369 7833 5786 8368 5903 8074 5627 7799 5836 7663 5150 5305 8367 2525 6400 2602 371 6074 9...
result:
ok ok
Test #54:
score: 32
Accepted
time: 522ms
memory: 49620kb
input:
6 6213 156426 135199 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50...
output:
62086 48411 15701 41453 44011 45790 25486 26588 7202 15184 54932 45805 49349 40879 55661 61775 34345 43649 25455 47700 57113 35424 36826 57476 27710 30210 46590 19519 60172 27289 39339 50642 34497 42917 36487 20817 62022 59476 16773 20160 3095 58921 60921 8148 26732 54544 36851 61045 25997 5037 5342...
result:
ok ok
Test #55:
score: 32
Accepted
time: 588ms
memory: 4744kb
input:
6 394 1424 1766 1 2 1 3 2 4 2 5 3 6 3 7 4 8 4 9 5 10 5 11 6 12 6 13 7 14 7 15 8 16 8 17 9 18 9 19 10 20 10 21 11 22 11 23 12 24 12 25 13 26 13 27 14 28 14 29 15 30 15 31 16 32 16 33 17 34 17 35 18 36 18 37 19 38 19 39 20 40 20 41 21 42 21 43 22 44 22 45 23 46 23 47 24 48 24 49 25 50 25 51 26 52 26 5...
output:
604 604 603 127 602 604 604 601 604 597 599 600 603 122 599 599 598 596 595 594 121 120 597 596 602 595 603 594 593 593 602 592 591 590 592 589 602 588 603 601 602 600 587 122 591 590 589 586 588 587 598 602 604 604 586 603 598 585 584 585 584 285 119 583 118 583 582 601 599 582 581 580 579 596 578 ...
result:
ok ok
Test #56:
score: 32
Accepted
time: 607ms
memory: 4432kb
input:
6 400 1210 2471 1 2 1 3 2 4 2 5 3 6 3 7 4 8 4 9 5 10 5 11 6 12 6 13 7 14 7 15 8 16 8 17 9 18 9 19 10 20 10 21 11 22 11 23 12 24 12 25 13 26 13 27 14 28 14 29 15 30 15 31 16 32 16 33 17 34 17 35 18 36 18 37 19 38 19 39 20 40 20 41 21 42 21 43 22 44 22 45 23 46 23 47 24 48 24 49 25 50 25 51 26 52 26 5...
output:
1521 1521 1520 1519 1517 1518 1517 1516 429 1513 1515 1514 1518 1520 1513 428 1512 1511 1510 1509 1516 1514 427 1508 426 1507 1512 425 849 1519 1516 1517 1506 1505 1504 1521 428 427 1521 1503 1502 1509 1501 1500 426 1499 1498 425 1497 1519 1496 1508 424 1495 423 1494 1493 1510 1492 1520 1517 1491 14...
result:
ok ok
Test #57:
score: 32
Accepted
time: 608ms
memory: 4676kb
input:
6 428 1031 1178 1 2 1 3 2 4 2 5 3 6 3 7 4 8 4 9 5 10 5 11 6 12 6 13 7 14 7 15 8 16 8 17 9 18 9 19 10 20 10 21 11 22 11 23 12 24 12 25 13 26 13 27 14 28 14 29 15 30 15 31 16 32 16 33 17 34 17 35 18 36 18 37 19 38 19 39 20 40 20 41 21 42 21 43 22 44 22 45 23 46 23 47 24 48 24 49 25 50 25 51 26 52 26 5...
output:
747 586 747 746 160 745 744 743 463 160 743 159 158 159 157 158 742 741 740 156 742 739 742 155 738 154 157 737 736 735 153 734 156 733 732 152 742 747 151 731 730 729 728 727 747 746 726 155 745 725 737 724 723 154 739 153 152 743 722 150 745 721 746 720 719 149 745 744 718 151 717 716 715 743 148 ...
result:
ok ok
Test #58:
score: 32
Accepted
time: 615ms
memory: 4388kb
input:
6 433 1412 1032 1 2 1 3 3 4 3 5 5 6 6 7 3 8 3 9 3 10 6 11 3 12 3 13 6 14 4 15 4 16 2 17 6 18 2 19 1 20 1 21 2 22 5 23 4 24 3 25 2 26 4 27 1 28 5 29 1 30 6 31 1 32 4 33 3 34 4 35 3 36 4 37 4 38 3 39 6 40 1 41 1 42 4 43 1 44 2 45 3 46 3 47 5 48 6 49 5 50 4 51 4 52 3 53 3 54 1 55 2 56 2 57 3 58 3 59 2 ...
output:
344 341 343 344 343 342 341 339 340 338 339 335 338 337 336 330 335 340 334 333 332 331 330 328 341 322 329 328 327 326 316 336 325 324 301 299 323 293 322 321 275 273 320 259 254 319 318 317 252 316 248 315 314 313 312 311 310 309 237 236 308 307 225 306 305 304 217 339 202 201 200 199 334 303 302 ...
result:
ok ok
Test #59:
score: 32
Accepted
time: 613ms
memory: 4624kb
input:
6 441 1130 2385 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 7 11 4 12 10 13 1 14 13 15 2 16 12 17 14 18 3 19 19 20 6 21 17 22 11 23 9 24 15 25 16 26 20 27 8 28 21 29 5 30 26 31 27 32 18 33 23 34 22 35 35 36 31 37 33 38 37 39 24 40 40 41 30 42 25 43 41 44 28 45 29 46 44 47 45 48 38 49 47 50 36 51 34 52 48 5...
output:
730 730 729 720 729 728 727 726 725 724 723 592 730 730 722 726 721 720 722 684 719 680 718 729 709 726 700 625 717 716 724 715 628 619 682 353 681 723 573 714 713 618 717 712 711 710 726 637 707 709 695 720 708 694 707 717 708 721 582 585 718 711 618 728 681 694 676 723 706 705 728 352 646 704 703 ...
result:
ok ok
Test #60:
score: 32
Accepted
time: 825ms
memory: 134420kb
input:
6 2736 454986 470122 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50...
output:
204856 113431 45643 130533 193088 85047 43231 184951 199661 189730 99806 165404 80314 135596 141330 32243 98068 192599 169579 152955 111206 135359 170933 73268 141935 168914 140590 115899 202970 174857 152658 112491 136844 127454 86571 56437 174501 58026 118866 23687 195458 134943 188740 169230 2038...
result:
ok ok