QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#668037#8938. Crawling on a TreeYansuan_HClWA 3ms9184kbC++202.7kb2024-10-23 10:51:032024-10-23 10:51:04

Judging History

This is the latest submission verdict.

  • [2024-10-23 10:51:04]
  • Judged
  • Verdict: WA
  • Time: 3ms
  • Memory: 9184kb
  • [2024-10-23 10:51:03]
  • Submitted

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;
const ll inf = 4e18;
int n, m, c[N], cx[N];

struct info {
	int l, r;
	array<ll, N> v;
};
void mkv(info &f, info &g, info &h) {
	h.v.fill(inf); h.l = min(m + 1, f.l + g.l); h.r = min(m, f.r + g.r);
	
	U (i, f.l, f.r) U (j, g.l, g.r) if (i + j <= m)
		h.v[i + j] = min(h.v[i + j], f.v[i] + g.v[j]);
	U (i, h.l + 1, h.r - 1) {
		assert(h.v[i] - h.v[i - 1] <= h.v[i + 1] - h.v[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 {};
		x.l = 0, x.r = m;
		
		dp(v, u, w, k, x);
		mkv(f, x, y);
		f = y;
	}
	U (y, f.l + 1, f.r) f.v[y] = min(f.v[y], f.v[y - 1]); // 留在 u
	
	int lb = m + 1, rb = -1;
	U (y, f.l, f.r) {
		int x = max(cx[u], y);
		if (2 * x - y > fk) rb = y;
		else break;
	}
	D (y, f.r, f.l) {
		int x = max(cx[u], y);
		if (2 * x - y > fk) lb = y;
		else break;
	}
	if (rb < lb) {
		assert(rb + 1 < lb);
		f.l = max(f.l, rb + 1);
		f.r = min(f.r, lb - 1);
	} else {
		f.l = m + 1, f.r = m;
	}
	
	U (y, f.l, f.r) {
		int x = max(cx[u], y);
		f.v[y] += (2 * x - y) * fw;
	}
}

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 {}; f.l = 0, f.r = m;
	dp(1, 0, 0, 2e9, f);
	array<ll, N> h; h.fill(inf);
	
	U (y, f.l, f.r) {
		int x = max(cx[1], y);
		h[x] = min(h[x], f.v[y]);
	}
	U (x, 1, m) {
		h[x] = min(h[x - 1], h[x]);
		if (x < cx[1] || h[x] >= inf)
			puts("-1");
		else
			printf("%lld\n", h[x]);
	}
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 4384kb

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: 4208kb

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: 4216kb

input:

2 1
2 1 1 1
1

output:

1

result:

ok 1 number(s): "1"

Test #4:

score: 0
Accepted
time: 1ms
memory: 4104kb

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: 4376kb

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: 4312kb

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: 7724kb

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: 8784kb

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: 3ms
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: 8924kb

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: 0ms
memory: 9068kb

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: 8940kb

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: 8556kb

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: 3ms
memory: 9140kb

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: 3ms
memory: 8820kb

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: 8676kb

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: 3ms
memory: 9040kb

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: 0ms
memory: 9000kb

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: 8692kb

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: 3ms
memory: 9008kb

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: 3ms
memory: 8924kb

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: 3ms
memory: 8980kb

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: 9004kb

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: 9184kb

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: 0ms
memory: 8784kb

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: 0ms
memory: 8944kb

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: 8196kb

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: -100
Wrong Answer
time: 0ms
memory: 7852kb

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
-1

result:

wrong answer 2nd numbers differ - expected: '4959570', found: '-1'