QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#572800#5208. Jumbled Trees251SecWA 26ms13032kbC++143.0kb2024-09-18 16:26:302024-09-18 16:26:31

Judging History

你现在查看的是最新测评结果

  • [2024-09-18 16:26:31]
  • 评测
  • 测评结果:WA
  • 用时:26ms
  • 内存:13032kb
  • [2024-09-18 16:26:30]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, m, P;
ll QPow(ll a, ll b) {
	ll res = 1;
	for (; b; b >>= 1, a = a * a % P) if (b & 1) res = res * a % P;
	return res; 
}
int opC;
string ope;
struct Edge {
	int v, nxt;
} e[2005];
ll w[1005];
int head[505], len = 1, dep[505], prt[505], pid[505];
void Insert(int u, int v) {
	e[++len] = { v, head[u] };
	head[u] = len;
}
bool onT[1005];
int tE[505], tC;
namespace T {
	struct Edge {
		int v, nxt, x, y;
	} e[2005];
	int head[1005], len, fa[1005];
	void Init() {
		for (int i = 1; i <= m; i++) fa[i] = i;
	}
	int F(int u) { return fa[u] == u ? u : fa[u] = F(fa[u]); }
	void Insert(int u, int v) {
		e[++len] = { v, head[u] };
		head[u] = len;
	}
	void InsertD(int u, int v) {
		if (F(u) == F(v)) return;
		Insert(u, v), Insert(v, u);
		fa[F(u)] = F(v);
	}
	void Oper(int u, int v, ll w) {
		if (!onT[u]) {
			swap(u, v), w = (P - w) % P;
		}
		::w[v] = (::w[v] - w + P) % P;
		::w[u] = (::w[u] + w + P) % P;
		opC++;
		ope += to_string((P - w % P) % P) + " ";
		for (int i = 1; i <= tC; i++) ope += to_string(tE[i]) + " \n"[i == tC];
		opC++;
		ope += to_string(w % P) + " ";
		for (int i = 1; i <= tC; i++) ope += to_string(tE[i] == u ? v : tE[i]) + " \n"[i == tC];
	}
	bool vis[1005];
	ll sw;
	int se;
	void DFS1(int u, int fa) {
		vis[u] = true;
		(se += onT[u]) % P;
		(sw += w[u]) %= P;
		for (int i = head[u]; i; i = e[i].nxt) {
			int v = e[i].v;
			if (v == fa) continue;
			DFS1(v, u);
		}
	}
	void DFS2(int u, int fa) {
		vis[u] = true;
		for (int i = head[u]; i; i = e[i].nxt) {
			int v = e[i].v;
			if (v == fa) continue;
			DFS2(v, u);
			Oper(u, v, w[v]);
		}
	}
	void Solve() {
		ll opw = -1;
		for (int i = 1; i <= m; i++) {
			if (!vis[i]) {
				sw = se = 0;
				DFS1(i, 0);
				if (!se && !sw) continue;
				ll cw = sw * QPow(se, P - 2) % P;
				if (opw == -1) opw = cw;
				else if (opw != cw) return puts("-1"), void();
			}
		}
		if (opw >= 0) {
			opC++;
			for (int i = 1; i <= tC; i++) w[tE[i]] = (w[tE[i]] - opw % P + P) % P;
			ope += to_string(opw) + " ";
			for (int i = 1; i <= tC; i++) ope += to_string(tE[i]) + " \n"[i == tC];
		}
		memset(vis, 0, sizeof(vis));
		for (int i = 1; i <= m; i++) {
			if (!vis[i]) {
				DFS2(i, 0);
				if (w[i]) {
					puts("-1");
					return;
				}
			}
		}
		printf("%d\n%s", opC, ope.c_str());
	}
}
bool vis[505];
void AddE(int u, int v, int x) {
	while (u != v) {
		if (dep[u] < dep[v]) swap(u, v);
		T::InsertD(pid[u], x);
		u = prt[u];
	}
}
void DFS(int u, int f) {
	vis[u] = true;
	for (int i = head[u]; i; i = e[i].nxt) {
		if (i == (f ^ 1)) continue;
		int v = e[i].v;
		if (vis[v]) AddE(u, v, i >> 1);
		else {
			tE[++tC] = (i >> 1);
			dep[v] = dep[u] + 1;
			prt[v] = u, pid[v] = i >> 1;
			onT[i >> 1] = true;
			DFS(v, i);
		}
	}
}
int main() {
	scanf("%d%d%d", &n, &m, &P);
	T::Init();
	for (int i = 1, u, v; i <= m; i++) {
		scanf("%d%d%lld", &u, &v, w + i);
		Insert(u, v), Insert(v, u);
	}
	DFS(1, 0);
	T::Solve();
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 4144kb

input:

3 3 101
1 2 30
2 3 40
3 1 50

output:

5
60 3 2
91 3 2
10 1 2
81 3 2
20 3 1

result:

ok Participant found an answer (5 trees) and jury found an answer (5 trees)

Test #2:

score: 0
Accepted
time: 0ms
memory: 3744kb

input:

2 2 37
1 2 8
1 2 15

output:

3
23 2
29 2
8 1

result:

ok Participant found an answer (3 trees) and jury found an answer (3 trees)

Test #3:

score: 0
Accepted
time: 0ms
memory: 3780kb

input:

5 4 5
1 3 1
2 3 2
2 5 3
4 1 4

output:

-1

result:

ok Both jury and participant did not find an answer

Test #4:

score: 0
Accepted
time: 0ms
memory: 3800kb

input:

10 15 997
4 3 459
9 7 94
9 8 767
10 2 877
5 8 258
3 4 166
8 5 621
8 10 619
9 1 316
10 5 516
3 10 125
1 7 961
3 6 500
4 10 976
3 4 842

output:

-1

result:

ok Both jury and participant did not find an answer

Test #5:

score: 0
Accepted
time: 0ms
memory: 3832kb

input:

20 30 9973
1 10 696
3 8 2905
12 7 6609
20 10 1962
11 9 8430
19 2 412
6 3 6936
19 7 9113
14 15 5635
15 7 1770
13 10 3182
3 16 2625
17 1 7387
11 5 3700
9 15 1048
2 3 7717
12 10 8625
7 13 8141
5 14 2245
6 4 2819
18 19 8709
18 5 6191
17 10 7606
9 20 8626
17 4 8848
4 13 1073
10 8 2277
14 2 7714
11 8 5318...

output:

59
9375 13 25 26 18 10 15 24 4 27 29 14 30 12 16 28 6 21 7 17
7985 13 25 26 18 10 15 24 4 27 29 14 30 12 16 28 6 21 7 17
1988 1 25 26 18 10 15 24 4 27 29 14 30 12 16 28 6 21 7 17
6791 13 25 26 18 10 15 24 4 27 29 14 30 12 16 28 6 21 7 17
3182 13 25 26 18 10 15 24 11 27 29 14 30 12 16 28 6 21 7 17
92...

result:

ok Participant found an answer (59 trees) and jury found an answer (59 trees)

Test #6:

score: 0
Accepted
time: 0ms
memory: 3640kb

input:

50 80 99991
6 5 67664
39 4 74944
11 9 13035
13 48 81979
40 20 57943
20 31 72081
1 6 39307
48 39 3550
28 48 41071
18 28 42935
37 32 7538
37 29 3815
50 37 88043
38 41 7283
40 26 66278
37 34 60696
47 19 80875
4 26 67
20 32 91858
39 24 83485
45 25 12241
48 46 61691
37 44 47541
39 40 70034
37 42 25006
27...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #7:

score: 0
Accepted
time: 0ms
memory: 4036kb

input:

100 150 999983
84 10 999545
69 48 930138
48 13 303468
36 6 668122
91 84 115623
62 71 59711
12 37 749281
86 49 281976
26 46 624831
91 8 450475
92 55 460900
50 63 513056
72 2 477622
26 96 11359
31 82 953946
6 71 406339
24 7 177090
70 4 67359
31 39 795565
47 32 407459
26 35 760698
22 37 508175
8 93 612...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #8:

score: 0
Accepted
time: 0ms
memory: 4036kb

input:

200 250 9999991
170 185 3242943
70 17 6083198
137 55 4000889
15 171 1113989
108 65 7988488
192 37 8812990
53 143 8707264
80 180 2504807
55 163 2706048
67 64 6210980
87 165 7693967
155 122 8550804
56 99 7228534
114 138 7047731
190 196 6684929
86 197 8866886
38 195 6717874
112 133 7257617
160 104 3210...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #9:

score: 0
Accepted
time: 0ms
memory: 3780kb

input:

500 600 99999989
265 416 47066772
354 266 16969437
195 415 7917612
354 136 43128175
163 191 58723996
144 84 65835385
157 45 94124747
232 441 17509499
70 397 64101208
223 387 7043647
320 47 84970673
100 2 87310855
87 131 75042257
101 391 27645446
79 26 68547739
390 185 92142961
257 15 80922292
276 48...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #10:

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

input:

500 700 99999989
250 2 71289880
454 447 70661327
328 253 57519343
11 201 67456781
294 99 23392419
215 322 61059212
411 389 69899684
488 429 89579827
437 79 60564061
413 380 34922641
477 372 14858185
156 44 3101349
88 8 52225146
115 26 8582010
171 237 33206748
237 495 31192017
146 32 62712576
209 352...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #11:

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

input:

500 800 99999989
258 304 1237432
159 152 6684056
8 47 64155938
436 265 83092505
204 302 3892712
142 302 77925167
37 15 20298972
202 395 35856655
284 260 96812598
365 172 48834835
196 101 64871741
174 45 37729972
302 206 90932677
305 275 27712443
443 157 81820535
16 248 22708463
461 479 64749118
105 ...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #12:

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

input:

500 900 99999989
122 188 44796717
73 121 56798468
334 358 95823235
485 453 96779071
209 391 45946094
332 168 91056077
481 483 81268636
148 393 25213027
107 214 99281713
493 46 61525618
472 355 74320568
258 482 99615552
159 393 20311839
411 121 5207095
20 131 65269699
45 339 51772607
195 292 64556504...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #13:

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

input:

500 1000 99999989
75 20 25003980
292 19 89418683
353 246 74910681
183 201 97535184
254 421 50614221
15 396 86624029
82 13 67776336
86 70 62843451
279 3 55801636
29 425 30024776
176 243 16631048
498 363 77415492
55 305 80862521
213 110 30693079
432 358 99667002
201 30 44433122
97 203 16284993
118 490...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #14:

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

input:

500 499 999999937
287 228 350409600
392 107 350409600
458 22 350409600
362 425 350409600
368 136 350409600
364 71 350409600
211 265 350409600
167 116 350409600
195 353 350409600
489 477 350409600
380 85 350409600
281 15 350409600
263 247 350409600
453 122 350409600
104 187 350409600
331 223 35040960...

output:

1
350409600 267 227 451 419 333 159 437 375 345 156 328 323 140 489 296 239 23 20 327 247 442 236 94 372 284 145 482 373 340 393 386 361 268 225 139 411 255 462 403 150 381 217 102 114 10 177 202 106 49 279 332 200 111 51 390 400 65 416 256 478 204 344 158 321 18 257 229 143 76 207 121 16 48 471 243...

result:

ok Participant found an answer (1 trees) and jury found an answer (1 trees)

Test #15:

score: 0
Accepted
time: 4ms
memory: 4004kb

input:

500 510 999999937
417 280 770450784
207 303 770450784
472 396 770450784
345 191 964169440
164 67 770450784
492 302 770450784
5 71 770450784
386 22 770450784
77 25 487491058
430 467 770450784
148 95 770450784
288 215 770450784
55 451 10190666
215 69 770450784
267 195 770450784
487 283 770450784
435 3...

output:

257
770450784 464 381 382 476 337 207 152 77 209 71 276 49 454 367 315 311 327 111 266 79 34 395 184 447 37 465 144 102 217 230 6 409 69 283 350 417 321 280 362 101 107 94 340 312 401 242 495 402 5 149 224 226 270 408 247 93 257 105 314 322 435 269 437 303 264 21 356 318 475 96 432 406 151 274 419 1...

result:

ok Participant found an answer (257 trees) and jury found an answer (257 trees)

Test #16:

score: 0
Accepted
time: 6ms
memory: 4320kb

input:

500 525 999999937
439 54 982774700
417 443 87702331
21 82 982774700
39 477 982774700
363 493 982774700
500 161 982774700
86 44 982774700
312 47 982774700
120 282 982774700
224 254 670954686
268 311 59221562
216 242 982774700
16 256 505585800
448 102 982774700
362 295 555877345
76 210 819076841
53 24...

output:

395
982774700 511 404 188 171 35 398 237 449 353 510 256 160 481 460 423 130 524 281 508 128 305 264 471 370 363 179 147 25 492 338 323 265 153 230 176 271 487 405 218 63 143 10 341 208 108 402 457 173 273 469 248 407 219 51 475 431 462 414 253 516 204 100 175 266 337 448 287 504 142 166 261 436 495...

result:

ok Participant found an answer (395 trees) and jury found an answer (395 trees)

Test #17:

score: 0
Accepted
time: 3ms
memory: 5380kb

input:

500 550 999999937
478 408 544946602
494 234 544946602
118 11 544946602
497 38 435997116
193 371 493919798
252 238 826125135
69 229 683109191
300 159 544946602
328 102 302951499
37 227 568031903
347 13 544946602
111 375 624947749
291 447 544946602
5 140 544946602
250 41 544946602
387 202 544946602
38...

output:

617
544946602 550 244 418 478 435 508 107 159 78 547 517 384 281 355 483 67 492 532 37 337 510 442 491 65 484 479 438 304 300 518 441 451 205 367 388 38 344 312 161 379 497 277 129 191 465 142 326 448 500 154 316 419 125 299 258 47 122 230 406 334 199 400 267 403 285 360 251 271 265 22 391 499 530 4...

result:

ok Participant found an answer (617 trees) and jury found an answer (617 trees)

Test #18:

score: 0
Accepted
time: 11ms
memory: 5292kb

input:

500 600 999999937
265 416 960325147
354 266 501849515
195 415 308033318
354 136 658703469
163 191 792878874
144 84 388345161
157 45 308033318
232 441 175503107
70 397 520297316
223 387 650583946
320 47 790017725
100 2 477058566
87 131 953737746
101 391 308033318
79 26 941025744
390 185 519333525
257...

output:

811
308033318 152 597 429 542 528 253 490 326 515 451 119 487 555 199 436 329 115 428 200 557 552 6 163 574 508 521 1 396 101 29 511 513 541 473 196 247 366 479 349 180 224 89 203 355 84 407 587 467 460 255 531 443 225 546 566 426 205 457 592 325 476 314 582 142 375 471 578 569 422 351 37 308 414 20...

result:

ok Participant found an answer (811 trees) and jury found an answer (811 trees)

Test #19:

score: 0
Accepted
time: 0ms
memory: 3920kb

input:

500 500 999999937
56 278 340955979
53 151 340955979
482 317 340955979
4 138 340955979
454 135 340955979
482 361 340955979
85 89 340955979
436 201 340955979
450 483 340955979
274 258 340955979
13 318 340955979
87 227 340955979
141 114 340955979
284 340 340955979
377 48 340955979
110 134 340955979
271...

output:

25
340955979 435 395 326 408 28 497 75 63 345 382 193 149 19 179 231 114 113 218 263 289 312 236 120 438 401 378 336 109 140 15 387 277 483 441 262 195 478 392 94 85 123 460 151 108 477 328 487 40 346 233 293 38 182 177 117 464 319 163 126 318 156 397 307 498 492 288 374 329 47 470 269 471 225 56 35...

result:

ok Participant found an answer (25 trees) and jury found an answer (25 trees)

Test #20:

score: 0
Accepted
time: 16ms
memory: 7208kb

input:

500 700 999999937
250 2 231570738
454 447 348559779
328 253 557290971
11 201 742990307
294 99 355194759
215 322 346919021
411 389 223497390
488 429 924302863
437 79 634119443
413 380 194151871
477 372 634119443
156 44 723189726
88 8 656811915
115 26 494639245
171 237 579262439
237 495 225519328
146 ...

output:

1213
634119443 681 70 132 577 442 633 530 655 213 424 405 326 578 645 612 129 447 599 626 688 321 102 438 318 630 242 348 59 506 313 610 370 638 494 247 399 592 664 450 431 491 16 650 640 315 635 412 671 641 570 518 415 662 277 347 426 689 246 607 475 603 509 581 257 541 441 550 323 411 594 539 423 ...

result:

ok Participant found an answer (1213 trees) and jury found an answer (1213 trees)

Test #21:

score: 0
Accepted
time: 18ms
memory: 8592kb

input:

500 800 999999937
258 304 583150933
159 152 864655622
8 47 904254153
436 265 649209189
204 302 999927615
142 302 437142821
37 15 886997658
202 395 176364113
284 260 352132138
365 172 621577977
196 101 999803609
174 45 669960837
302 206 85008264
305 275 142531904
443 157 652057600
16 248 693746068
46...

output:

1441
649209189 788 714 428 696 613 655 538 287 728 182 718 495 637 753 789 512 762 569 601 746 688 306 685 794 318 338 475 570 555 120 568 571 371 773 375 513 782 157 670 578 667 713 719 352 464 791 408 778 590 502 467 652 647 284 784 419 315 732 103 621 435 423 577 691 693 678 197 451 740 177 689 5...

result:

ok Participant found an answer (1441 trees) and jury found an answer (1441 trees)

Test #22:

score: 0
Accepted
time: 21ms
memory: 8700kb

input:

500 900 999999937
122 188 437691348
73 121 296323029
334 358 25382116
485 453 71271129
209 391 955537437
332 168 58669489
481 483 584529141
148 393 88230539
107 214 706736962
493 46 995301637
472 355 754703158
258 482 416475555
159 393 775800573
411 121 458973126
20 131 939950122
45 339 247694299
19...

output:

1701
5612341 500 295 812 833 829 781 799 159 897 638 423 894 893 687 570 859 753 417 701 816 694 851 748 838 837 772 555 503 413 855 670 876 577 463 628 783 332 813 878 424 659 647 750 354 700 742 730 849 895 537 619 253 759 722 886 581 666 861 686 147 768 657 573 204 651 313 845 373 693 898 844 835...

result:

ok Participant found an answer (1701 trees) and jury found an answer (1701 trees)

Test #23:

score: 0
Accepted
time: 20ms
memory: 8940kb

input:

500 1000 999999937
75 20 857550680
292 19 110166270
353 246 190797204
183 201 150954990
254 421 374099649
15 396 837014574
82 13 802431102
86 70 422727121
279 3 985425226
29 425 742626961
176 243 571825134
498 363 619955816
55 305 797984505
213 110 284175102
432 358 702809990
201 30 28699854
97 203 ...

output:

1945
818970192 960 721 744 876 903 227 388 949 766 984 930 674 929 863 942 836 923 667 959 826 873 592 542 539 292 962 644 621 911 908 921 925 636 729 659 799 646 848 458 290 831 832 954 855 851 993 823 748 944 787 849 719 789 893 278 697 845 571 935 802 281 722 776 975 861 805 964 582 979 840 898 3...

result:

ok Participant found an answer (1945 trees) and jury found an answer (1945 trees)

Test #24:

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

input:

2 1000 999999937
1 2 411133720
1 2 776367809
1 2 801503481
2 1 289867740
2 1 639986495
2 1 555099841
2 1 689485994
1 2 108816472
2 1 877082404
1 2 123678957
2 1 880363745
1 2 770025482
1 2 593440355
2 1 899935259
1 2 157609551
2 1 373761515
2 1 2889558
2 1 629415436
1 2 684947844
1 2 485414377
2 1 4...

output:

1999
862815664 1000
223632128 1000
776367809 2
198496456 1000
801503481 3
710132197 1000
289867740 4
360013442 1000
639986495 5
444900096 1000
555099841 6
310513943 1000
689485994 7
891183465 1000
108816472 8
122917533 1000
877082404 9
876320980 1000
123678957 10
119636192 1000
880363745 11
22997445...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1999 trees)

