QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#286849#1866. Decomposition5abAC ✓177ms3748kbC++201.2kb2023-12-18 19:37:342023-12-18 19:37:34

Judging History

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

  • [2023-12-18 19:37:34]
  • 评测
  • 测评结果:AC
  • 用时:177ms
  • 内存:3748kb
  • [2023-12-18 19:37:34]
  • 提交

answer

/* name: D
 * author: 5ab
 * created at: 2023-12-18
 */
#include <iostream>
#include <vector>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define ssz(x) (int((x).size()))

auto chmax = [](auto& x, auto y) { if (x < y) x = y; };
auto chmin = [](auto& x, auto y) { if (y < x) x = y; };

using ll = long long;
const int max_n = 1e3, max_m = max_n * (max_n - 1) / 2;

int l[max_m];

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int cas, n, m;
	
	auto nxt = [&](int x) { return x == n - 2 ? 0 : x + 1; };
	auto prv = [&](int x) { return x == 0 ? n - 2 : x - 1; };
	
	cin >> cas;
	for (int t = 0; t < cas; t++)
	{
		cin >> n >> m;
		for (int i = 0; i < m; i++)
			cin >> l[i];
		
		int curp = 0, curc = 0;
		auto addp = [&](int x) {
			cout << x + 1 << " ";
			if (curc == l[curp])
			{
				cout << "\n" << x + 1 << " ";
				curc = 1, curp++;
			}
			else
				curc++;
		};
		
		cout << "Case #" << t + 1 << ":\n";
		for (int i = 0; i < n / 2; i++)
		{
			addp(n - 1);
			for (int j = i, k = prv(i), c = 0; c < n / 2; c++, j = nxt(j), k = prv(k))
			{
				addp(j);
				addp(k);
			}
		}
		cout << n << "\n";
	}
	
	return 0;
}
// started coding at: 12-18 18:09:39

詳細信息

Test #1:

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

input:

3
5 6
2 1 1 2 2 2
7 8
1 1 4 3 4 1 3 4
5 10
1 1 1 1 1 1 1 1 1 1

output:

Case #1:
5 1 4 
4 2 
2 3 
3 5 2 
2 1 3 
3 4 5
Case #2:
7 1 
1 6 
6 2 5 3 4 
4 7 2 1 
1 3 6 4 5 
5 7 
7 3 2 4 
4 1 5 6 7
Case #3:
5 1 
1 4 
4 2 
2 3 
3 5 
5 2 
2 1 
1 3 
3 4 
4 5

result:

ok OK, 3 cases

Test #2:

score: 0
Accepted
time: 24ms
memory: 3580kb

input:

5000
13 12
5 8 9 7 5 4 10 10 7 9 2 2
7 13
2 2 1 2 2 2 3 1 1 1 2 1 1
11 16
1 1 5 4 6 2 5 1 5 8 1 1 7 3 4 1
13 17
4 1 9 1 8 1 7 6 4 8 2 8 5 8 4 1 1
5 6
1 2 1 2 2 2
9 9
5 4 5 4 5 1 6 1 5
17 23
4 9 1 10 5 8 8 7 4 11 2 4 6 3 6 7 11 3 10 7 4 5 1
13 14
10 9 1 1 1 10 3 8 8 10 3 3 10 1
7 8
4 1 4 1 4 3 2 2
19...

output:

Case #1:
13 1 12 2 11 3 
3 10 4 9 5 8 6 7 13 
13 2 1 3 12 4 11 5 10 6 
6 9 7 8 13 3 2 4 
4 1 5 12 6 11 
11 7 10 8 9 
9 13 4 3 5 2 6 1 7 12 8 
8 11 9 10 13 5 4 6 3 7 2 
2 8 1 9 12 10 11 13 
13 6 5 7 4 8 3 9 2 10 
10 1 11 
11 12 13
Case #2:
7 1 6 
6 2 5 
5 3 
3 4 7 
7 2 1 
1 3 6 
6 4 5 7 
7 3 
3 2 
2 ...

result:

ok OK, 5000 cases

Test #3:

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

input:

2000
27 44
5 15 4 6 7 14 9 2 1 24 9 4 12 6 13 23 7 3 21 2 5 2 3 20 8 12 10 21 3 1 6 8 8 4 5 3 19 1 10 7 4 1 1 2
29 31
25 8 18 22 7 7 25 9 26 25 6 11 20 1 7 9 11 14 23 20 1 13 16 1 22 23 14 6 13 1 2
27 27
16 24 6 12 3 3 22 2 24 12 6 10 18 14 8 21 20 14 15 4 23 20 2 14 11 23 4
29 39
15 19 3 7 1 13 20 ...

output:

