QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#842131 | #3248. tdnmo | Xiaohuba | AC ✓ | 664ms | 326600kb | C++23 | 5.3kb | 2025-01-04 10:25:26 | 2025-01-04 10:25:26 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
// #define LOCK_GETCHAR
// #define USE_INT_128
#if __cplusplus < 201400
#warning "Please use c++14 or higher."
#define CONSTEXPR_FUNC
#define ENABLE_IF_INT
#else
#define CONSTEXPR_FUNC constexpr
#define ENABLE_IF_INT , enable_if_t<_is_integer<T>, int> = 0
template <class T> constexpr bool _is_integer = numeric_limits<T>::is_integer;
template <> constexpr bool _is_integer<bool> = false;
template <> constexpr bool _is_integer<char> = false;
#ifdef USE_INT_128
template <> constexpr bool _is_integer<__int128> = true;
template <> constexpr bool _is_integer<__uint128_t> = true;
#endif
#endif
#if !defined(_WIN32) && !defined(__CYGWIN__) && !defined(LOCK_GETCHAR)
#define getchar getchar_unlocked
#endif
#define il inline
#define mkp make_pair
#define fi first
#define se second
#define ssz(x) (signed((x).size()))
#define _loop_i_t(j, k) make_signed_t<decltype((j) - (k))>
#define For(i, j, k) for (_loop_i_t(j, k) i = (j); i <= (k); ++i) // NOLINT
#define ForDown(i, j, k) \
for (_loop_i_t(j, k) i = (j); i >= decltype(i)(k); --i) // NOLINT
#define eb emplace_back
#ifndef ONLINE_JUDGE
#define FileIO(filename) \
freopen(filename ".in", "r", stdin); \
freopen(filename ".out", "w", stdout)
#else
#define FileIO(filename) void(0)
#endif
using ll = long long;
using uint = unsigned int;
using ull = unsigned long long;
using db = double;
using ldb = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#ifdef USE_INT_128
using lll = __int128_t;
using ulll = __uint128_t;
#endif
// clang-format off
CONSTEXPR_FUNC il ll qpow(ll x, ull y, ll mod){ ll ans = 1; x %= mod; while (y) { if (y & 1) (ans *= x) %= mod; (x *= x) %= mod; y >>= 1; } return ans; }
template<typename T> CONSTEXPR_FUNC il void cmin(T & x, const T &y){ x = min(x, y); }
template<typename T> CONSTEXPR_FUNC il void cmax(T & x, const T &y){ x = max(x, y); }
template<typename T ENABLE_IF_INT> il void read(T &x){ x = 0; int f = 1; int c = getchar(); while (!isdigit(c)) { if (c == '-') f = -1; c = getchar(); } while (isdigit(c)) { x = x * 10 + (c - '0'); c = getchar(); } x *= f; }
template<typename T, typename ... Args> il void read(T &x, Args &... y){ read(x), read(y...); }
// clang-format on
// File head end
namespace {
constexpr ll MAXN = 1e6 + 5, B = 2500;
int n, m, fa[MAXN], _id[MAXN], tot = 0, bl[MAXN], key[2048][2], pos[MAXN],
onTr[MAXN], dep[MAXN];
vector<int> T[MAXN];
vector<pii> st;
bool isKey[MAXN];
pii b[MAXN];
vector<tuple<int, int, int>> todo[MAXN];
vector<tuple<int, int, int>> ans;
vector<pii> todo2[MAXN];
void dfs1(int x) {
dep[x] = dep[fa[x]] + 1;
int cur = ssz(st), cnt = 0;
for (int v : T[x]) {
st.eb(x, v), dfs1(v), cnt += !!pos[v], _id[v] = ssz(st);
if (pos[v] && !pos[x])
pos[x] = pos[v];
}
if (x == 1 || cnt >= 2 || ssz(st) - cur >= B) {
cnt = 0, pos[x] = x, isKey[x] = 1;
// cerr << "U " << x << '\n';
int qwq = 0, pre = 0, cur0 = cur;
for (int v : T[x]) {
if (cnt + (!!pos[v]) == 2 || _id[v] - cur > B) {
assert(pre);
++tot;
key[tot][0] = x, key[tot][1] = qwq;
// cerr << "V " << v << ' ' << qwq << '\n';
For(i, cur + 1, _id[pre]) {
if (!isKey[st[i].fi])
bl[st[i].fi] = tot;
if (!isKey[st[i].se])
bl[st[i].se] = tot;
}
cur = _id[pre], cnt = qwq = 0;
}
if (pos[v])
qwq = pos[v], cnt++;
pre = v;
}
++tot;
key[tot][0] = x, key[tot][1] = qwq;
// cerr << "V back " << qwq << '\n';
For(i, cur + 1, _id[pre]) {
if (!isKey[st[i].fi])
bl[st[i].fi] = tot;
if (!isKey[st[i].se])
bl[st[i].se] = tot;
}
st.resize(cur0);
}
}
void dfs2(int x) {
if (isKey[x]) {
sort(todo[x].begin(), todo[x].end());
int c = 0;
for (auto [d, u, id] : todo[x]) {
ans.eb(1, x, d), c++;
ans.eb(1, u, d + dep[x] - dep[u]);
ans.eb(3, id, 0);
ans.eb(2, 0, 0);
}
For(_, 1, c) ans.eb(2, 0, 0);
}
for (int v : T[x])
dfs2(v);
}
void dfs3(int x) {
sort(todo2[x].begin(), todo2[x].end());
for (auto [d, id] : todo2[x])
ans.eb(1, x, d), ans.eb(3, id, 0);
For(_, 1, ssz(todo2[x])) ans.eb(2, 0, 0);
for (int v : T[x]) {
dfs3(v);
}
}
void Main() {
read(n, m);
For(i, 2, n) read(fa[i]), T[fa[i]].eb(i);
dfs1(1);
For(i, 1, tot) if (key[i][1]) {
int p = key[i][1];
while (p != key[i][0]) {
onTr[p] = key[i][1], p = fa[p];
}
}
cerr << tot << '\n';
assert(key[tot][0] == 1), onTr[1] = key[tot][1];
For(i, 1, m) {
auto &[x, d] = b[i];
read(x, d);
if (!onTr[x] || dep[onTr[x]] >= dep[x] + d)
todo2[x].eb(d, i);
else
todo[onTr[x]].eb(d - (dep[onTr[x]] - dep[x]), x, i);
}
dfs2(1);
cerr << ssz(ans) << '\n';
dfs3(1);
cerr << ssz(ans) << '\n';
printf("%d\n", ssz(ans));
for (auto [x, y, z] : ans) {
if (x == 1)
printf("%d %d %d\n", x, y, z);
else if (x == 2)
printf("%d\n", x);
else
printf("%d %d\n", x, y);
}
}
} // namespace
signed main() { return Main(), 0; }
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 659ms
memory: 160676kb
input:
1000000 1000000 1 2 2 4 5 6 7 4 8 1 5 7 11 5 4 10 10 8 3 7 8 14 16 4 18 16 1 17 15 20 4 32 1 18 18 5 35 9 26 33 24 2 16 3 18 12 34 29 14 18 5 12 17 4 31 28 45 43 50 41 18 15 3 17 56 46 20 60 13 34 6 70 61 11 43 75 24 31 30 72 29 69 78 55 14 11 24 19 68 17 4 21 33 4 45 50 95 25 90 13 100 12 2 56 20 1...
output:
3000716 1 3 2 1 3 2 3 759870 2 1 3 9 1 3 9 3 208290 2 1 3 17 1 3 17 3 380688 2 1 3 21 1 3 21 3 783918 2 2 2 2 2 1 20 12 1 20 12 3 177984 2 2 1 31 10 1 31 10 3 553703 2 2 1 158 5 1 66 7 3 260305 2 2 1 223 8 1 223 8 3 712767 2 1 223 13 1 164 14 3 423968 2 1 223 14 1 223 14 3 935347 2 2 2 2 1 511 1 1 5...
result:
ok good
Test #2:
score: 0
Accepted
time: 573ms
memory: 221256kb
input:
1000000 1000000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98...
output:
3493196 1 1055 1557 1 96 2516 3 970678 2 1 1055 2349 1 1033 2371 3 311047 2 1 1055 3276 1 92 4239 3 539520 2 1 1055 3458 1 1020 3493 3 525868 2 1 1055 4988 1 784 5259 3 336190 2 1 1055 5190 1 730 5515 3 840934 2 1 1055 5380 1 499 5936 3 173966 2 1 1055 6184 1 328 6911 3 935787 2 1 1055 6424 1 284 71...
result:
ok good
Test #3:
score: 0
Accepted
time: 428ms
memory: 177204kb
input:
1000000 1000000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98...
output:
3022748 1 21 227 1 4 244 3 175884 2 1 21 646 1 17 650 3 987592 2 1 21 700 1 12 709 3 564769 2 1 21 1910 1 1 1930 3 865598 2 1 21 2911 1 13 2919 3 982428 2 1 21 3027 1 5 3043 3 663429 2 1 21 5586 1 10 5597 3 75105 2 1 21 5847 1 8 5860 3 244777 2 1 21 6096 1 7 6110 3 882721 2 1 21 6586 1 21 6586 3 494...
result:
ok good
Test #4:
score: 0
Accepted
time: 532ms
memory: 180252kb
input:
999995 999995 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 9...
output:
4051605 1 15 1 1 1 15 3 7417 2 1 15 1 1 1 15 3 168442 2 1 15 1 1 1 15 3 171633 2 1 15 1 1 1 15 3 268575 2 1 15 1 1 1 15 3 369721 2 1 15 1 1 1 15 3 434793 2 1 15 1 1 1 15 3 568955 2 1 15 1 1 1 15 3 574299 2 1 15 2 1 1 16 3 276952 2 1 15 2 1 1 16 3 319316 2 1 15 2 1 1 16 3 449994 2 1 15 2 1 1 16 3 665...
result:
ok good
Test #5:
score: 0
Accepted
time: 486ms
memory: 176664kb
input:
1000000 1000000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98...
output:
3019358 1 4 387 1 1 390 3 218625 2 1 4 4007 1 3 4008 3 582213 2 1 4 4065 1 2 4067 3 842210 2 2 2 2 1 16 732 1 5 743 3 463087 2 1 16 3000 1 12 3004 3 256867 2 1 16 3286 1 14 3288 3 263209 2 1 16 3971 1 12 3975 3 924 2 1 16 4941 1 12 4945 3 300821 2 1 16 7451 1 16 7451 3 613333 2 1 16 7502 1 5 7513 3 ...
result:
ok good
Test #6:
score: 0
Accepted
time: 493ms
memory: 175736kb
input:
1000000 1000000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98...
output:
4010262 1 4 1 1 1 4 3 14344 2 1 4 1 1 1 4 3 31601 2 1 4 1 1 1 4 3 35812 2 1 4 1 1 1 4 3 37161 2 1 4 1 1 1 4 3 68166 2 1 4 1 1 1 4 3 69522 2 1 4 1 1 1 4 3 74074 2 1 4 1 1 1 4 3 83746 2 1 4 1 1 1 4 3 140173 2 1 4 1 1 1 4 3 168410 2 1 4 1 1 1 4 3 176381 2 1 4 1 1 1 4 3 186589 2 1 4 1 1 1 4 3 188091 2 1...
result:
ok good
Test #7:
score: 0
Accepted
time: 451ms
memory: 178864kb
input:
1000000 999996 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 ...
output:
3033084 1 24 277 1 6 295 3 89693 2 1 24 935 1 10 949 3 125856 2 1 24 1028 1 13 1039 3 969133 2 1 24 1098 1 7 1115 3 292762 2 1 24 1333 1 8 1349 3 358271 2 1 24 1452 1 20 1456 3 11197 2 1 24 1938 1 19 1943 3 950168 2 1 24 2202 1 7 2219 3 796818 2 1 24 3237 1 4 3257 3 580529 2 1 24 3782 1 12 3794 3 72...
result:
ok good
Test #8:
score: 0
Accepted
time: 552ms
memory: 310008kb
input:
1000000 999995 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 ...
output:
4653881 1 1055 1 1 1 1055 3 11568 2 1 1055 3 1 1 1057 3 814667 2 1 1055 4 1 1 1058 3 422861 2 1 1055 5 1 1 1059 3 343814 2 1 1055 7 1 1 1061 3 165701 2 1 1055 7 1 1 1061 3 659924 2 1 1055 8 1 1 1062 3 542471 2 1 1055 8 1 1 1062 3 774996 2 1 1055 9 1 1 1063 3 33374 2 1 1055 9 1 1 1063 3 308452 2 1 10...
result:
ok good
Test #9:
score: 0
Accepted
time: 488ms
memory: 314164kb
input:
1000000 1000000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98...
output:
4343862 1 1763 228 1 633 1358 3 801536 2 1 1763 1596 1 1075 2284 3 867833 2 1 1763 1707 1 1143 2327 3 234614 2 1 1763 2008 1 1258 2513 3 138827 2 1 1763 2961 1 922 3802 3 103090 2 1 1763 3006 1 952 3817 3 863456 2 1 1763 3105 1 1719 3149 3 947324 2 1 1763 3151 1 696 4218 3 916224 2 1 1763 3156 1 286...
result:
ok good
Test #10:
score: 0
Accepted
time: 629ms
memory: 306644kb
input:
999995 999999 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 9...
output:
4658049 1 935 4 1 1 938 3 160574 2 1 935 7 1 1 941 3 522606 2 1 935 9 1 1 943 3 482681 2 1 935 9 1 1 943 3 638865 2 1 935 10 1 1 944 3 849188 2 1 935 12 1 1 946 3 213597 2 1 935 13 1 1 947 3 580481 2 1 935 14 1 1 948 3 108540 2 1 935 15 1 1 949 3 550189 2 1 935 17 1 1 951 3 587103 2 1 935 18 1 1 952...
result:
ok good
Test #11:
score: 0
Accepted
time: 541ms
memory: 326600kb
input:
999997 999999 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 9...
output:
4543347 1 2036 106 1 365 1777 3 136109 2 1 2036 550 1 1665 921 3 894518 2 1 2036 787 1 357 2466 3 513940 2 1 2036 1022 1 736 2322 3 416624 2 1 2036 1034 1 1857 1213 3 884296 2 1 2036 1172 1 1822 1386 3 112381 2 1 2036 1316 1 1560 1792 3 783952 2 1 2036 2746 1 610 4172 3 358146 2 1 2036 3418 1 1725 3...
result:
ok good
Test #12:
score: 0
Accepted
time: 600ms
memory: 159096kb
input:
1000000 1000000 1 2 3 1 5 3 6 8 6 3 11 8 10 4 15 9 12 2 11 3 10 20 23 18 1 1 2 21 29 9 29 16 3 20 19 22 5 29 26 30 22 21 43 26 13 7 5 14 24 15 35 28 24 1 8 54 8 44 28 17 31 8 21 40 47 35 7 27 1 65 24 45 30 65 19 50 27 45 54 71 26 56 30 70 53 50 75 11 1 39 61 2 72 66 86 10 78 62 14 23 92 22 72 48 52 ...
output:
3000350 1 3 13 1 3 13 3 43299 2 2 1 4 4 1 4 4 3 355184 2 2 1 284 8 1 284 8 3 113619 2 2 1 916 7 1 916 7 3 1267 2 2 1 1840 14 1 1840 14 3 828374 2 2 1 142 5 1 142 5 3 115752 2 2 1 613 2 1 613 2 3 509806 2 1 613 7 1 176 9 3 22002 2 1 613 8 1 175 11 3 249806 2 1 613 49518 1 571 49519 3 896061 2 2 2 2 2...
result:
ok good
Test #13:
score: 0
Accepted
time: 570ms
memory: 307532kb
input:
999995 999997 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 9...
output:
4658013 1 1086 1 1 1 1086 3 845954 2 1 1086 2 1 1 1087 3 957943 2 1 1086 3 1 1 1088 3 962900 2 1 1086 4 1 1 1089 3 98997 2 1 1086 5 1 1 1090 3 992122 2 1 1086 6 1 1 1091 3 56578 2 1 1086 7 1 1 1092 3 982345 2 1 1086 9 1 1 1094 3 639210 2 1 1086 10 1 1 1095 3 62811 2 1 1086 10 1 1 1095 3 109106 2 1 1...
result:
ok good
Test #14:
score: 0
Accepted
time: 498ms
memory: 315416kb
input:
999995 999997 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 9...
output:
4364607 1 1830 803 1 752 1881 3 111641 2 1 1830 904 1 564 2170 3 420925 2 1 1830 963 1 1335 1458 3 254970 2 1 1830 2366 1 769 3427 3 104491 2 1 1830 2543 1 566 3807 3 849735 2 1 1830 2814 1 200 4444 3 262515 2 1 1830 3407 1 795 4442 3 368911 2 1 1830 3907 1 570 5167 3 474975 2 1 1830 4192 1 431 5591...
result:
ok good
Test #15:
score: 0
Accepted
time: 534ms
memory: 306988kb
input:
999995 999995 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 9...
output:
4658951 1 641 1 1 1 641 3 988801 2 1 641 2 1 1 642 3 263884 2 1 641 4 1 1 644 3 507683 2 1 641 5 1 1 645 3 236830 2 1 641 6 1 1 646 3 248459 2 1 641 8 1 1 648 3 629286 2 1 641 9 1 1 649 3 763243 2 1 641 11 1 1 651 3 330015 2 1 641 14 1 1 654 3 81172 2 1 641 14 1 1 654 3 584522 2 1 641 14 1 1 654 3 7...
result:
ok good
Test #16:
score: 0
Accepted
time: 516ms
memory: 320696kb
input:
1000000 1000000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98...
output:
4439768 1 1982 10 1 1115 877 3 146566 2 1 1982 1255 1 857 2380 3 179907 2 1 1982 1554 1 1762 1774 3 995361 2 1 1982 2104 1 738 3348 3 405364 2 1 1982 2153 1 556 3579 3 796518 2 1 1982 2165 1 1837 2310 3 675738 2 1 1982 2259 1 1506 2735 3 643065 2 1 1982 2273 1 633 3622 3 835384 2 1 1982 2426 1 1545 ...
result:
ok good
Test #17:
score: 0
Accepted
time: 532ms
memory: 308396kb
input:
999996 999995 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 9...
output:
4656193 1 2137 650 1 2137 650 3 723164 2 1 2137 2966 1 1887 3216 3 519542 2 1 2137 3328 1 685 4780 3 644443 2 1 2137 5251 1 227 7161 3 34543 2 1 2137 5356 1 792 6701 3 532325 2 1 2137 5813 1 1249 6701 3 956962 2 1 2137 6851 1 107 8881 3 529195 2 1 2137 7203 1 718 8622 3 26663 2 1 2137 7280 1 14 9403...
result:
ok good
Test #18:
score: 0
Accepted
time: 535ms
memory: 313048kb
input:
1000000 1000000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98...
output:
4325392 1 618 187 1 577 228 3 850054 2 1 618 553 1 444 727 3 258177 2 1 618 1396 1 501 1513 3 411775 2 1 618 1766 1 352 2032 3 336657 2 1 618 2550 1 188 2980 3 334968 2 1 618 3367 1 83 3902 3 492198 2 1 618 4095 1 490 4223 3 381735 2 1 618 4888 1 431 5075 3 588140 2 1 618 7453 1 97 7974 3 681909 2 1...
result:
ok good
Test #19:
score: 0
Accepted
time: 438ms
memory: 194052kb
input:
1000000 1000000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98...
output:
3205850 1 320 4999 1 287 5032 3 357914 2 1 320 5076 1 76 5320 3 306581 2 1 320 6285 1 313 6292 3 11281 2 1 320 7082 1 305 7097 3 651464 2 1 320 7557 1 47 7830 3 696268 2 1 320 8836 1 294 8862 3 715055 2 1 320 9302 1 210 9412 3 567289 2 1 320 9394 1 92 9622 3 589627 2 1 320 9683 1 165 9838 3 298970 2...
result:
ok good
Test #20:
score: 0
Accepted
time: 498ms
memory: 218616kb
input:
1000000 1000000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98...
output:
3718064 1 1471 136 1 1235 372 3 262872 2 1 1471 343 1 874 940 3 518636 2 1 1471 527 1 336 1662 3 498302 2 1 1471 645 1 215 1901 3 683421 2 1 1471 706 1 638 1539 3 861322 2 1 1471 1452 1 775 2148 3 28653 2 1 1471 1543 1 586 2428 3 753372 2 1 1471 1646 1 257 2860 3 82881 2 1 1471 1710 1 462 2719 3 216...
result:
ok good
Test #21:
score: 0
Accepted
time: 518ms
memory: 279732kb
input:
1000000 1000000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98...
output:
4429066 1 219 5575 1 188 5606 3 327967 2 1 219 8025 1 199 8045 3 984788 2 1 219 8773 1 207 8785 3 943114 2 1 219 31318 1 4 31533 3 994767 2 1 219 34222 1 157 34284 3 725052 2 1 219 36912 1 117 37014 3 157814 2 1 219 39032 1 129 39122 3 433652 2 1 219 39532 1 60 39691 3 276652 2 1 219 49634 1 5 49848...
result:
ok good
Test #22:
score: 0
Accepted
time: 264ms
memory: 81552kb
input:
1 1000000 1 1 1 0 1 0 1 0 1 1 1 1 1 0 1 1 1 0 1 1 1 1 1 1 1 0 1 0 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 0 1 1 1 0 1 0 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 0 1 0 1 1 1 1 1 0 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1 1 1 0 1 ...
output:
3000000 1 1 0 3 2 1 1 0 3 3 1 1 0 3 4 1 1 0 3 7 1 1 0 3 9 1 1 0 3 13 1 1 0 3 14 1 1 0 3 18 1 1 0 3 19 1 1 0 3 20 1 1 0 3 21 1 1 0 3 22 1 1 0 3 24 1 1 0 3 25 1 1 0 3 26 1 1 0 3 31 1 1 0 3 38 1 1 0 3 40 1 1 0 3 42 1 1 0 3 44 1 1 0 3 45 1 1 0 3 46 1 1 0 3 47 1 1 0 3 48 1 1 0 3 54 1 1 0 3 57 1 1 0 3 59 ...
result:
ok good
Test #23:
score: 0
Accepted
time: 643ms
memory: 160764kb
input:
1000000 999998 1 2 2 2 4 6 4 2 1 2 11 10 13 13 6 12 9 11 1 6 16 1 9 16 23 19 24 5 8 13 27 22 32 5 30 14 30 21 29 40 11 32 7 1 38 31 42 34 11 8 25 4 25 2 12 21 36 35 23 14 21 36 41 54 48 45 55 34 39 14 43 46 45 73 57 58 23 59 52 34 61 80 26 74 10 20 37 37 55 82 50 31 6 70 14 30 7 87 4 100 86 26 75 14...
output:
3000762 1 4 25 1 4 25 3 469541 2 2 1 371 20 1 371 20 3 675054 2 2 1 620 4 1 620 4 3 293904 2 2 1 622 7 1 622 7 3 14888 2 1 622 13 1 622 13 3 455375 2 1 622 15 1 98 16 3 284336 2 2 2 2 1 132 1 1 132 1 3 775751 2 2 1 195 18 1 195 18 3 217241 2 1 195 18 1 195 18 3 455257 2 2 2 1 870 3 1 664 4 3 831410 ...
result:
ok good
Test #24:
score: 0
Accepted
time: 84ms
memory: 167480kb
input:
999995 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...
output:
5 1 752 114171 1 1 114922 3 1 2 2
result:
ok good
Test #25:
score: 0
Accepted
time: 617ms
memory: 159136kb
input:
999996 999999 1 2 3 1 1 3 1 7 8 6 10 9 13 8 15 12 9 3 7 2 14 4 4 9 24 17 2 6 22 19 30 27 20 2 10 7 13 7 6 5 39 21 22 20 1 30 42 37 20 32 5 10 14 50 43 6 30 35 53 59 34 19 32 8 35 16 16 61 54 30 14 58 21 35 30 49 18 59 20 41 45 1 40 6 13 26 12 27 48 8 55 49 86 22 85 76 80 68 90 66 86 84 6 43 37 6 4 1...
output:
3000375 1 1364 5 1 1364 5 3 226618 2 1 1364 10 1 1364 10 3 932842 2 2 2 1 1226 17 1 1226 17 3 846757 2 2 1 1090 17 1 918 18 3 8843 2 2 1 202 3 1 202 3 3 186126 2 2 1 221 12 1 221 12 3 558448 2 2 1 9 4 1 9 4 3 375412 2 2 1 51 1 1 51 1 3 950411 2 1 51 15 1 51 15 3 118527 2 2 2 1 224 12 1 224 12 3 1653...
result:
ok good
Test #26:
score: 0
Accepted
time: 632ms
memory: 157240kb
input:
999998 999998 1 1 1 1 2 5 6 2 1 10 9 5 5 8 6 10 11 8 15 16 7 3 1 3 18 2 27 17 21 6 4 18 19 7 5 1 19 17 37 24 16 11 35 17 44 17 41 48 16 27 31 27 45 9 41 38 13 32 23 44 30 39 59 42 64 64 1 57 59 55 19 67 8 55 47 3 32 67 77 12 8 24 33 51 21 10 37 75 15 3 70 18 90 52 56 4 62 13 64 5 25 69 1 94 1 77 29 ...
output:
3000810 1 355 1 1 238 2 3 649775 2 1 355 17 1 238 18 3 745358 2 2 2 1 90 5 1 90 5 3 581113 2 2 1 105 15 1 94 16 3 365842 2 2 1 19 13 1 19 13 3 367437 2 1 19 19 1 19 19 3 949777 2 2 2 1 38 8 1 38 8 3 259045 2 2 1 57 14 1 57 14 3 500654 2 2 1 132 4 1 132 4 3 497121 2 1 132 12 1 132 12 3 370974 2 2 2 1...
result:
ok good
Test #27:
score: 0
Accepted
time: 664ms
memory: 257760kb
input:
1000000 1000000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98...
output:
4331130 1 44 1 1 1 44 3 191489 2 1 44 1 1 1 44 3 468323 2 1 44 2 1 1 45 3 46934 2 1 44 2 1 1 45 3 183727 2 1 44 2 1 1 45 3 217092 2 1 44 2 1 1 45 3 883363 2 1 44 2 1 1 45 3 963934 2 1 44 3 1 1 46 3 718155 2 1 44 4 1 1 47 3 863127 2 1 44 4 1 1 47 3 889484 2 1 44 6 1 1 49 3 68295 2 1 44 7 1 1 50 3 292...
result:
ok good
Test #28:
score: 0
Accepted
time: 584ms
memory: 192540kb
input:
1000000 1000000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98...
output:
3327440 1 112 1006 1 61 1057 3 886464 2 1 112 2649 1 12 2749 3 556686 2 1 112 4945 1 21 5036 3 992906 2 1 112 5177 1 41 5248 3 387591 2 1 112 6008 1 47 6073 3 204202 2 1 112 6563 1 9 6666 3 909946 2 1 112 7132 1 97 7147 3 737222 2 1 112 8597 1 6 8703 3 541846 2 1 112 10891 1 112 10891 3 370068 2 1 1...
result:
ok good
Test #29:
score: 0
Accepted
time: 643ms
memory: 248520kb
input:
999996 999996 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 9...
output:
4268794 1 61 1 1 1 61 3 855870 2 1 61 2 1 1 62 3 232387 2 1 61 2 1 1 62 3 238179 2 1 61 2 1 1 62 3 286435 2 1 61 2 1 1 62 3 816804 2 1 61 2 1 1 62 3 859119 2 1 61 2 1 1 62 3 898797 2 1 61 3 1 1 63 3 113100 2 1 61 3 1 1 63 3 992784 2 1 61 4 1 1 64 3 972372 2 1 61 5 1 1 65 3 298038 2 1 61 6 1 1 66 3 6...
result:
ok good
Test #30:
score: 0
Accepted
time: 613ms
memory: 199944kb
input:
1000000 1000000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98...
output:
3476528 1 379 50 1 36 393 3 618128 2 1 379 97 1 76 400 3 357173 2 1 379 876 1 212 1043 3 101281 2 1 379 1300 1 231 1448 3 862708 2 1 379 2447 1 379 2447 3 795044 2 1 379 3068 1 269 3178 3 565625 2 1 379 3108 1 372 3115 3 806093 2 1 379 3752 1 259 3872 3 654330 2 1 379 3893 1 206 4066 3 922670 2 1 37...
result:
ok good