Test #25:

score: 0
Accepted
time: 0ms
memory: 4316kb

input:

10 1000 999999937
3 6 178912852
10 3 875510731
6 7 212989905
7 5 974004463
1 10 620941502
7 5 600081434
9 1 394370115
1 3 776909504
5 1 370501286
6 8 726447186
10 5 267613208
2 9 467291795
9 2 938683115
5 4 729586694
2 7 214781199
6 5 414875992
9 6 60215552
3 6 901637793
7 9 907537612
7 8 42123063
1...

output:

1999
785709981 1000 990 986 996 997 998 993 999 904
98362144 1000 990 986 996 997 998 993 999 904
901637793 1000 990 18 996 997 998 993 999 904
686673402 1000 990 986 996 997 998 993 999 904
313326535 1000 990 22 996 997 998 993 999 904
695351990 1000 990 986 996 997 998 993 999 904
304647947 1000 9...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1999 trees)

Test #26:

score: 0
Accepted
time: 6ms
memory: 4392kb

input:

100 1000 999999937
27 22 577129898
47 76 383040531
44 49 252504590
66 46 764432363
75 76 827756718
80 35 275529478
95 9 886404040
55 97 184978304
11 72 641255171
65 95 394679645
37 8 171252921
35 39 277250820
62 10 745905336
97 76 208239094
16 34 460397322
74 28 465442229
89 95 979433574
70 86 67725...