Case #1:
27 1 26 2 25 3 
3 24 4 23 5 22 6 21 7 20 8 19 9 18 10 17 
17 11 16 12 15 
15 13 14 27 2 1 3 
3 26 4 25 5 24 6 23 
23 7 22 8 21 9 20 10 19 11 18 12 17 13 16 
16 14 15 27 3 2 4 1 5 26 
26 6 25 
25 7 
7 24 8 23 9 22 10 21 11 20 12 19 13 18 14 17 15 16 27 4 3 5 2 6 1 
1 7 26 8 25 9 24 10 23 11 ...

result:

ok OK, 2000 cases

Test #4:

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

input:

800
9 11
5 5 4 1 1 5 5 6 2 1 1
11 14
5 7 5 1 3 3 6 8 3 7 2 3 1 1
19 22
14 10 8 2 9 12 13 2 6 5 8 5 5 1 12 1 10 13 10 2 14 9
9 9
6 5 3 4 3 4 4 6 1
5 7
2 1 1 2 1 2 1
5 7
1 2 2 2 1 1 1
31 29
20 8 18 13 1 24 12 9 12 19 24 25 21 23 6 27 12 10 17 19 23 26 23 5 28 14 11 2 13
49 48
42 46 45 12 5 24 16 28 40...

output:

Case #1:
9 1 8 2 7 3 
3 6 4 5 9 2 
2 1 3 8 4 
4 7 
7 5 
5 6 9 3 2 4 
4 1 5 8 6 7 
7 9 4 3 5 2 6 
6 1 7 
7 8 
8 9
Case #2:
11 1 10 2 9 3 
3 8 4 7 5 6 11 2 
2 1 3 10 4 9 
9 5 
5 8 6 7 
7 11 3 2 
2 4 1 5 10 6 9 
9 7 8 11 4 3 5 2 6 
6 1 7 10 
10 8 9 11 5 4 6 3 
3 7 2 
2 8 1 9 
9 10 
10 11
Case #3:
19 1 ...

result:

ok OK, 800 cases

Test #5:

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

input:

200
23 26
6 17 15 16 8 5 3 20 8 17 16 8 10 10 10 10 14 1 16 12 7 6 2 4 10 2
47 45
40 15 13 24 37 4 37 8 27 44 12 11 38 19 41 26 22 33 13 26 20 40 39 37 21 16 32 14 9 8 32 36 43 28 29 4 26 38 23 34 5 23 17 16 1
11 12
4 6 7 7 8 4 8 3 1 2 3 2
89 89
57 9 68 20 45 8 78 59 16 83 72 8 42 39 76 76 28 72 46 ...

output:

Case #1:
23 1 22 2 21 3 20 
20 4 19 5 18 6 17 7 16 8 15 9 14 10 13 11 12 23 
23 2 1 3 22 4 21 5 20 6 19 7 18 8 17 9 
9 16 10 15 11 14 12 13 23 3 2 4 1 5 22 6 21 
21 7 20 8 19 9 18 10 17 
17 11 16 12 15 13 
13 14 23 4 
4 3 5 2 6 1 7 22 8 21 9 20 10 19 11 18 12 17 13 16 14 
14 15 23 5 4 6 3 7 2 
2 8 1...

result:

ok OK, 200 cases

Test #6:

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

input:

8
123 123
11 68 57 31 101 57 58 24 104 69 103 1 3 32 74 103 13 86 90 112 64 109 25 68 60 102 89 50 112 37 53 93 24 115 93 21 56 82 80 13 71 54 94 16 6 57 20 39 54 76 48 57 75 35 63 11 86 102 32 20 65 15 81 15 98 14 102 57 92 94 46 104 56 60 57 120 31 114 23 111 15 96 68 93 50 26 114 79 103 59 106 60...

output:

Case #1:
123 1 122 2 121 3 120 4 119 5 118 6 
6 117 7 116 8 115 9 114 10 113 11 112 12 111 13 110 14 109 15 108 16 107 17 106 18 105 19 104 20 103 21 102 22 101 23 100 24 99 25 98 26 97 27 96 28 95 29 94 30 93 31 92 32 91 33 90 34 89 35 88 36 87 37 86 38 85 39 84 40 
40 83 41 82 42 81 43 80 44 79 45...

result:

ok OK, 8 cases

Test #7:

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

input:

2
931 941
37 625 158 286 652 892 205 242 367 627 914 33 501 700 280 117 693 593 389 547 807 758 160 565 24 601 784 551 322 749 463 504 681 221 8 857 511 554 45 797 828 538 779 876 868 475 607 43 161 692 514 687 717 420 610 570 389 112 587 551 890 101 128 371 621 186 263 926 332 130 21 898 311 436 32...

output:

Case #1:
931 1 930 2 929 3 928 4 927 5 926 6 925 7 924 8 923 9 922 10 921 11 920 12 919 13 918 14 917 15 916 16 915 17 914 18 913 19 
19 912 20 911 21 910 22 909 23 908 24 907 25 906 26 905 27 904 28 903 29 902 30 901 31 900 32 899 33 898 34 897 35 896 36 895 37 894 38 893 39 892 40 891 41 890 42 88...

