QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#668009 | #8938. Crawling on a Tree | Yansuan_HCl | RE | 3ms | 9208kb | C++20 | 3.3kb | 2024-10-23 10:36:54 | 2024-10-23 10:36:55 |
Judging History
answer
#include <bits/stdc++.h>
#define ms(x, v) memset(x, v, sizeof(x))
#define il __attribute__((always_inline)) static
#define U(i,l,r) for(int i(l),END##i(r);i<=END##i;++i)
#define D(i,r,l) for(int i(r),END##i(l);i>=END##i;--i)
using namespace std;
using ll = long long;
#define IC isdigit(c)
#define GC c=getchar()
void rd(auto &x) { x = 0; char GC; bool f = 0;
for (; !IC; GC) f |= c == '-';
for (; IC; GC) x = x * 10 + c - 48;
if (f) x = -x;
}
void rd(auto &x, auto &...y) { rd(x); rd(y...); }
#define meow(...) fprintf(stderr, __VA_ARGS__)
#define Assert(e, v) if (!(e)) { meow("AF@%d\n", __LINE__ ); exit(v); }
#define vc vector
#define eb emplace_back
#define pb push_back
const int N = 10004;
int n, m, c[N], cx[N];
using info = array<ll, N>;
void mkv(info &f, info &g, info &h) {
h.fill(1e18);
// int i = 0, j = 0, k = 0;
// while (i <= m && f[i] == 1e18) ++i;
// while (j <= m && g[j] == 1e18) ++j;
// if (i > m || j > m)
// return;
// h[i + j] = f[i] + g[j];
// k = i + j + 1;
// ++i; ++j;
// for (; i <= m && j <= m && f[i] < 1e18 && g[j] < 1e18 && k <= m; ++k) {
// if (f[i] - f[i - 1] <= g[j] - g[j - 1]) {
// h[k] = h[k - 1] + f[i] - f[i - 1];
// ++i;
// } else {
// h[k] = h[k - 1] + g[j] - g[j - 1];
// ++j;
// }
// }
// for (; i <= m && f[i] < 1e18 && k <= m; ++i, ++k) {
// h[k] = h[k - 1] + f[i] - f[i - 1];
// }
// for (; j <= m && f[j] < 1e18 && k <= m; ++j, ++k) {
// h[k] = h[k - 1] + g[j] - g[j - 1];
// }
// U (i, 0, m) U (j, 0, m - i) {
// assert(f[i] + g[j] >= h[i + j]);
// }
U (i, 0, m) U (j, 0, m - i)
h[i + j] = min(h[i + j], f[i] + g[j]);
U (i, 0, m) h[i] = min(h[i], ll(1e18));
U (i, 1, m - 1) if (h[i] != 1e18 && h[i - 1] != 1e18 && h[i + 1] != 1e18) {
assert(h[i] - h[i - 1] <= h[i + 1] - h[i]);
}
}
using edge = array<int, 3>;
vc<edge> g[N];
int siz[N], hson[N];
void dfs0(int u, int f) {
siz[u] = 1; cx[u] = c[u];
for (auto [v, w, k] : g[u]) if (v != f) {
dfs0(v, u);
siz[u] += siz[v];
cx[u] = max(cx[u], cx[v]);
if (siz[v] > siz[hson[u]])
hson[u] = v;
}
}
void dp(int u, int fa, int fw, int fk, info &f) {
for (auto [v, w, k] : g[u]) if (v == hson[u]) {
dp(hson[u], u, w, k, f);
}
for (auto [v, w, k] : g[u]) if (v != fa && v != hson[u]) {
info x {}, y {};
dp(v, u, w, k, x);
mkv(f, x, y);
f = y;
}
U (y, 1, m) f[y] = min(f[y], f[y - 1]); // 留在 u
int lb = m + 1, rb = -1;
U (y, 0, m) {
int x = max(cx[u], y);
if (2 * x - y > fk) rb = y;
else break;
}
D (y, m, 0) {
int x = max(cx[u], y);
if (2 * x - y > fk) lb = y;
else break;
}
D (i, rb, 0) f[i] = 1e18;
U (i, lb, m) f[i] = 1e18;
// U (i, 1, m - 1) {
// if (f[i] - f[i - 1] > f[i + 1] - f[i])
// exit(0);
// }
U (y, 0, m) {
int x = max(cx[u], y);
f[y] += (2 * x - y) * fw;
f[y] = min(f[y], ll(1e18));
}
}
int main() {
// freopen("ava.in", "r", stdin);
rd(n, m);
U (i, 2, n) {
int u, v, w, k; rd(u, v, w, k);
g[u].pb({v, w, k});
g[v].pb({u, w, k});
}
U (i, 2, n)
rd(c[i]);
dfs0(1, 0);
info f {};
dp(1, 0, 0, 2e9, f);
info h; h.fill(1e18);
U (y, 0, m) {
int x = max(cx[1], y);
h[x] = min(h[x], f[y]);
}
U (x, 1, m) {
h[x] = min(h[x - 1], h[x]);
if (x < cx[1] || h[x] >= 1e14)
puts("-1");
else
printf("%lld\n", h[x]);
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 4480kb
input:
4 2 1 2 3 2 2 3 2 1 2 4 5 1 1 1 1
output:
-1 13
result:
ok 2 number(s): "-1 13"
Test #2:
score: 0
Accepted
time: 0ms
memory: 4240kb
input:
4 2 1 2 3 2 2 3 2 1 2 4 5 1 2 2 2
output:
-1 -1
result:
ok 2 number(s): "-1 -1"
Test #3:
score: 0
Accepted
time: 1ms
memory: 4284kb
input:
2 1 2 1 1 1 1
output:
1
result:
ok 1 number(s): "1"
Test #4:
score: 0
Accepted
time: 1ms
memory: 4168kb
input:
2 50 2 1 1 1 50
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
result:
ok 50 numbers
Test #5:
score: 0
Accepted
time: 1ms
memory: 4284kb
input:
2 50 2 1 1 50 50
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 50
result:
ok 50 numbers
Test #6:
score: 0
Accepted
time: 1ms
memory: 4232kb
input:
2 50 1 2 1 100000 50
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 50
result:
ok 50 numbers
Test #7:
score: 0
Accepted
time: 2ms
memory: 7560kb
input:
50 1 1 2 85524 58896 2 3 9137 9819 3 4 3036 88987 4 5 78909 15766 5 6 76067 34996 6 7 64247 63701 7 8 14 9384 8 9 37698 35418 9 10 51427 91691 10 11 39818 89351 11 12 47887 64083 12 13 43836 44135 13 14 22561 83803 14 15 52617 97413 15 16 41869 83810 16 17 35783 18642 17 18 5514 34601 18 19 50448 49...
output:
3202064
result:
ok 1 number(s): "3202064"
Test #8:
score: 0
Accepted
time: 0ms
memory: 8736kb
input:
50 5 1 2 48897 1 2 3 59967 3 3 4 61806 2 4 5 48519 4 5 6 77213 5 6 7 32384 1 7 8 59009 2 8 9 98263 1 9 10 42945 6 10 11 5549 6 11 12 51097 6 12 13 88536 4 13 14 44215 2 14 15 56896 2 15 16 19263 5 16 17 30787 5 17 18 20135 3 18 19 75922 4 19 20 35387 5 20 21 84081 4 21 22 54235 5 22 23 44411 3 23 24...
output:
-1 -1 -1 -1 -1
result:
ok 5 number(s): "-1 -1 -1 -1 -1"
Test #9:
score: 0
Accepted
time: 2ms
memory: 8772kb
input:
50 10 1 2 44914 14 2 3 84737 11 3 4 76461 7 4 5 36207 14 5 6 48479 10 6 7 88167 14 7 8 71415 7 8 9 95290 10 9 10 12553 7 10 11 2718 7 11 12 89004 12 12 13 86605 10 13 14 76252 14 14 15 75076 10 15 16 52024 14 16 17 23365 15 17 18 93829 13 18 19 3765 10 19 20 72010 9 20 21 17119 7 21 22 83633 14 22 2...
output:
-1 -1 9947212 9947212 9947212 9947212 9947212 9947212 9947212 9947212
result:
ok 10 numbers
Test #10:
score: 0
Accepted
time: 0ms
memory: 8920kb
input:
50 20 1 2 84157 10 2 3 20072 5 3 4 36547 8 4 5 46072 11 5 6 64560 10 6 7 51220 8 7 8 6257 14 8 9 85793 7 9 10 67400 7 10 11 37948 14 11 12 64361 12 12 13 15316 14 13 14 86110 9 14 15 66507 13 15 16 31139 9 16 17 91577 12 17 18 30027 7 18 19 17865 9 19 20 16377 14 20 21 70649 14 21 22 29703 5 22 23 7...
output:
-1 -1 8952969 8952969 8952969 8952969 8952969 8952969 8952969 8952969 8952969 8952969 8952969 8952969 8952969 8952969 8952969 8952969 8952969 8952969
result:
ok 20 numbers
Test #11:
score: 0
Accepted
time: 3ms
memory: 8936kb
input:
50 30 1 2 92254 8 2 3 67112 8 3 4 51573 12 4 5 45236 11 5 6 86302 12 6 7 5974 14 7 8 96820 7 8 9 83266 13 9 10 83174 8 10 11 14722 9 11 12 80728 10 12 13 71250 12 13 14 59937 14 14 15 33700 7 15 16 58668 9 16 17 66269 9 17 18 30776 9 18 19 91575 11 19 20 51383 7 20 21 92925 14 21 22 70739 7 22 23 60...
output:
-1 -1 -1 -1 -1 18181356 18181356 18181356 18181356 18181356 18181356 18181356 18181356 18181356 18181356 18181356 18181356 18181356 18181356 18181356 18181356 18181356 18181356 18181356 18181356 18181356 18181356 18181356 18181356 18181356
result:
ok 30 numbers
Test #12:
score: 0
Accepted
time: 0ms
memory: 8984kb
input:
50 50 1 2 44120 30 2 3 73250 30 3 4 68398 30 4 5 98932 30 5 6 98719 30 6 7 96765 30 7 8 71479 30 8 9 37151 30 9 10 91752 30 10 11 8218 30 11 12 66373 30 12 13 49494 30 13 14 56744 30 14 15 829 30 15 16 61166 30 16 17 64926 30 17 18 76821 30 18 19 18028 30 19 20 3749 30 20 21 38173 30 21 22 57828 30 ...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 33741592 33741592 33741592 33741592 33741592 33741592 33741592 33741592 33741592 33741592 33741592 33741592 33741592 33741592 33741592 33741592 33741592 33741592 33741592 33741592 33741592 33741592 33741592 33741592 33741592 33741592 33741592 33741592 33741592 ...
result:
ok 50 numbers
Test #13:
score: 0
Accepted
time: 2ms
memory: 8480kb
input:
50 50 1 2 32039 30 2 3 25573 30 3 4 93435 30 4 5 12864 30 5 6 81011 30 6 7 72386 30 7 8 60555 30 8 9 44065 30 9 10 87410 30 10 11 95846 30 11 12 22377 30 12 13 33453 30 13 14 24010 30 14 15 84584 30 15 16 66399 30 16 17 15580 30 17 18 91590 30 18 19 72162 30 19 20 96308 30 20 21 57991 30 21 22 69903...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
result:
ok 50 numbers
Test #14:
score: 0
Accepted
time: 0ms
memory: 9208kb
input:
50 50 1 2 90182 100 2 3 80679 100 3 4 17341 100 4 5 14788 100 5 6 25843 100 6 7 19327 100 7 8 64668 100 8 9 261 100 9 10 11742 100 10 11 87415 100 11 12 4372 100 12 13 27691 100 13 14 88014 100 14 15 71401 100 15 16 79534 100 16 17 74095 100 17 18 81196 100 18 19 93774 100 19 20 18579 100 20 21 8033...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 126552274
result:
ok 50 numbers
Test #15:
score: 0
Accepted
time: 2ms
memory: 8812kb
input:
50 50 1 2 36276 100 2 3 234 100 3 4 42378 100 4 5 28720 100 5 6 8136 100 6 7 27716 100 7 8 53744 100 8 9 7176 100 9 10 49224 100 10 11 33219 100 11 12 25912 100 12 13 44418 100 13 14 78991 100 14 15 55156 100 15 16 84767 100 16 17 91981 100 17 18 63197 100 18 19 40548 100 19 20 78370 100 20 21 149 1...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 104297593
result:
ok 50 numbers
Test #16:
score: 0
Accepted
time: 0ms
memory: 8740kb
input:
50 50 1 2 89387 100 2 3 41204 100 3 4 80467 100 4 5 13758 100 5 6 11818 100 6 7 30592 100 7 8 28372 100 8 9 48338 100 9 10 1818 100 10 11 70286 100 11 12 52808 100 12 13 74834 100 13 14 69168 100 14 15 25792 100 15 16 28166 100 16 17 19009 100 17 18 80450 100 18 19 63550 100 19 20 35778 100 20 21 84...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 133219774
result:
ok 50 numbers
Test #17:
score: 0
Accepted
time: 2ms
memory: 8928kb
input:
50 50 1 2 15303 100 2 3 98808 100 3 4 15515 100 4 5 76922 100 5 6 45606 100 6 7 18024 100 7 8 83194 100 8 9 22871 100 9 10 93775 100 10 11 59712 100 11 12 13986 100 12 13 94177 100 13 14 20817 100 14 15 66237 100 15 16 34816 100 16 17 3800 100 17 18 76471 100 18 19 23516 100 19 20 11297 100 20 21 18...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 143745580
result:
ok 50 numbers
Test #18:
score: 0
Accepted
time: 3ms
memory: 9056kb
input:
50 50 1 2 58242 100 2 3 52909 100 3 4 68175 100 4 5 35825 100 5 6 26534 100 6 7 23990 100 7 8 65980 100 8 9 64364 100 9 10 53688 100 10 11 61013 100 11 12 61050 100 12 13 93001 100 13 14 65905 100 14 15 68787 100 15 16 11043 100 16 17 67314 100 17 18 1482 100 18 19 14105 100 19 20 35473 100 20 21 44...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 136747391 136747391 136747391
result:
ok 50 numbers
Test #19:
score: 0
Accepted
time: 0ms
memory: 8612kb
input:
50 50 1 2 87313 100 2 3 34142 100 3 4 75601 100 4 5 86787 100 5 6 19862 100 6 7 13844 100 7 8 59860 100 8 9 71550 100 9 10 15855 100 10 11 53118 100 11 12 89343 100 12 13 90120 100 13 14 30675 100 14 15 24900 100 15 16 46699 100 16 17 30187 100 17 18 47132 100 18 19 79439 100 19 20 46609 100 20 21 8...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 180004277
result:
ok 50 numbers
Test #20:
score: 0
Accepted
time: 2ms
memory: 8976kb
input:
50 50 1 2 6377 100 2 3 74759 100 3 4 12929 100 4 5 78652 100 5 6 45614 100 6 7 63300 100 7 8 2272 100 8 9 29671 100 9 10 1466 100 10 11 57378 100 11 12 69874 100 12 13 88680 100 13 14 59380 100 14 15 98428 100 15 16 1823 100 16 17 32536 100 17 18 73638 100 18 19 41194 100 19 20 39472 100 20 21 90418...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 162625095
result:
ok 50 numbers
Test #21:
score: 0
Accepted
time: 0ms
memory: 8992kb
input:
50 50 1 2 49316 100 2 3 28860 100 3 4 98357 100 4 5 4787 100 5 6 68367 100 6 7 60210 100 7 8 61346 100 8 9 3932 100 9 10 26915 100 10 11 25911 100 11 12 49706 100 12 13 20271 100 13 14 46292 100 14 15 33746 100 15 16 78050 100 16 17 96050 100 17 18 98649 100 18 19 99015 100 19 20 30880 100 20 21 163...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 178165310
result:
ok 50 numbers
Test #22:
score: 0
Accepted
time: 0ms
memory: 9120kb
input:
50 50 1 2 50686 100 2 3 61764 100 3 4 2158 100 4 5 61656 100 5 6 16190 100 6 7 47188 100 7 8 71543 100 8 9 79011 100 9 10 3719 100 10 11 80950 100 11 12 43743 100 12 13 12383 100 13 14 46293 100 14 15 93814 100 15 16 70307 100 16 17 73720 100 17 18 59814 100 18 19 6883 100 19 20 26432 100 20 21 1051...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 168905607
result:
ok 50 numbers
Test #23:
score: 0
Accepted
time: 2ms
memory: 9116kb
input:
50 50 1 2 52472 100 2 3 52489 100 3 4 37966 100 4 5 59816 100 5 6 27907 100 6 7 29864 100 7 8 58580 100 8 9 36585 100 9 10 97123 100 10 11 3182 100 11 12 84054 100 12 13 72639 100 13 14 26646 100 14 15 56775 100 15 16 7056 100 16 17 83190 100 17 18 88407 100 18 19 62560 100 19 20 66495 100 20 21 102...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 126132174
result:
ok 50 numbers
Test #24:
score: 0
Accepted
time: 3ms
memory: 9136kb
input:
50 50 1 2 26269 57 2 3 54838 68 3 4 33860 53 4 5 610 57 5 6 13881 94 6 7 8362 52 7 8 80460 75 8 9 84662 81 9 10 19967 86 10 11 60644 60 11 12 74314 65 12 13 19781 55 13 14 7800 61 14 15 11166 61 15 16 55688 61 16 17 86280 56 17 18 87661 91 18 19 65104 79 19 20 74638 57 20 21 72951 82 21 22 77319 100...
output:
-1 6500083 6500083 6500083 6500083 6500083 6500083 6500083 6500083 6500083 6500083 6500083 6500083 6500083 6500083 6500083 6500083 6500083 6500083 6500083 6500083 6500083 6500083 6500083 6500083 6500083 6500083 6500083 6500083 6500083 6500083 6500083 6500083 6500083 6500083 6500083 6500083 6500083 6...
result:
ok 50 numbers
Test #25:
score: 0
Accepted
time: 2ms
memory: 8812kb
input:
50 50 1 2 20786 58 2 3 36289 99 3 4 72709 65 4 5 20643 51 5 6 28260 59 6 7 82771 56 7 8 54535 62 8 9 67042 54 9 10 88729 91 10 11 63285 100 11 12 87705 92 12 13 98468 66 13 14 68505 96 14 15 37086 57 15 16 96419 55 16 17 14275 56 17 18 3023 77 18 19 169 70 19 20 87534 97 20 21 58552 70 21 22 94659 7...
output:
-1 6115126 6115126 6115126 6115126 6115126 6115126 6115126 6115126 6115126 6115126 6115126 6115126 6115126 6115126 6115126 6115126 6115126 6115126 6115126 6115126 6115126 6115126 6115126 6115126 6115126 6115126 6115126 6115126 6115126 6115126 6115126 6115126 6115126 6115126 6115126 6115126 6115126 6...
result:
ok 50 numbers
Test #26:
score: 0
Accepted
time: 2ms
memory: 8928kb
input:
50 50 1 2 48235 88 2 3 73049 100 3 4 59657 71 4 5 7714 51 5 6 32279 51 6 7 46460 58 7 8 1752 75 8 9 26 85 9 10 99024 53 10 11 46614 62 11 12 74988 62 12 13 10188 54 13 14 36538 60 14 15 82973 90 15 16 49197 96 16 17 28844 64 17 18 67770 81 18 19 5892 65 19 20 31742 61 20 21 26417 75 21 22 81333 62 2...
output:
-1 5708762 5708762 5708762 5708762 5708762 5708762 5708762 5708762 5708762 5708762 5708762 5708762 5708762 5708762 5708762 5708762 5708762 5708762 5708762 5708762 5708762 5708762 5708762 5708762 5708762 5708762 5708762 5708762 5708762 5708762 5708762 5708762 5708762 5708762 5708762 5708762 5708762 5...
result:
ok 50 numbers
Test #27:
score: 0
Accepted
time: 2ms
memory: 8332kb
input:
50 1 1 2 64846 1 2 3 76726 1 3 4 75087 1 4 5 248 1 5 6 1934 1 6 7 8476 1 7 8 20723 1 8 9 1597 1 9 10 75343 1 10 11 33438 1 11 12 59347 1 12 13 4097 2 12 26 13782 2 12 27 35089 1 13 14 17043 2 14 15 69465 2 15 16 91817 2 15 29 35818 2 16 17 73625 2 17 18 83002 2 18 19 87947 2 18 32 4127 2 19 20 73738...
output:
4159205
result:
ok 1 number(s): "4159205"
Test #28:
score: 0
Accepted
time: 0ms
memory: 8040kb
input:
50 2 1 2 58565 2 2 3 98266 2 3 4 83717 2 4 5 93399 2 5 6 50704 1 6 7 51541 1 7 8 26818 1 8 9 52929 1 9 10 84124 1 10 11 55215 1 11 12 36194 1 12 13 43797 1 13 14 34685 1 14 15 98478 2 14 26 75129 1 15 16 54681 2 16 17 71688 2 17 18 73687 2 17 31 95774 2 18 19 14608 2 18 32 30611 2 19 20 61422 2 19 2...
output:
-1 4959570
result:
ok 2 number(s): "-1 4959570"
Test #29:
score: 0
Accepted
time: 2ms
memory: 8140kb
input:
50 10 1 2 12734 10 2 3 27338 10 3 4 15936 10 4 5 30198 9 5 6 59960 9 6 7 14693 9 7 8 67702 9 8 9 63361 8 9 10 76125 7 10 11 77894 6 11 12 6787 6 12 13 12390 5 13 14 30868 9 13 26 57318 10 13 27 6991 6 14 15 14783 9 15 16 15431 7 16 17 31742 5 17 18 73924 6 17 30 98533 5 18 19 48352 6 18 31 40456 4 1...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 10817378
result:
ok 10 numbers
Test #30:
score: 0
Accepted
time: 0ms
memory: 8032kb
input:
50 50 1 2 8473 43 2 3 71048 38 3 4 54201 37 4 5 49351 35 5 6 33457 32 6 7 70017 30 7 8 41296 26 8 9 51812 21 9 10 508 17 10 11 46766 14 11 12 69582 14 12 13 41682 13 13 14 52211 17 13 28 3255 20 14 15 1549 17 15 16 93912 15 16 17 6064 14 17 18 60581 10 18 19 53797 12 18 26 99776 15 18 27 12746 14 18...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 30524399 30524399 30524399 30524399 30524399 30524399 30524399 30524399
result:
ok 50 numbers
Test #31:
score: 0
Accepted
time: 0ms
memory: 8112kb
input:
50 50 1 2 67321 42 2 3 26698 37 3 4 85929 35 4 5 97341 29 5 6 64650 27 6 7 35137 23 7 8 75283 21 8 9 57707 21 9 10 86844 20 10 11 3992 16 11 12 92196 13 12 13 5032 12 13 14 65067 12 14 15 3646 10 14 26 89560 18 15 16 3394 10 16 17 37812 15 16 27 10336 14 16 29 19308 13 17 18 54566 13 18 19 56404 10 ...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 39756081 39756081 39756081 39756081 39756081 39756081 39756081 39756081 39756081
result:
ok 50 numbers
Test #32:
score: 0
Accepted
time: 2ms
memory: 8196kb
input:
50 50 1 2 85385 41 2 3 77845 38 3 4 33944 32 4 5 38550 28 5 6 32835 24 6 7 24247 17 7 8 69157 15 8 9 51497 14 9 10 27936 13 10 11 381 12 11 12 16281 10 12 13 59050 10 13 14 32472 8 14 15 5164 7 15 16 50121 7 16 17 94207 8 16 29 87325 11 17 18 53384 6 17 32 54346 10 18 19 11948 6 18 30 95782 8 19 20 ...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 28676009 28676009 28676009 28676009 28676009 28676009 28676009 28676009 28676009 28676009
result:
ok 50 numbers
Test #33:
score: 0
Accepted
time: 0ms
memory: 8056kb
input:
50 50 1 2 97493 43 2 3 93134 39 3 4 71163 37 4 5 74205 37 5 6 93088 31 6 7 63629 28 7 8 1505 26 8 9 79134 23 9 10 52544 22 10 11 146 19 11 12 15842 19 11 26 89715 30 12 13 85906 19 13 14 65003 19 14 15 92124 19 15 16 13802 17 15 28 65107 20 16 17 26724 17 17 18 24108 19 17 30 66288 18 18 19 5760 15 ...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 56153920 56153920 56153920 56153920 56153920 56153920 56153920 56153920
result:
ok 50 numbers
Test #34:
score: 0
Accepted
time: 2ms
memory: 8032kb
input:
50 50 1 2 56938 42 2 3 59402 35 3 4 69840 30 4 5 43455 27 5 6 85737 27 6 7 57562 24 7 8 99187 22 8 9 77083 21 9 10 85265 19 10 11 52260 17 11 12 70886 14 12 13 79327 13 13 14 41214 12 14 15 27029 10 15 16 16710 10 16 17 77240 12 16 26 32047 15 16 27 73115 15 17 18 82223 11 18 19 99445 11 19 20 85248...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 40563245 40563245 40563245 40563245 40563245 40563245 40563245 40563245 40563245
result:
ok 50 numbers
Test #35:
score: 0
Accepted
time: 2ms
memory: 8144kb
input:
50 50 1 2 98510 46 2 3 93965 46 3 4 41929 44 4 5 19848 42 5 6 68598 39 6 7 70832 35 7 8 83776 33 8 9 33801 31 9 10 77350 27 10 11 55278 26 11 12 32635 24 12 13 89355 22 13 14 98727 21 14 15 38114 23 14 29 88163 36 15 16 26791 34 15 26 14880 35 15 27 18787 34 16 17 38977 32 17 18 56052 30 18 19 10461...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 86355759 86355759 86355759 86355759 86355759
result:
ok 50 numbers
Test #36:
score: 0
Accepted
time: 0ms
memory: 7888kb
input:
50 50 1 2 76463 46 2 3 31143 44 3 4 76369 41 4 5 15357 40 5 6 21881 37 6 7 70117 36 7 8 23175 35 8 9 41791 34 9 10 43869 32 10 11 50610 31 11 12 65893 27 12 13 52967 27 12 27 44201 50 13 14 89804 26 14 15 89880 22 15 16 65330 22 16 17 8584 24 16 28 51503 40 16 30 36335 36 17 18 4796 22 18 19 83241 2...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 70604858 70604858 70604858 70604858 70604858
result:
ok 50 numbers
Test #37:
score: 0
Accepted
time: 0ms
memory: 8148kb
input:
50 50 1 2 24405 44 2 3 62219 39 3 4 72335 37 4 5 15808 34 5 6 71844 34 6 7 3009 32 7 8 62543 31 8 9 87213 30 9 10 1651 29 10 11 29640 26 11 12 72054 25 12 13 59995 30 12 26 1153 43 13 14 50864 26 14 15 37921 28 14 28 88374 28 15 16 77545 24 16 17 15843 20 17 18 3630 21 17 29 15181 27 18 19 10 21 18 ...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 56132191 56132191 56132191 56132191 56132191 56132191 56132191
result:
ok 50 numbers
Test #38:
score: 0
Accepted
time: 2ms
memory: 7956kb
input:
50 50 1 2 80463 50 2 3 52642 46 3 4 60998 41 4 5 82093 41 5 6 35487 34 6 7 26785 31 7 8 40155 28 8 9 19547 27 9 10 68628 21 10 11 14443 16 11 12 64052 17 12 13 13207 17 13 14 89753 17 13 28 5337 19 14 15 96152 12 14 29 39804 20 15 16 18519 15 16 17 43395 14 16 27 50929 21 17 18 16195 17 17 31 40822 ...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 30531572 30531572 30531572 30531572 30531572 30531572 30531572 30531572 30531572 30531572
result:
ok 50 numbers
Test #39:
score: 0
Accepted
time: 2ms
memory: 8132kb
input:
50 50 1 2 86377 46 2 3 39502 40 3 4 50121 30 4 5 2762 27 5 6 90187 28 6 7 56040 27 7 8 42193 20 8 9 12189 19 9 10 26945 20 10 11 96194 14 11 12 62631 18 12 13 92402 12 13 14 96849 14 14 15 41552 13 15 16 22385 15 15 26 18815 22 16 17 93023 14 16 31 89063 18 17 18 35476 12 17 27 79383 16 18 19 67023 ...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 29089524 29089524 29089524 29089524 29089524 29089524 29089524 29089524 29089524 29089524
result:
ok 50 numbers
Test #40:
score: 0
Accepted
time: 0ms
memory: 8352kb
input:
50 50 1 2 99844 51 2 3 73364 45 3 4 27309 33 4 5 33862 29 5 6 3739 24 6 7 78082 17 7 8 84577 23 8 9 29919 23 9 10 96344 15 10 11 51253 20 11 12 32795 11 12 13 66178 10 13 14 83625 8 14 15 49160 13 14 27 51079 12 15 16 91341 18 15 26 49339 17 15 29 4602 15 16 17 2706 12 17 18 95293 8 17 28 12923 17 1...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 21645025 21645025 21645025 21645025 21645025 21645025 21645025 21645025
result:
ok 50 numbers
Test #41:
score: 0
Accepted
time: 0ms
memory: 8148kb
input:
50 50 1 2 77698 46 2 3 96016 46 3 4 43785 41 4 5 86726 38 5 6 63069 34 6 7 63396 30 7 8 51770 28 8 9 60419 20 9 10 63858 20 10 11 23436 15 11 12 51818 13 12 13 91135 14 13 14 33979 13 14 15 143 12 15 16 79186 9 15 27 33604 14 16 17 43185 11 17 18 79288 8 17 26 7628 16 18 19 85146 10 18 33 96908 13 1...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 30019114 30019114 30019114 30019114 30019114 30019114 30019114 30019114 30019114 30019114
result:
ok 50 numbers
Test #42:
score: 0
Accepted
time: 0ms
memory: 8084kb
input:
50 50 1 2 20167 43 2 3 53262 40 3 4 39931 42 4 5 37885 37 5 6 75474 33 6 7 22855 34 7 8 74049 29 8 9 28188 27 9 10 65682 22 10 11 26686 17 11 12 1730 11 12 13 88870 13 13 14 29953 12 14 15 73596 11 15 16 26037 5 15 29 58466 15 15 30 44952 14 16 17 14090 6 17 18 55989 5 18 19 29084 10 18 26 72367 12 ...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 19378390 19378390 19378390 19378390 19378390 19378390 19378390 19378390 19378390 19378390 19378390 19378390
result:
ok 50 numbers
Test #43:
score: 0
Accepted
time: 2ms
memory: 8196kb
input:
50 50 1 2 12142 49 2 3 30573 41 3 4 39885 35 4 5 8853 35 5 6 89261 34 6 7 91249 28 7 8 55843 32 8 9 71878 20 9 10 59528 19 10 11 76319 16 11 12 41015 11 12 13 41003 15 13 14 87699 19 14 15 97980 19 15 16 46558 21 15 30 41546 11 16 17 28227 6 17 18 18671 8 17 26 30765 17 17 31 84553 12 18 19 70893 12...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 20575841 20575841 20575841 20575841 20575841 20575841
result:
ok 50 numbers
Test #44:
score: 0
Accepted
time: 2ms
memory: 8144kb
input:
50 50 1 2 10901 52 2 3 94622 45 3 4 26574 36 4 5 24672 35 5 6 26633 34 6 7 36144 30 7 8 32927 22 8 9 50330 21 9 10 56016 24 10 11 55152 26 11 12 12766 23 11 26 95845 33 12 13 82159 22 13 14 8531 20 13 27 84591 29 14 15 12790 29 14 29 79499 18 15 16 52143 20 16 17 91896 18 17 18 56194 25 17 32 37162 ...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 27788632 27788632 27788632 27788632 27788632 27788632 27788632 27788632
result:
ok 50 numbers
Test #45:
score: 0
Accepted
time: 0ms
memory: 8056kb
input:
50 50 1 2 5193 55 2 3 99911 42 3 4 70425 38 4 5 31958 29 5 6 28031 30 6 7 26187 30 7 8 18786 26 8 9 68615 19 9 10 45881 22 10 11 30651 16 11 12 24499 19 12 13 22832 14 12 26 9776 30 13 14 84000 21 14 15 33541 18 15 16 2331 17 15 27 3036 16 16 17 18787 16 17 18 79602 12 18 19 72112 16 19 20 44759 10 ...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 20314715 20314715 20314715 20314715 20314715 20314715 20314715 20314715 20314715 20314715
result:
ok 50 numbers
Test #46:
score: 0
Accepted
time: 1ms
memory: 4280kb
input:
50 50 1 2 69735 91 1 3 67629 91 1 4 64395 97 1 5 57674 98 1 6 22880 94 1 7 44243 95 1 8 5977 92 1 9 79874 91 1 10 28888 93 1 11 16709 84 1 12 30710 92 1 13 66175 98 1 14 90591 92 1 15 72133 93 1 16 64499 93 1 17 97794 94 1 18 55719 97 1 19 64532 91 1 20 88034 89 1 21 71181 94 1 22 56480 88 1 23 9681...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 230913673
result:
ok 50 numbers
Test #47:
score: 0
Accepted
time: 1ms
memory: 4236kb
input:
50 50 1 2 18560 97 1 3 58108 96 1 4 24196 96 1 5 52010 87 1 6 81513 93 1 7 84070 94 1 8 98678 98 1 9 17889 98 1 10 90085 96 1 11 9886 98 1 12 6373 97 1 13 41975 98 1 14 77175 98 1 15 92566 91 1 16 43026 97 1 17 73277 95 1 18 16287 89 1 19 10238 95 1 20 63998 102 1 21 55652 93 1 22 54335 92 1 23 7469...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 240713938 240616501
result:
ok 50 numbers
Test #48:
score: 0
Accepted
time: 0ms
memory: 4672kb
input:
50 50 1 2 65214 68 1 3 81530 86 1 4 15657 87 1 5 44143 88 2 6 21706 86 2 7 10019 90 2 8 35299 90 2 9 98504 87 2 10 97049 89 3 11 52918 86 3 12 56531 89 3 13 74630 92 3 14 19967 85 3 15 40632 87 4 16 64973 83 4 17 73838 92 4 18 66291 86 4 19 65935 86 4 20 45191 82 5 21 89637 88 5 22 29800 84 5 23 798...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 236485086 236241924 235998762
result:
ok 50 numbers
Test #49:
score: 0
Accepted
time: 1ms
memory: 4372kb
input:
50 50 1 2 99276 84 1 3 73308 83 1 4 82748 85 1 5 89983 88 1 6 54934 93 1 7 39985 89 1 8 15266 90 1 9 22213 93 1 10 56030 97 2 11 86209 89 2 12 87543 91 2 13 44224 91 2 14 53076 89 2 15 6318 89 2 16 97675 92 2 17 59919 85 2 18 92202 89 2 19 3289 82 2 20 89391 89 3 21 48342 93 3 22 9584 91 3 23 12547 ...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 242594441 242397490 242200539
result:
ok 50 numbers
Test #50:
score: -100
Runtime Error
input:
10000 10000 1 2 199194692 986 2 3 923159214 862 2 4 548448431 11785 2 5 196017345 3828 4 6 617436340 13406 3 7 939115752 7521 1 8 378387969 13234 2 9 930724711 19784 6 10 235683367 1335 9 11 715849733 17244 9 12 646199534 15253 8 13 130696451 12121 5 14 532284400 3526 6 15 105642585 18051 14 16 8220...