output:

1999
127560596 990 994 899 857 983 992 955 999 868 930 986 645 935 858 982 890 966 889 973 959 703 849 995 957 917 978 976 962 987 808 920 956 993 958 878 946 898 852 964 689 928 614 972 997 912 1000 818 693 961 872 947 856 814 854 927 971 960 998 974 965 789 913 698 811 846 989 937 931 977 742 806 ...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1999 trees)

Test #27:

score: 0
Accepted
time: 20ms
memory: 7984kb

input:

498 1000 999999937
487 73 269543467
331 211 379519784
495 422 686973047
284 16 204129347
254 399 260794796
422 126 211993357
166 429 802536094
351 315 235479275
49 324 904476025
55 15 317387996
440 330 833475395
398 483 245510540
283 270 881075381
392 210 101464008
462 186 116907647
183 33 19696935
...

output:

1999
833785709 858 696 5 533 497 936 867 673 779 799 567 486 256 956 801 920 987 473 741 816 487 935 389 711 976 485 359 957 785 829 871 964 929 519 815 904 993 897 707 972 550 835 759 899 852 422 809 281 645 970 660 592 840 317 886 995 82 927 732 511 836 973 793 889 892 715 943 628 490 134 983 996 ...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1999 trees)

Test #28:

score: 0
Accepted
time: 26ms
memory: 11444kb