result:

ok OK, 2 cases

Test #8:

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

input:

2
57 60
24 19 36 48 4 43 19 52 8 52 6 17 10 19 18 41 20 36 4 41 38 34 24 26 29 48 15 37 10 7 4 8 16 43 8 9 27 38 12 19 52 31 9 54 49 15 51 24 43 54 29 46 12 40 17 36 50 12 2 1
643 646
230 5 469 246 610 243 221 411 352 98 56 243 481 622 240 492 349 336 548 102 516 326 468 563 272 363 99 156 468 562 5...

output:

Case #1:
57 1 56 2 55 3 54 4 53 5 52 6 51 7 50 8 49 9 48 10 47 11 46 12 45 
45 13 44 14 43 15 42 16 41 17 40 18 39 19 38 20 37 21 36 22 
22 35 23 34 24 33 25 32 26 31 27 30 28 29 57 2 1 3 56 4 55 5 54 6 53 7 52 8 51 9 50 10 49 11 48 12 47 
47 13 46 14 45 15 44 16 43 17 42 18 41 19 40 20 39 21 38 22 ...

result:

ok OK, 2 cases

Test #9:

score: 0
Accepted
time: 27ms
memory: 3688kb

input:

2
939 935
96 887 857 430 351 403 292 594 392 287 841 710 428 591 389 218 248 134 924 445 162 52 491 820 314 711 207 112 874 201 908 448 799 207 6 690 782 141 749 623 628 466 495 700 861 588 791 93 364 36 834 772 774 619 615 46 358 5 493 382 121 891 71 564 219 201 496 495 883 781 546 394 548 936 643 ...

output:

Case #1:
939 1 938 2 937 3 936 4 935 5 934 6 933 7 932 8 931 9 930 10 929 11 928 12 927 13 926 14 925 15 924 16 923 17 922 18 921 19 920 20 919 21 918 22 917 23 916 24 915 25 914 26 913 27 912 28 911 29 910 30 909 31 908 32 907 33 906 34 905 35 904 36 903 37 902 38 901 39 900 40 899 41 898 42 897 43...

result:

ok OK, 2 cases

Test #10:

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

input:

2
763 776
379 463 566 538 49 15 664 613 227 59 631 331 374 87 4 325 559 80 459 107 528 340 427 420 99 171 492 465 572 316 723 598 423 135 14 156 604 99 648 509 657 449 715 50 157 652 701 521 644 529 420 385 173 55 758 649 311 135 744 47 370 488 40 405 722 284 443 676 57 552 283 241 26 449 522 201 10...

output:

Case #1:
763 1 762 2 761 3 760 4 759 5 758 6 757 7 756 8 755 9 754 10 753 11 752 12 751 13 750 14 749 15 748 16 747 17 746 18 745 19 744 20 743 21 742 22 741 23 740 24 739 25 738 26 737 27 736 28 735 29 734 30 733 31 732 32 731 33 730 34 729 35 728 36 727 37 726 38 725 39 724 40 723 41 722 42 721 43...

result:

ok OK, 2 cases

Test #11:

score: 0
Accepted
time: 62ms
memory: 3592kb

input:

18181
11 14
7 1 6 2 7 3 2 7 2 4 5 4 4 1
11 10
8 5 6 8 6 4 6 1 7 4
11 13
7 8 7 3 3 7 1 3 1 4 3 6 2
11 14
3 1 5 3 8 1 4 8 4 8 1 5 3 1
11 15
5 3 2 5 1 5 7 8 2 6 4 4 1 1 1
11 11
6 1 7 5 6 7 6 6 4 5 2
11 12
6 3 5 2 5 8 6 3 4 8 4 1
11 12
3 8 4 3 4 7 2 5 6 6 6 1
11 15
5 5 1 2 5 7 6 1 6 5 6 1 3 1 1
11 15
7 ...

output:

Case #1:
11 1 10 2 9 3 8 4 
4 7 
7 5 6 11 2 1 3 
3 10 4 
4 9 5 8 6 7 11 3 
3 2 4 1 
1 5 10 
10 6 9 7 8 11 4 3 
3 5 2 
2 6 1 7 10 
10 8 9 11 5 4 
4 6 3 7 2 
2 8 1 9 10 
10 11
Case #2:
11 1 10 2 9 3 8 4 7 
7 5 6 11 2 1 
1 3 10 4 9 5 8 
8 6 7 11 3 2 4 1 5 
5 10 6 9 7 8 11 
11 4 3 5 2 
2 6 1 7 10 8 9 
9...

result:

ok OK, 18181 cases

Test #12:

score: 0
Accepted
time: 52ms
memory: 3684kb

input:

4700
21 25
6 14 1 10 8 8 18 5 15 9 15 3 4 3 12 12 18 10 4 1 13 6 8 3 4
21 23
9 15 17 10 2 12 12 12 9 6 8 1 4 8 9 6 16 18 2 14 10 8 2
21 21
17 16 5 9 14 8 14 17 7 7 5 14 13 1 10 2 11 12 4 14 10
21 23
16 5 11 10 14 14 1 13 16 6 8 17 3 1 3 1 6 12 9 17 16 9 2
21 27
2 6 9 17 6 11 5 15 3 17 4 13 9 1 4 5 1...

output:

Case #1:
21 1 20 2 19 3 18 
18 4 17 5 16 6 15 7 14 8 13 9 12 10 11 
11 21 
21 2 1 3 20 4 19 5 18 6 17 
17 7 16 8 15 9 14 10 13 
13 11 12 21 3 2 4 1 5 
5 20 6 19 7 18 8 17 9 16 10 15 11 14 12 13 21 4 3 
3 5 2 6 1 7 
7 20 8 19 9 18 10 17 11 16 12 15 13 14 21 5 
5 4 6 3 7 2 8 1 9 20 
20 10 19 11 18 12 ...

result:

ok OK, 4700 cases

Test #13:

score: 0
Accepted
time: 45ms
memory: 3656kb

input:

2000
31 34
5 28 14 25 14 13 10 2 21 24 28 6 4 23 9 5 4 26 18 18 8 7 24 12 21 19 19 10 2 11 7 13 9 6
31 33
20 18 1 26 19 2 5 27 18 18 12 15 28 28 1 12 5 5 5 11 10 9 5 14 26 18 10 23 27 25 17 1 4
31 29
28 18 22 1 4 17 12 23 19 27 12 19 26 27 26 18 6 9 20 16 6 19 17 25 3 12 23 5 5
31 37
9 25 27 12 28 9...

output:

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

result:

ok OK, 2000 cases

Test #14:

score: 0
Accepted
time: 45ms
memory: 3620kb

input:

780
51 55
2 9 14 17 31 21 36 21 16 40 32 9 25 5 48 1 25 6 38 13 14 47 2 33 38 42 37 30 35 24 44 22 28 39 6 9 13 47 34 34 19 24 11 10 29 14 6 40 42 18 33 12 18 9 3
51 57
36 31 7 48 37 19 8 35 30 15 41 5 16 27 17 14 42 38 9 42 48 44 4 5 46 1 24 41 1 14 38 35 14 29 36 8 8 21 19 7 25 44 43 1 32 24 7 11 ...

output:

Case #1:
51 1 50 
50 2 49 3 48 4 47 5 46 6 
6 45 7 44 8 43 9 42 10 41 11 40 12 39 13 
13 38 14 37 15 36 16 35 17 34 18 33 19 32 20 31 21 30 
30 22 29 23 28 24 27 25 26 51 2 1 3 50 4 49 5 48 6 47 7 46 8 45 9 44 10 43 11 42 12 41 
41 13 40 14 39 15 38 16 37 17 36 18 35 19 34 20 33 21 32 22 31 23 
23 3...

result:

ok OK, 780 cases

Test #15:

score: 0
Accepted
time: 42ms
memory: 3592kb

input:

198
101 103
54 54 28 16 56 42 72 79 61 77 67 38 33 96 82 79 2 58 88 43 14 61 70 55 14 58 60 62 63 52 82 79 43 47 49 3 28 80 57 88 55 89 57 50 95 84 58 40 49 13 7 78 11 12 48 21 54 93 9 97 61 66 29 81 97 8 38 3 85 67 84 27 85 76 42 37 28 23 48 25 29 3 71 31 17 41 36 79 26 54 12 92 94 54 53 35 37 19 3...

output:

Case #1:
101 1 100 2 99 3 98 4 97 5 96 6 95 7 94 8 93 9 92 10 91 11 90 12 89 13 88 14 87 15 86 16 85 17 84 18 83 19 82 20 81 21 80 22 79 23 78 24 77 25 76 26 75 27 74 
74 28 73 29 72 30 71 31 70 32 69 33 68 34 67 35 66 36 65 37 64 38 63 39 62 40 61 41 60 42 59 43 58 44 57 45 56 46 55 47 54 48 53 49 ...

result:

ok OK, 198 cases

Test #16:

score: 0
Accepted
time: 42ms
memory: 3656kb

input:

8
499 525
114 220 79 338 377 103 342 3 46 404 13 272 375 131 31 325 354 168 294 378 363 68 104 463 346 360 435 461 276 151 431 405 303 436 349 398 323 172 404 87 194 111 162 179 399 312 13 393 82 149 67 135 88 472 381 9 388 238 448 163 422 113 143 19 311 461 11 263 158 337 479 450 135 47 492 64 8 26...

output:

Case #1:
499 1 498 2 497 3 496 4 495 5 494 6 493 7 492 8 491 9 490 10 489 11 488 12 487 13 486 14 485 15 484 16 483 17 482 18 481 19 480 20 479 21 478 22 477 23 476 24 475 25 474 26 473 27 472 28 471 29 470 30 469 31 468 32 467 33 466 34 465 35 464 36 463 37 462 38 461 39 460 40 459 41 458 42 457 43...

result:

ok OK, 8 cases

Test #17:

score: 0
Accepted
time: 34ms
memory: 3692kb

input:

2
999 1031
352 582 8 942 106 301 80 868 705 200 986 193 843 715 563 861 800 694 453 106 243 840 714 919 557 180 732 707 801 523 441 189 227 564 67 874 137 219 509 52 205 480 515 81 295 438 274 911 501 260 992 58 616 536 234 772 738 594 265 697 696 789 156 313 455 755 317 845 18 712 781 95 400 62 457...

output:

Case #1:
999 1 998 2 997 3 996 4 995 5 994 6 993 7 992 8 991 9 990 10 989 11 988 12 987 13 986 14 985 15 984 16 983 17 982 18 981 19 980 20 979 21 978 22 977 23 976 24 975 25 974 26 973 27 972 28 971 29 970 30 969 31 968 32 967 33 966 34 965 35 964 36 963 37 962 38 961 39 960 40 959 41 958 42 957 43...

result:

ok OK, 2 cases

Test #18:

score: 0
Accepted
time: 38ms
memory: 3692kb

input:

2
999 999
848 520 572 830 859 562 369 726 766 93 841 929 890 261 644 121 168 989 93 244 595 845 955 371 926 347 296 944 833 471 904 341 13 752 44 712 578 355 833 546 597 407 186 472 785 93 659 892 925 560 562 150 162 186 260 826 366 478 459 430 115 741 834 981 139 109 418 321 149 754 167 207 562 495...

output:

Case #1:
999 1 998 2 997 3 996 4 995 5 994 6 993 7 992 8 991 9 990 10 989 11 988 12 987 13 986 14 985 15 984 16 983 17 982 18 981 19 980 20 979 21 978 22 977 23 976 24 975 25 974 26 973 27 972 28 971 29 970 30 969 31 968 32 967 33 966 34 965 35 964 36 963 37 962 38 961 39 960 40 959 41 958 42 957 43...

result:

ok OK, 2 cases

Test #19:

score: 0
Accepted
time: 38ms
memory: 3656kb

input:

2
999 994
452 635 984 227 498 587 35 67 265 269 982 486 255 964 366 159 995 500 427 870 470 559 230 881 359 968 772 169 337 251 547 550 627 7 255 158 919 638 303 132 397 330 406 944 494 748 528 29 323 254 102 22 8 345 762 434 700 48 687 536 740 88 478 746 576 854 917 384 958 338 643 351 314 393 515 ...

output:

Case #1:
999 1 998 2 997 3 996 4 995 5 994 6 993 7 992 8 991 9 990 10 989 11 988 12 987 13 986 14 985 15 984 16 983 17 982 18 981 19 980 20 979 21 978 22 977 23 976 24 975 25 974 26 973 27 972 28 971 29 970 30 969 31 968 32 967 33 966 34 965 35 964 36 963 37 962 38 961 39 960 40 959 41 958 42 957 43...

result:

ok OK, 2 cases

Test #20:

score: 0
Accepted
time: 38ms
memory: 3688kb

input:

20000
9 11
3 2 2 5 1 5 4 4 3 4 3
5 6
1 2 2 2 1 2
9 12
6 1 1 2 1 6 6 3 5 2 1 2
9 12
5 2 6 4 1 1 6 1 2 1 5 2
7 10
2 1 2 3 1 4 2 4 1 1
7 9
3 2 2 3 1 2 1 4 3
5 8
1 2 2 1 1 1 1 1
7 8
2 2 3 4 3 4 2 1
5 7
2 1 1 1 2 2 1
7 9
2 2 3 4 3 2 2 2 1
5 6
2 2 1 2 2 1
5 6
2 1 1 2 2 2
5 7
2 1 1 2 2 1 1
9 11
5 6 3 5 2 2...

output:

Case #1:
9 1 8 2 
2 7 3 
3 6 4 
4 5 9 2 1 3 
3 8 
8 4 7 5 6 9 
9 3 2 4 1 
1 5 8 6 7 
7 9 4 3 
3 5 2 6 1 
1 7 8 9
Case #2:
5 1 
1 4 2 
2 3 5 
5 2 1 
1 3 
3 4 5
Case #3:
9 1 8 2 7 3 6 
6 4 
4 5 
5 9 2 
2 1 
1 3 8 4 7 5 6 
6 9 3 2 4 1 5 
5 8 6 7 
7 9 4 3 5 2 
2 6 1 
1 7 
7 8 9
Case #4:
9 1 8 2 7 3 
3 6...