input:

499 1000 999999937
144 284 46025639
242 260 240568220
449 203 912275568
260 4 382100531
96 298 24757210
255 315 720292625
111 97 124002714
227 444 550413391
331 282 363023595
201 44 757190858
498 460 378149715
387 63 989403521
195 296 477597041
210 146 858766928
499 87 408290897
313 395 347050751
14...

output:

1999
767509726 910 970 530 999 844 857 708 141 889 630 830 593 412 1000 457 294 955 583 974 699 808 975 796 548 801 941 811 993 881 893 717 627 755 943 956 576 674 834 839 996 876 959 866 603 339 765 709 506 848 954 914 179 833 650 199 836 256 977 980 988 927 897 885 700 966 899 831 921 856 835 336 ...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1999 trees)

Test #29:

score: 0
Accepted
time: 21ms
memory: 11252kb

input:

500 1000 999999937
114 191 548698698
257 259 174101411
166 144 307067234
5 65 315189831
130 144 764747698
191 263 657349687
435 125 520510567
72 457 869051725
31 434 652697712
451 437 241147129
140 367 568108671
423 368 152200500
258 291 922031445
489 5 313644610
407 393 435155235
96 135 53577132
26...

output:

1997
912213077 956 340 905 814 529 911 787 784 760 988 881 215 844 942 585 748 838 690 110 853 998 871 512 426 979 421 48 793 906 367 816 944 627 621 444 977 817 959 897 987 862 274 609 928 658 921 939 620 870 496 856 779 952 635 696 967 943 569 890 666 954 882 265 745 5 819 727 759 996 577 656 232 ...

result:

ok Participant found an answer (1997 trees) and jury found an answer (1997 trees)

Test #30:

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

input:

10 1000 999999937
1 6 169017311
6 4 813438192
7 10 658256408
3 10 356519068
5 8 105814076
10 9 432666653
2 10 924273201
4 2 438838176
6 10 23105379
9 3 61095925
4 6 492672241
8 1 350092485
1 3 849557758
9 8 527128919
5 10 399172798
2 4 637109541
9 7 862381710
8 4 821851347
9 1 517530356
10 7 7723516...

output:

1999
880696294 1000 998 995 999 988 991 989 997 968
186561745 1000 998 995 999 988 991 989 997 968
813438192 1000 998 995 999 988 991 989 997 2
976894558 1000 998 995 999 988 991 989 997 968
23105379 1000 998 995 999 988 991 989 997 9
507327696 1000 998 995 999 988 991 989 997 968
492672241 1000 998...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1999 trees)

Test #31:

score: 0
Accepted
time: 3ms
memory: 4024kb

input:

50 1000 999999937
47 31 338993180
1 40 981131058
16 14 475599962
29 44 218651110
13 5 295788288
8 46 379702422
16 8 788369898
12 21 193552464
42 4 516953820
17 46 395588075
26 32 801052259
22 6 252241088
25 47 415361628
36 14 665366957
24 5 332323875
45 22 667496708
30 48 315574397
42 5 265997928
16...

output:

1999
759603654 993 973 982 994 956 981 938 997 988 992 969 957 964 998 929 989 947 999 1000 978 926 898 953 996 876 976 970 980 959 906 944 752 914 805 968 825 985 629 948 975 847 972 800 888 986 954 430 744 742
101819079 993 973 982 994 956 981 938 997 988 992 969 957 964 998 929 989 947 999 1000 9...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1999 trees)

Test #32:

score: 0
Accepted
time: 7ms
memory: 5368kb

input:

200 1000 999999937
155 193 467849083
56 59 535575167
97 22 494627324
200 72 960374690
51 200 104743381
129 37 403458202
99 138 318791385
164 7 513263543
116 185 858111714
169 165 864977405
87 135 479124746
164 37 463283980
98 150 827389077
111 2 519317068
8 84 554409749
51 11 688845859
164 39 370009...

output:

1999
433965560 989 904 998 700 997 977 973 984 703 725 753 843 689 854 780 746 930 809 834 967 584 926 944 940 922 943 759 979 768 694 975 961 792 983 770 874 972 892 918 745 962 951 890 881 828 908 1000 764 894 612 955 782 932 952 822 995 976 571 954 827 776 655 540 158 992 831 994 856 543 956 815 ...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1999 trees)

Test #33:

score: 0
Accepted
time: 0ms
memory: 4044kb

input:

499 1000 999999937
378 480 476231202
116 251 757524517
304 91 136773672
58 7 246393874
378 453 282946052
378 336 684803902
161 356 124374696
378 359 997729308
378 72 26684646
378 325 946203739
370 109 226216491
378 220 60777554
344 414 415380261
378 275 83199163
378 412 850660890
378 81 183620361
37...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #34:

score: 0
Accepted
time: 19ms
memory: 7788kb

input:

500 1000 999999937
430 117 111637665
85 228 267289407
478 304 819693771
477 99 161971830
69 242 172626708
397 448 755199536
397 165 556061372
397 309 705286456
397 71 441535487
397 242 463539465
451 64 63633665
397 333 435428974
441 202 512181674
397 217 566535010
397 241 556061372
390 384 444381502...

output:

1845
556061372 790 982 991 721 983 999 996 833 431 860 717 602 845 273 987 972 439 919 950 793 911 696 1000 824 362 766 914 838 953 503 817 385 941 610 63 863 816 228 300 963 922 841 651 791 579 162 487 87 923 669 522 798 775 475 957 703 336 45 944 573 482 724 958 332 644 928 786 68 884 494 85 144 3...

result:

ok Participant found an answer (1845 trees) and jury found an answer (1845 trees)

Test #35:

score: 0
Accepted
time: 2ms
memory: 4088kb

input:

20 1000 2
5 11 1
10 6 0
10 13 1
3 6 0
4 8 0
14 1 0
6 7 1
19 20 1
15 12 0
5 1 1
2 5 0
14 5 1
13 4 1
6 12 1
20 16 1
10 13 1
2 10 1
17 14 1
2 19 1
17 12 1
17 11 0
5 20 1
10 5 0
7 19 0
12 9 0
14 6 1
12 13 1
7 2 1
16 15 1
2 15 1
8 12 1
3 14 1
3 17 1
9 10 1
10 1 1
14 20 0
6 12 0
19 1 0
2 16 1
8 15 1
1 11 ...

output:

1999
0 981 1000 998 994 999 986 993 990 982 996 973 977 988 997 915 967 951 934 979
1 981 1000 998 994 999 986 993 990 982 996 973 977 988 997 915 967 951 934 979
1 981 1000 998 994 999 986 993 990 982 996 10 977 988 997 915 967 951 934 979
1 981 1000 998 994 999 986 993 990 982 996 973 977 988 997 ...

result:

ok Participant found an answer (1999 trees) and jury found an answer (972 trees)

Test #36:

score: 0
Accepted
time: 2ms
memory: 4032kb

input:

30 1000 3
23 24 0
4 9 1
13 14 1
19 21 1
21 10 1
16 18 2
23 5 0
17 9 0
2 19 1
2 17 0
30 27 0
26 25 1
10 30 1
8 10 1
29 9 2
28 29 2
26 12 1
10 13 2
11 20 0
23 5 0
23 22 1
25 5 2
19 9 1
17 6 0
19 8 0
17 28 0
6 21 1
8 9 2
11 4 1
15 21 1
18 16 0
23 15 0
11 18 2
4 15 2
10 9 2
6 5 2
19 7 1
24 16 1
14 1 2
4...

output:

1999
0 970 998 978 984 962 950 994 989 987 990 988 980 986 983 924 997 913 999 939 862 945 996 995 993 1000 711 804 379 985
0 970 998 978 984 962 950 994 989 987 990 988 980 986 983 924 997 913 999 939 862 945 996 995 993 1000 711 804 379 985
0 970 998 56 984 962 950 994 989 987 990 988 980 986 983 ...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1338 trees)

Test #37:

score: 0
Accepted
time: 3ms
memory: 4032kb

input:

40 1000 5
39 1 1
28 24 4
37 5 0
9 6 2
20 7 0
12 7 4
15 39 2
33 27 1
40 6 3
3 34 0
37 38 3
19 6 4
40 10 4
5 1 3
39 12 0
2 13 4
38 8 4
28 39 0
35 21 4
11 40 3
7 29 4
12 29 4
9 3 2
18 23 1
38 2 2
33 4 2
14 16 1
36 19 1
37 14 4
23 37 3
33 22 3
34 23 1
7 24 2
17 16 2
13 17 4
38 23 4
39 14 1
31 6 4
26 19 ...

output:

1999
3 978 972 977 995 986 996 999 991 987 966 839 973 981 927 993 971 998 980 983 887 919 948 976 970 960 997 946 940 925 982 942 900 725 849 807 951 381 1000 257
3 978 972 977 995 986 996 999 991 987 966 839 973 981 927 993 971 998 980 983 887 919 948 976 970 960 997 946 940 925 982 942 900 725 84...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1573 trees)

Test #38:

score: 0
Accepted
time: 0ms
memory: 4024kb

input:

44 1000 7
27 12 0
7 41 5
16 21 1
41 28 2
19 16 5
37 7 1
33 1 4
28 36 4
2 11 1
17 14 0
11 15 2
2 20 4
34 44 2
27 43 3
20 7 3
40 2 5
28 15 3
40 5 6
30 4 0
27 24 2
26 38 3
24 26 4
19 6 6
19 18 2
31 10 0
5 19 2
29 39 5
1 44 6
3 1 1
43 28 6
34 29 5
43 8 0
20 43 1
25 23 6
38 21 6
32 27 2
20 31 3
16 11 0
3...

output:

1999
4 999 996 989 993 929 990 956 974 973 987 986 934 976 991 978 998 988 966 979 992 997 963 1000 980 958 842 894 975 953 994 882 971 877 947 965 914 717 932 835 427 704 683 138
4 999 996 989 993 929 990 956 974 973 987 986 934 976 991 978 998 988 966 979 992 997 963 1000 980 958 842 894 975 953 9...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1705 trees)

Test #39:

score: 0
Accepted
time: 3ms
memory: 4316kb

input:

44 1000 11
27 12 6
7 41 9
16 21 5
41 28 5
19 16 5
37 7 5
33 1 0
28 36 1
2 11 10
17 14 4
11 15 3
2 20 6
34 44 9
27 43 6
20 7 1
40 2 8
28 15 8
40 5 5
30 4 1
27 24 6
26 38 6
24 26 5
19 6 4
19 18 1
31 10 8
5 19 0
29 39 7
1 44 6
3 1 4
43 28 6
34 29 6
43 8 1
20 43 8
25 23 8
38 21 9
32 27 4
20 31 1
16 11 3...

output:

1999
8 999 996 989 993 929 990 956 974 973 987 986 934 976 991 978 998 988 966 979 992 997 963 1000 980 958 842 894 975 953 994 882 971 877 947 965 914 717 932 835 427 704 683 138
5 999 996 989 993 929 990 956 974 973 987 986 934 976 991 978 998 988 966 979 992 997 963 1000 980 958 842 894 975 953 9...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1797 trees)

Test #40:

score: 0
Accepted
time: 0ms
memory: 4328kb

input:

45 1000 2
42 1 1
13 16 1
22 25 1
20 1 1
18 11 1
42 12 1
40 7 1
33 6 1
13 18 1
39 2 1
19 30 1
10 4 1
1 45 1
16 18 1
17 41 1
21 11 1
1 7 1
1 7 1
43 22 1
45 22 1
5 18 1
30 25 1
3 16 1
37 13 1
35 39 1
6 31 1
12 22 1
28 27 1
4 29 1
45 14 1
31 26 1
39 43 1
29 10 1
42 28 1
26 16 1
6 27 1
33 22 1
8 41 1
17 ...

output:

1999
0 982 965 974 998 927 991 995 988 968 987 993 979 951 1000 999 889 962 932 935 921 933 996 997 980 970 954 848 955 973 994 937 964 782 771 983 986 928 851 916 892 733 952 239 130
1 982 965 974 998 927 991 995 988 968 987 993 979 951 1000 999 889 962 932 935 921 933 996 997 980 970 954 848 955 9...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1934 trees)

Test #41:

score: 0
Accepted
time: 3ms
memory: 4032kb

input:

45 1000 3
42 1 1
13 16 2
22 25 2
20 1 0
18 11 2
42 12 2
40 7 2
33 6 1
13 18 2
39 2 1
19 30 1
10 4 2
1 45 2
16 18 1
17 41 1
21 11 2
1 7 1
1 7 1
43 22 1
45 22 2
5 18 1
30 25 1
3 16 1
37 13 1
35 39 2
6 31 1
12 22 2
28 27 2
4 29 2
45 14 1
31 26 2
39 43 2
29 10 2
42 28 1
26 16 1
6 27 1
33 22 1
8 41 2
17 ...

output:

1999
0 982 965 974 998 927 991 995 988 968 987 993 979 951 1000 999 889 962 932 935 921 933 996 997 980 970 954 848 955 973 994 937 964 782 771 983 986 928 851 916 892 733 952 239 130
1 982 965 974 998 927 991 995 988 968 987 993 979 951 1000 999 889 962 932 935 921 933 996 997 980 970 954 848 955 9...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1932 trees)

Test #42:

score: 0
Accepted
time: 3ms
memory: 4100kb

input:

45 1000 5
42 1 2
13 16 3
22 25 1
20 1 3
18 11 3
42 12 3
40 7 3
33 6 4
13 18 4
39 2 3
19 30 4
10 4 3
1 45 2
16 18 4
17 41 3
21 11 3
1 7 4
1 7 0
43 22 2
45 22 4
5 18 0
30 25 3
3 16 3
37 13 3
35 39 3
6 31 4
12 22 3
28 27 2
4 29 2
45 14 1
31 26 2
39 43 1
29 10 3
42 28 2
26 16 2
6 27 2
33 22 4
8 41 3
17 ...

output:

1999
2 982 965 974 998 927 991 995 988 968 987 993 979 951 1000 999 889 962 932 935 921 933 996 997 980 970 954 848 955 973 994 937 964 782 771 983 986 928 851 916 892 733 952 239 130
3 982 965 974 998 927 991 995 988 968 987 993 979 951 1000 999 889 962 932 935 921 933 996 997 980 970 954 848 955 9...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1951 trees)

Test #43:

score: 0
Accepted
time: 0ms
memory: 3972kb

input:

45 1000 7
42 1 2
13 16 3
22 25 3
20 1 2
18 11 1
42 12 1
40 7 5
33 6 2
13 18 5
39 2 3
19 30 3
10 4 4
1 45 2
16 18 1
17 41 1
21 11 1
1 7 2
1 7 1
43 22 1
45 22 3
5 18 3
30 25 2
3 16 5
37 13 1
35 39 4
6 31 6
12 22 4
28 27 5
4 29 4
45 14 2
31 26 3
39 43 6
29 10 2
42 28 4
26 16 5
6 27 3
33 22 4
8 41 1
17 ...

output:

1999
1 982 965 974 998 927 991 995 988 968 987 993 979 951 1000 999 889 962 932 935 921 933 996 997 980 970 954 848 955 973 994 937 964 782 771 983 986 928 851 916 892 733 952 239 130
5 982 965 974 998 927 991 995 988 968 987 993 979 951 1000 999 889 962 932 935 921 933 996 997 980 970 954 848 955 9...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1973 trees)

Test #44:

score: 0
Accepted
time: 0ms
memory: 4016kb

input:

45 1000 11
42 1 3
13 16 7
22 25 6
20 1 9
18 11 7
42 12 6
40 7 4
33 6 2
13 18 9
39 2 2
19 30 7
10 4 6
1 45 7
16 18 4
17 41 6
21 11 2
1 7 7
1 7 9
43 22 5
45 22 5
5 18 8
30 25 4
3 16 4
37 13 10
35 39 1
6 31 6
12 22 2
28 27 2
4 29 2
45 14 8
31 26 5
39 43 9
29 10 3
42 28 4
26 16 6
6 27 1
33 22 5
8 41 9
1...

output:

1999
0 982 965 974 998 927 991 995 988 968 987 993 979 951 1000 999 889 962 932 935 921 933 996 997 980 970 954 848 955 973 994 937 964 782 771 983 986 928 851 916 892 733 952 239 130
3 982 965 974 998 927 991 995 988 968 987 993 979 951 1000 999 889 962 932 935 921 933 996 997 980 970 954 848 955 9...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1988 trees)

Test #45:

score: 0
Accepted
time: 16ms
memory: 7636kb

input:

300 1000 579907477
85 20 501369811
170 209 398163019
213 60 24791654
230 141 419019038
262 23 307332223
76 171 6647363
82 256 472269037
83 216 98974104
212 171 206720550
270 276 515676983
204 176 51907464
144 112 422022914
118 82 330909459
205 132 575785329
169 140 55357686
40 286 145577484
126 212 ...

output:

1999
110715191 863 842 792 966 898 978 917 994 876 963 714 893 993 985 998 982 972 956 932 779 592 889 935 770 803 970 874 934 924 960 984 980 448 702 590 445 762 983 744 989 937 908 933 976 585 965 944 869 886 918 947 967 783 940 968 873 926 825 115 773 636 775 857 866 936 804 870 740 839 988 945 5...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1999 trees)

Test #46:

score: 0
Accepted
time: 13ms
memory: 8212kb

input:

350 1000 994747931
95 304 672543274
30 294 551111098
27 157 153882783
116 157 512439805
203 153 527241207
111 105 470017102
282 4 195745674
175 189 61279030
344 65 6080303
281 134 896176207
11 182 876685758
157 196 599267556
77 207 337469051
143 130 692521419
123 120 187503868
51 289 102179308
21 29...

output:

1999
863207455 712 824 580 828 469 998 646 938 865 442 795 815 750 974 940 831 678 623 871 683 571 846 880 852 675 980 997 894 654 784 964 870 994 936 944 856 787 845 943 487 645 952 565 972 878 570 887 373 986 917 720 918 574 684 727 995 900 954 448 905 942 910 829 821 632 868 733 844 971 779 679 9...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1999 trees)

Test #47:

score: 0
Accepted
time: 17ms
memory: 9040kb

input:

400 1000 967527623
227 62 593968166
174 386 319015265
11 386 37103681
254 362 439221071
301 329 441776182
166 272 228510487
215 140 164578119
281 268 87582058
356 247 835697768
66 197 929873194
333 289 477978462
156 48 669732140
300 106 567689265
229 125 128833926
380 331 286498390
357 58 4652963
17...

output:

1999
525945103 948 949 961 958 785 978 796 932 926 246 830 717 723 945 296 494 613 952 900 975 388 851 985 853 624 836 809 842 631 250 807 923 848 946 870 986 749 963 854 887 722 901 802 913 934 810 905 776 497 760 628 645 505 370 236 602 891 899 770 171 974 999 563 959 670 994 572 988 698 874 639 6...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1999 trees)

Test #48:

score: 0
Accepted
time: 19ms
memory: 8636kb

input:

450 1000 955153609
290 219 65970737
334 77 21598136
198 332 90012774
363 300 235053495
73 132 615775924
295 155 562343519
445 436 152605289
399 252 933967514
262 423 376322373
230 294 265251767
89 32 847945694
61 94 770914730
56 305 374807056
137 64 69327712
323 107 782667
209 274 944022728
23 21 23...

output:

1999
925119728 734 987 760 910 967 819 600 413 961 928 842 840 868 527 459 698 831 903 936 891 991 727 642 904 501 899 717 832 998 628 757 942 720 945 276 947 867 229 42 897 777 996 827 579 715 562 799 433 974 828 718 746 943 951 929 877 902 983 997 769 843 472 138 909 629 766 454 944 315 850 884 89...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1999 trees)

Test #49:

score: 0
Accepted
time: 23ms
memory: 13000kb

input:

499 1000 830842109
454 357 281331744
288 10 603468239
151 105 612741336
176 23 696034831
478 38 86151600
96 1 205849625
428 233 227676259
116 344 432314466
181 263 725179555
154 330 276902007
387 454 212244033
434 297 150051447
73 473 657304392
434 484 467362896
31 317 540666741
83 2 818695382
74 55...

output:

1999
829731142 150 954 825 765 356 929 997 935 712 526 887 972 709 780 343 984 902 998 918 937 418 752 606 639 445 220 922 896 865 814 614 838 860 822 732 26 677 692 758 914 738 873 784 992 927 831 852 336 928 794 965 813 803 776 989 473 952 290 859 708 589 667 959 744 917 155 693 938 818 840 979 98...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1999 trees)

Test #50:

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

input:

497 497 2
138 127 1
224 181 1
445 401 0
162 242 0
410 15 1
496 295 0
318 352 1
195 403 1
478 148 0
394 47 0
229 151 0
270 123 0
234 395 0
319 133 1
258 332 1
118 384 0
78 419 1
467 456 0
277 279 0
46 78 0
193 89 0
487 128 1
249 376 0
121 115 1
421 477 1
317 240 0
474 339 1
127 428 0
221 289 1
248 36...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #51:

score: 0
Accepted
time: 0ms
memory: 3672kb

input:

497 497 2
472 43 1
217 85 1
366 196 0
223 301 0
68 25 1
72 115 1
286 74 0
175 122 1
487 129 0
46 54 0
477 24 1
6 134 0
312 456 1
402 364 1
465 98 1
264 44 0
49 4 0
257 22 0
397 285 1
430 388 0
259 342 1
354 300 1
448 96 1
290 228 0
31 272 0
332 130 0
348 160 1
198 366 1
18 467 0
474 308 1
374 101 1
...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #52:

score: 0
Accepted
time: 0ms
memory: 3700kb

input:

497 497 2
81 446 1
484 359 0
417 249 1
113 74 1
27 14 0
51 380 1
207 148 0
422 334 0
386 419 1
369 46 1
338 136 1
211 62 1
264 125 0
426 90 0
404 211 1
339 66 0
468 21 1
394 177 1
127 442 1
262 190 0
172 415 0
29 10 1
189 484 0
379 60 1
102 84 0
118 163 0
236 76 1
33 422 0
384 328 1
9 448 0
425 120 ...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #53:

score: 0
Accepted
time: 0ms
memory: 3700kb

input:

499 499 2
282 20 1
276 126 0
353 375 1
62 89 1
461 127 0
18 159 0
197 310 1
393 418 1
38 246 1
363 84 1
312 314 1
473 370 1
456 22 0
17 111 1
450 417 1
114 413 0
238 449 0
260 454 1
210 86 0
349 468 0
465 477 0
376 362 0
287 87 1
494 44 1
334 349 0
183 77 0
10 154 1
54 433 1
286 325 1
224 140 0
156 ...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #54:

score: 0
Accepted
time: 0ms
memory: 3708kb

input:

499 499 3
28 294 2
84 43 1
224 290 2
302 18 2
443 410 0
320 370 2
425 42 2
82 235 1
396 76 0
412 270 0
387 360 2
195 84 0
409 416 2
339 390 1
365 342 1
187 223 0
442 142 1
299 320 1
32 321 1
79 56 0
485 437 1
76 272 2
379 93 1
410 169 0
413 16 1
50 347 1
378 101 1
30 384 2
332 348 0
26 395 1
92 40 2...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #55:

score: 0
Accepted
time: 0ms
memory: 4088kb

input:

499 499 89
443 214 36
365 483 68
177 343 67
419 112 70
294 104 37
271 77 50
397 115 52
473 141 34
282 318 5
343 467 67
320 157 87
68 486 51
69 466 65
35 484 35
248 91 73
101 13 57
278 67 0
78 172 71
322 74 68
482 370 65
459 295 32
207 39 16
361 321 9
441 431 36
147 363 6
93 390 59
90 128 44
339 178 ...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #56:

score: 0
Accepted
time: 9ms
memory: 5372kb

input:

500 500 499
349 244 372
211 55 184
392 217 54
343 125 381
169 265 319
184 382 159
329 187 268
341 248 273
240 360 62
35 438 70
27 408 479
130 35 319
313 57 223
376 245 135
219 170 59
469 425 277
140 398 302
275 41 337
377 148 171
307 64 256
446 484 361
124 137 369
62 216 297
466 343 71
26 462 451
41...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #57:

score: 0
Accepted
time: 3ms
memory: 4340kb

input:

500 500 900557569
354 397 69211892
20 455 69211892
86 85 769147441
130 5 69211892
182 74 863979609
30 33 69211892
81 23 69211892
309 171 69211892
52 439 619200238
381 215 69211892
107 65 418363826
373 429 597847779
361 484 69211892
406 421 69211892
105 445 69211892
469 226 366814872
353 389 69211892...

output:

415
69211892 179 95 204 186 294 483 387 314 27 469 59 435 217 450 384 121 42 472 302 281 393 326 309 52 391 286 425 51 488 306 369 61 429 402 444 287 211 114 125 209 198 87 96 153 401 417 265 171 317 72 212 366 312 100 278 242 494 132 34 332 323 78 352 85 426 154 382 167 489 481 407 456 202 371 148 ...

result:

ok Participant found an answer (415 trees) and jury found an answer (413 trees)

Test #58:

score: 0
Accepted
time: 16ms
memory: 8500kb

input:

500 600 757689509
446 285 573639950
270 388 122483021
381 1 522425165
288 476 614875119
283 52 398486338
443 366 113128200
243 327 222283575
11 158 248607065
482 243 150554599
195 12 735418857
78 371 429919406
120 275 30816927
460 364 469329384
108 256 518286993
477 72 118822969
249 185 303993365
36...

output:

1185
168150466 304 558 95 492 591 202 244 292 402 589 327 436 420 151 495 79 193 405 334 322 297 443 497 519 513 361 60 106 538 364 187 508 119 320 47 264 470 36 87 140 269 458 388 505 30 274 195 328 584 448 332 124 26 238 115 573 467 299 540 566 338 300 596 173 594 164 542 496 273 421 342 583 556 4...

result:

ok Participant found an answer (1185 trees) and jury found an answer (1185 trees)

Test #59:

score: 0
Accepted
time: 15ms
memory: 7824kb

input:

500 700 828905719
480 5 739672643
201 112 370733333
235 26 16345049
409 234 173409653
486 456 631007778
120 1 538740285
58 458 522613047
107 314 58436706
400 89 287382978
206 304 118447652
248 438 738474281
138 437 424258467
358 245 311144163
446 239 676021307
489 362 475425446
68 19 412038991
452 2...

output:

1385
225419949 70 593 580 427 235 621 590 597 210 546 669 468 101 360 536 527 305 517 616 432 660 330 654 39 481 671 520 553 499 386 311 356 43 487 684 500 679 340 530 673 636 72 490 690 297 201 389 153 614 652 568 420 430 419 685 583 498 653 288 255 688 539 480 188 96 675 495 547 56 569 274 280 173...

result:

ok Participant found an answer (1385 trees) and jury found an answer (1385 trees)

Test #60:

score: 0
Accepted
time: 21ms
memory: 8908kb

input:

500 800 742108217
240 437 223580374
386 260 450278481
408 194 272294044
55 440 411878160
466 274 698768664
374 195 103845986
347 474 601813702
298 276 229739628
58 332 403349699
407 175 540597854
114 256 39078041
395 467 643278059
250 234 83749897
26 159 422456771
272 101 476764351
410 86 521528751
...

output:

1599
485105386 429 175 734 774 178 662 790 748 561 741 550 730 371 631 782 709 536 799 668 647 791 272 666 419 239 450 469 731 706 688 348 9 620 439 787 689 574 682 501 625 670 781 609 747 500 778 548 482 318 580 732 328 567 196 21 651 687 764 554 86 642 356 109 246 775 442 426 296 737 542 445 712 4...

result:

ok Participant found an answer (1599 trees) and jury found an answer (1599 trees)

Test #61:

score: 0
Accepted
time: 18ms
memory: 7568kb

input:

500 900 734453983
97 159 647125233
12 291 575754497
338 202 4000585
185 448 531153789
420 221 670359551
156 233 277582474
279 371 585124518
139 272 669984536
368 39 404059164
268 353 422914933
482 180 633326141
285 69 106394126
1 441 389880720
46 293 550622480
1 464 703029276
136 194 398527669
403 1...

output:

1799
425697662 786 717 34 866 403 862 567 720 754 751 705 753 846 763 289 149 791 730 788 722 685 718 822 771 124 362 650 527 441 875 885 684 646 336 622 664 850 345 544 499 865 262 509 703 832 418 326 726 691 222 781 804 502 458 614 878 869 801 581 723 896 830 819 892 626 895 890 835 285 321 802 44...

result:

ok Participant found an answer (1799 trees) and jury found an answer (1799 trees)

Test #62:

score: 0
Accepted
time: 22ms
memory: 13032kb

input:

500 999 710309027
418 335 337061089
237 197 426428799
93 439 166667582
83 277 8712657
128 401 231709955
39 147 548228697
169 128 490677625
421 321 605233428
188 59 627898332
329 28 521677427
383 381 25277585
431 369 47133664
36 258 136480797
81 166 178582419
325 338 108644840
56 362 524348240
335 14...

output:

1995
469192202 947 900 716 745 464 830 928 931 618 896 977 726 838 803 823 755 866 591 999 195 453 921 428 373 842 899 829 385 756 953 917 951 850 851 837 909 883 868 949 597 399 979 922 925 876 986 993 992 580 937 844 451 802 897 737 562 721 955 965 826 539 964 747 879 442 836 846 79 805 625 973 97...

result:

ok Participant found an answer (1995 trees) and jury found an answer (1995 trees)

Test #63:

score: 0
Accepted
time: 19ms
memory: 12204kb

input:

500 1000 671240159
112 82 417448095
230 361 64083244
212 281 465849701
227 24 427651359
466 280 57293642
422 272 572834299
26 185 528167062
43 164 561914685
390 346 68777697
467 77 139659139
6 93 623796002
20 445 60076185
265 466 534177282
202 339 50852556
126 245 54588949
409 50 658668954
63 389 74...

output:

1999
477526700 838 730 465 991 753 418 747 449 866 975 716 185 898 576 546 917 675 943 588 738 698 845 862 846 994 939 792 908 714 509 982 953 927 632 834 884 952 726 719 815 967 299 629 705 285 607 749 545 986 654 728 841 650 552 836 945 693 740 897 859 972 874 801 901 984 892 860 799 680 754 774 7...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1999 trees)