result:

ok OK, 20000 cases

Test #21:

score: 0
Accepted
time: 24ms
memory: 3716kb

input:

5000
13 12
5 8 9 7 5 4 10 10 7 9 2 2
7 13
2 2 1 2 2 2 3 1 1 1 2 1 1
11 16
1 1 5 4 6 2 5 1 5 8 1 1 7 3 4 1
13 17
4 1 9 1 8 1 7 6 4 8 2 8 5 8 4 1 1
5 6
1 2 1 2 2 2
9 9
5 4 5 4 5 1 6 1 5
17 23
4 9 1 10 5 8 8 7 4 11 2 4 6 3 6 7 11 3 10 7 4 5 1
13 14
10 9 1 1 1 10 3 8 8 10 3 3 10 1
7 8
4 1 4 1 4 3 2 2
19...

output:

Case #1:
13 1 12 2 11 3 
3 10 4 9 5 8 6 7 13 
13 2 1 3 12 4 11 5 10 6 
6 9 7 8 13 3 2 4 
4 1 5 12 6 11 
11 7 10 8 9 
9 13 4 3 5 2 6 1 7 12 8 
8 11 9 10 13 5 4 6 3 7 2 
2 8 1 9 12 10 11 13 
13 6 5 7 4 8 3 9 2 10 
10 1 11 
11 12 13
Case #2:
7 1 6 
6 2 5 
5 3 
3 4 7 
7 2 1 
1 3 6 
6 4 5 7 
7 3 
3 2 
2 ...

result:

ok OK, 5000 cases

Test #22:

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

input:

2000
27 44
5 15 4 6 7 14 9 2 1 24 9 4 12 6 13 23 7 3 21 2 5 2 3 20 8 12 10 21 3 1 6 8 8 4 5 3 19 1 10 7 4 1 1 2
29 31
25 8 18 22 7 7 25 9 26 25 6 11 20 1 7 9 11 14 23 20 1 13 16 1 22 23 14 6 13 1 2
27 27
16 24 6 12 3 3 22 2 24 12 6 10 18 14 8 21 20 14 15 4 23 20 2 14 11 23 4
29 39
15 19 3 7 1 13 20 ...

output:

Case #1:
27 1 26 2 25 3 
3 24 4 23 5 22 6 21 7 20 8 19 9 18 10 17 
17 11 16 12 15 
15 13 14 27 2 1 3 
3 26 4 25 5 24 6 23 
23 7 22 8 21 9 20 10 19 11 18 12 17 13 16 
16 14 15 27 3 2 4 1 5 26 
26 6 25 
25 7 
7 24 8 23 9 22 10 21 11 20 12 19 13 18 14 17 15 16 27 4 3 5 2 6 1 
1 7 26 8 25 9 24 10 23 11 ...

result:

ok OK, 2000 cases

Test #23:

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

input:

800
9 11
5 5 4 1 1 5 5 6 2 1 1
11 14
5 7 5 1 3 3 6 8 3 7 2 3 1 1
19 22
14 10 8 2 9 12 13 2 6 5 8 5 5 1 12 1 10 13 10 2 14 9
9 9
6 5 3 4 3 4 4 6 1
5 7
2 1 1 2 1 2 1
5 7
1 2 2 2 1 1 1
31 29
20 8 18 13 1 24 12 9 12 19 24 25 21 23 6 27 12 10 17 19 23 26 23 5 28 14 11 2 13
49 48
42 46 45 12 5 24 16 28 40...

output:

Case #1:
9 1 8 2 7 3 
3 6 4 5 9 2 
2 1 3 8 4 
4 7 
7 5 
5 6 9 3 2 4 
4 1 5 8 6 7 
7 9 4 3 5 2 6 
6 1 7 
7 8 
8 9
Case #2:
11 1 10 2 9 3 
3 8 4 7 5 6 11 2 
2 1 3 10 4 9 
9 5 
5 8 6 7 
7 11 3 2 
2 4 1 5 10 6 9 
9 7 8 11 4 3 5 2 6 
6 1 7 10 
10 8 9 11 5 4 6 3 
3 7 2 
2 8 1 9 
9 10 
10 11
Case #3:
19 1 ...

result:

ok OK, 800 cases

Test #24:

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

input:

200
23 26
6 17 15 16 8 5 3 20 8 17 16 8 10 10 10 10 14 1 16 12 7 6 2 4 10 2
47 45
40 15 13 24 37 4 37 8 27 44 12 11 38 19 41 26 22 33 13 26 20 40 39 37 21 16 32 14 9 8 32 36 43 28 29 4 26 38 23 34 5 23 17 16 1
11 12
4 6 7 7 8 4 8 3 1 2 3 2
89 89
57 9 68 20 45 8 78 59 16 83 72 8 42 39 76 76 28 72 46 ...