Test #64:

score: 0
Accepted
time: 8ms
memory: 9152kb

input:

500 1000 2
33 43 0
50 112 0
444 334 1
384 349 0
331 147 0
476 51 0
50 14 0
468 180 1
114 449 1
495 60 0
269 313 0
341 435 0
297 230 1
355 365 1
234 448 1
422 371 1
207 286 1
373 469 1
179 354 1
148 288 0
106 464 1
488 330 0
5 483 1
303 456 0
385 225 1
307 180 0
232 230 0
478 106 1
415 157 1
180 468 ...

output:

1003
1 900 345 711 254 878 982 979 577 374 761 757 492 417 769 394 877 843 910 974 951 928 794 941 498 802 932 780 724 722 952 291 37 696 270 883 824 967 424 890 425 638 351 213 936 746 627 866 918 963 919 393 879 797 846 935 792 412 556 539 274 703 602 411 578 310 811 682 472 775 443 550 827 984 37...

result:

ok Participant found an answer (1003 trees) and jury found an answer (569 trees)

Test #65:

score: 0
Accepted
time: 17ms
memory: 7176kb

input:

500 1000 449601599
100 222 30037220
147 470 249365875
276 477 154411298
118 484 169381615
326 359 72638440
120 49 11887570
172 17 29333979
267 318 165923299
423 133 34647814
43 476 94909028
370 346 9506795
234 438 79196751
313 419 212431557
74 276 388811517
434 333 381427530
318 68 174003055
275 56 ...

output:

1343
197745351 819 741 898 836 378 984 420 657 845 793 804 365 211 331 719 977 531 955 773 938 866 788 218 106 927 832 900 605 456 944 835 637 248 407 920 803 886 749 730 995 855 811 997 556 843 706 314 930 828 145 463 326 964 979 830 357 43 330 603 643 700 943 952 629 661 752 978 493 911 415 411 81...

result:

ok Participant found an answer (1343 trees) and jury found an answer (1343 trees)

Test #66:

score: 0
Accepted
time: 15ms
memory: 7176kb

input:

500 1000 377264473
175 38 136228469
128 185 129185920
439 476 58945960
345 171 15536581
269 259 31215767
278 394 252159963
254 395 351469865
47 161 180813824
258 82 291987616
371 125 324790445
82 258 183455625
205 12 19394719
417 395 209733633
205 12 306682523
395 72 301637606
112 399 189192744
429 ...

output:

1501
220501433 420 398 766 992 244 77 931 511 995 919 938 701 997 567 732 731 201 966 53 717 750 946 33 495 251 893 383 458 322 841 908 681 468 541 254 820 128 823 757 725 944 829 610 618 985 854 973 354 720 952 980 542 622 656 695 902 467 972 948 746 679 866 804 409 933 180 749 821 677 785 789 440 ...

result:

ok Participant found an answer (1501 trees) and jury found an answer (1501 trees)

Test #67:

score: 0
Accepted
time: 14ms
memory: 7248kb

input:

500 1000 2
175 38 0
128 185 0
439 476 1
345 171 0
269 259 0
278 394 1
254 395 1
47 161 1
258 82 1
371 125 1
82 258 1
205 12 1
417 395 0
205 12 1
395 72 1
112 399 0
429 430 1
113 136 1
258 337 0
467 89 1
435 299 1
355 369 1
368 406 1
328 483 1
259 406 1
487 112 1
455 356 1
293 387 1
195 205 1
51 319 ...

output:

1501
0 420 398 766 992 244 77 931 511 995 919 938 701 997 567 732 731 201 966 53 717 750 946 33 495 251 893 383 458 322 841 908 681 468 541 254 820 128 823 757 725 944 829 610 618 985 854 973 354 720 952 980 542 622 656 695 902 467 972 948 746 679 866 804 409 933 180 749 821 677 785 789 440 102 382 ...

result:

ok Participant found an answer (1501 trees) and jury found an answer (1144 trees)

Test #68:

score: 0
Accepted
time: 15ms
memory: 7924kb

input:

500 1000 2
112 139 1
447 169 1
475 125 1
448 102 1
291 390 1
78 53 1
46 167 1
304 400 1
282 420 1
162 152 0
167 46 1
425 405 1
63 160 1
476 200 1
288 460 0
496 20 0
131 290 1
181 376 1
420 188 0
231 356 0
55 399 0
319 180 0
167 46 0
325 14 0
206 283 1
473 45 1
37 103 0
302 115 1
70 63 1
115 345 1
35...

output:

1597
0 875 999 161 959 945 890 411 865 621 808 537 895 893 918 278 840 902 640 228 745 590 127 456 27 93 826 798 932 949 346 967 795 829 898 440 988 595 778 869 655 507 347 924 908 832 336 241 854 644 344 483 782 251 965 791 748 900 527 718 80 931 444 158 821 953 816 891 631 447 913 851 756 610 302 ...

result:

ok Participant found an answer (1597 trees) and jury found an answer (1160 trees)

Test #69:

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

input:

500 1000 2
365 287 1
402 330 1
416 83 1
186 498 1
377 248 0
5 295 1
472 152 0
475 368 1
80 40 0
447 462 1
359 316 0
279 256 1
179 469 1
237 221 0
408 148 0
474 462 0
141 230 1
230 141 0
350 159 0
280 230 1
435 247 1
308 387 0
213 422 0
469 467 0
84 434 0
93 113 0
245 389 1
377 82 0
492 80 0
409 440 ...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #70:

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

input:

500 1000 2
149 464 0
471 295 0
385 355 0
195 142 0
267 385 1
312 467 0
269 83 1
397 238 0
483 21 0
335 23 0
288 359 0
494 455 0
459 217 0
278 68 0
101 105 0
291 184 1
277 382 0
411 264 1
125 1 1
3 346 0
300 98 0
488 419 1
401 316 0
314 281 0
376 230 0
324 425 1
431 275 0
431 253 1
188 344 0
232 380 ...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #71:

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

input:

500 1000 3
369 288 2
52 203 2
241 486 1
47 26 0
408 336 2
338 230 0
478 197 2
483 212 1
283 205 1
337 444 0
260 65 2
313 459 0
156 362 0
405 492 0
294 353 2
202 37 0
498 3 1
193 260 0
230 416 1
459 173 0
416 216 2
202 220 1
280 448 2
237 111 0
353 16 1
207 336 1
480 116 2
230 239 1
418 482 0
46 98 2...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #72:

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

input:

500 1000 3
186 357 2
211 226 1
183 462 2
217 14 2
101 160 2
184 366 1
231 98 1
311 128 0
307 364 0
453 405 1
321 335 1
19 446 1
403 177 2
157 377 2
435 55 1
263 37 0
89 426 2
28 470 1
213 394 0
447 419 2
34 454 2
155 100 2
277 211 2
146 46 1
374 438 0
475 245 0
254 276 2
409 176 0
197 166 2
424 83 2...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #73:

score: -100
Wrong Answer
time: 1ms
memory: 4032kb

input:

500 1000 5
52 403 3
490 11 3
4 70 2
200 337 2
163 77 3
294 450 0
230 338 2
420 275 3
132 456 4
298 357 4
181 287 1
122 482 0
439 383 3
462 164 1
448 475 4
235 251 1
251 232 1
287 170 1
172 62 4
215 18 0
353 306 3
105 390 2
462 89 2
346 267 3
385 2 1
178 197 1
408 302 1
145 300 1
484 143 0
229 321 2
...

output:

-1

result:

wrong answer Participant did not find an answer, while jury found (1463 trees)