output:

Case #1:
23 1 22 2 21 3 20 
20 4 19 5 18 6 17 7 16 8 15 9 14 10 13 11 12 23 
23 2 1 3 22 4 21 5 20 6 19 7 18 8 17 9 
9 16 10 15 11 14 12 13 23 3 2 4 1 5 22 6 21 
21 7 20 8 19 9 18 10 17 
17 11 16 12 15 13 
13 14 23 4 
4 3 5 2 6 1 7 22 8 21 9 20 10 19 11 18 12 17 13 16 14 
14 15 23 5 4 6 3 7 2 
2 8 1...

result:

ok OK, 200 cases

Test #25:

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

input:

8
123 123
11 68 57 31 101 57 58 24 104 69 103 1 3 32 74 103 13 86 90 112 64 109 25 68 60 102 89 50 112 37 53 93 24 115 93 21 56 82 80 13 71 54 94 16 6 57 20 39 54 76 48 57 75 35 63 11 86 102 32 20 65 15 81 15 98 14 102 57 92 94 46 104 56 60 57 120 31 114 23 111 15 96 68 93 50 26 114 79 103 59 106 60...

output:

Case #1:
123 1 122 2 121 3 120 4 119 5 118 6 
6 117 7 116 8 115 9 114 10 113 11 112 12 111 13 110 14 109 15 108 16 107 17 106 18 105 19 104 20 103 21 102 22 101 23 100 24 99 25 98 26 97 27 96 28 95 29 94 30 93 31 92 32 91 33 90 34 89 35 88 36 87 37 86 38 85 39 84 40 
40 83 41 82 42 81 43 80 44 79 45...

result:

ok OK, 8 cases

Test #26:

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

input:

2
931 941
37 625 158 286 652 892 205 242 367 627 914 33 501 700 280 117 693 593 389 547 807 758 160 565 24 601 784 551 322 749 463 504 681 221 8 857 511 554 45 797 828 538 779 876 868 475 607 43 161 692 514 687 717 420 610 570 389 112 587 551 890 101 128 371 621 186 263 926 332 130 21 898 311 436 32...

output:

Case #1:
931 1 930 2 929 3 928 4 927 5 926 6 925 7 924 8 923 9 922 10 921 11 920 12 919 13 918 14 917 15 916 16 915 17 914 18 913 19 
19 912 20 911 21 910 22 909 23 908 24 907 25 906 26 905 27 904 28 903 29 902 30 901 31 900 32 899 33 898 34 897 35 896 36 895 37 894 38 893 39 892 40 891 41 890 42 88...

result:

ok OK, 2 cases

Test #27:

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

input:

2
57 60
24 19 36 48 4 43 19 52 8 52 6 17 10 19 18 41 20 36 4 41 38 34 24 26 29 48 15 37 10 7 4 8 16 43 8 9 27 38 12 19 52 31 9 54 49 15 51 24 43 54 29 46 12 40 17 36 50 12 2 1
643 646
230 5 469 246 610 243 221 411 352 98 56 243 481 622 240 492 349 336 548 102 516 326 468 563 272 363 99 156 468 562 5...

output:

Case #1:
57 1 56 2 55 3 54 4 53 5 52 6 51 7 50 8 49 9 48 10 47 11 46 12 45 
45 13 44 14 43 15 42 16 41 17 40 18 39 19 38 20 37 21 36 22 
22 35 23 34 24 33 25 32 26 31 27 30 28 29 57 2 1 3 56 4 55 5 54 6 53 7 52 8 51 9 50 10 49 11 48 12 47 
47 13 46 14 45 15 44 16 43 17 42 18 41 19 40 20 39 21 38 22 ...

result:

ok OK, 2 cases

Test #28:

score: 0
Accepted
time: 27ms
memory: 3692kb

input:

2
939 935
96 887 857 430 351 403 292 594 392 287 841 710 428 591 389 218 248 134 924 445 162 52 491 820 314 711 207 112 874 201 908 448 799 207 6 690 782 141 749 623 628 466 495 700 861 588 791 93 364 36 834 772 774 619 615 46 358 5 493 382 121 891 71 564 219 201 496 495 883 781 546 394 548 936 643 ...

output:

Case #1:
939 1 938 2 937 3 936 4 935 5 934 6 933 7 932 8 931 9 930 10 929 11 928 12 927 13 926 14 925 15 924 16 923 17 922 18 921 19 920 20 919 21 918 22 917 23 916 24 915 25 914 26 913 27 912 28 911 29 910 30 909 31 908 32 907 33 906 34 905 35 904 36 903 37 902 38 901 39 900 40 899 41 898 42 897 43...

result:

ok OK, 2 cases

Test #29:

score: 0
Accepted
time: 27ms
memory: 3748kb

input:

2
763 776
379 463 566 538 49 15 664 613 227 59 631 331 374 87 4 325 559 80 459 107 528 340 427 420 99 171 492 465 572 316 723 598 423 135 14 156 604 99 648 509 657 449 715 50 157 652 701 521 644 529 420 385 173 55 758 649 311 135 744 47 370 488 40 405 722 284 443 676 57 552 283 241 26 449 522 201 10...

output:

Case #1:
763 1 762 2 761 3 760 4 759 5 758 6 757 7 756 8 755 9 754 10 753 11 752 12 751 13 750 14 749 15 748 16 747 17 746 18 745 19 744 20 743 21 742 22 741 23 740 24 739 25 738 26 737 27 736 28 735 29 734 30 733 31 732 32 731 33 730 34 729 35 728 36 727 37 726 38 725 39 724 40 723 41 722 42 721 43...

result:

ok OK, 2 cases

Test #30:

score: 0
Accepted
time: 42ms
memory: 3692kb

input:

2
999 504
991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 991 99...

output:

Case #1:
999 1 998 2 997 3 996 4 995 5 994 6 993 7 992 8 991 9 990 10 989 11 988 12 987 13 986 14 985 15 984 16 983 17 982 18 981 19 980 20 979 21 978 22 977 23 976 24 975 25 974 26 973 27 972 28 971 29 970 30 969 31 968 32 967 33 966 34 965 35 964 36 963 37 962 38 961 39 960 40 959 41 958 42 957 43...

result:

ok OK, 2 cases

Test #31:

score: 0
Accepted
time: 34ms
memory: 3732kb

input:

2
999 501
996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 996 99...

output:

Case #1:
999 1 998 2 997 3 996 4 995 5 994 6 993 7 992 8 991 9 990 10 989 11 988 12 987 13 986 14 985 15 984 16 983 17 982 18 981 19 980 20 979 21 978 22 977 23 976 24 975 25 974 26 973 27 972 28 971 29 970 30 969 31 968 32 967 33 966 34 965 35 964 36 963 37 962 38 961 39 960 40 959 41 958 42 957 43...

result:

ok OK, 2 cases

Test #32:

score: 0
Accepted
time: 31ms
memory: 3684kb

input:

20000
9 11
3 2 2 5 1 5 4 4 3 4 3
5 6
1 2 2 2 1 2
9 12
6 1 1 2 1 6 6 3 5 2 1 2
9 12
5 2 6 4 1 1 6 1 2 1 5 2
7 10
2 1 2 3 1 4 2 4 1 1
7 9
3 2 2 3 1 2 1 4 3
5 8
1 2 2 1 1 1 1 1
7 8
2 2 3 4 3 4 2 1
5 7
2 1 1 1 2 2 1
7 9
2 2 3 4 3 2 2 2 1
5 6
2 2 1 2 2 1
5 6
2 1 1 2 2 2
5 7
2 1 1 2 2 1 1
9 11
5 6 3 5 2 2...

output:

Case #1:
9 1 8 2 
2 7 3 
3 6 4 
4 5 9 2 1 3 
3 8 
8 4 7 5 6 9 
9 3 2 4 1 
1 5 8 6 7 
7 9 4 3 
3 5 2 6 1 
1 7 8 9
Case #2:
5 1 
1 4 2 
2 3 5 
5 2 1 
1 3 
3 4 5
Case #3:
9 1 8 2 7 3 6 
6 4 
4 5 
5 9 2 
2 1 
1 3 8 4 7 5 6 
6 9 3 2 4 1 5 
5 8 6 7 
7 9 4 3 5 2 
2 6 1 
1 7 
7 8 9
Case #4:
9 1 8 2 7 3 
3 6...

result:

ok OK, 20000 cases

Test #33:

score: 0
Accepted
time: 177ms
memory: 3748kb

input:

18968
51 55
2 9 14 17 31 21 36 21 16 40 32 9 25 5 48 1 25 6 38 13 14 47 2 33 38 42 37 30 35 24 44 22 28 39 6 9 13 47 34 34 19 24 11 10 29 14 6 40 42 18 33 12 18 9 3
51 57
36 31 7 48 37 19 8 35 30 15 41 5 16 27 17 14 42 38 9 42 48 44 4 5 46 1 24 41 1 14 38 35 14 29 36 8 8 21 19 7 25 44 43 1 32 24 7 1...

output:

Case #1:
51 1 50 
50 2 49 3 48 4 47 5 46 6 
6 45 7 44 8 43 9 42 10 41 11 40 12 39 13 
13 38 14 37 15 36 16 35 17 34 18 33 19 32 20 31 21 30 
30 22 29 23 28 24 27 25 26 51 2 1 3 50 4 49 5 48 6 47 7 46 8 45 9 44 10 43 11 42 12 41 
41 13 40 14 39 15 38 16 37 17 36 18 35 19 34 20 33 21 32 22 31 23 
23 3...

result:

ok OK, 18968 cases