QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#616157#957. Assignment ProblemApteryxxTL 3664ms3864kbC++201.1kb2024-10-05 22:54:552024-10-05 22:54:56

Judging History

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

  • [2024-10-05 22:54:56]
  • 评测
  • 测评结果:TL
  • 用时:3664ms
  • 内存:3864kb
  • [2024-10-05 22:54:55]
  • 提交

answer

#include <bits/stdc++.h>

#ifdef LOCAL
#include <debug.h>
#else
#define debug(...)
#define debug_arr(...)
#define debug_endl(...)
#endif

void solve() {
	int n, m;
	std::cin >> n >> m;

	std::vector p(m, std::vector<int>(n));
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < n; j++) {
			std::cin >> p[i][j];
			p[i][j]--;
		}
	}

	std::vector vis(n, false), ans(n, false);
	std::vector<int> o(m);
	std::iota(o.begin(), o.end(), 0);

	do {
		std::vector<int> a(m);
		for (int i : o) {
			a[i] = *std::ranges::find_if(p[i], [&](int x) -> bool {
				return !vis[x];
			});
			vis[a[i]] = ans[a[i]] = true;
		}
		for (int i = 0; i < m; i++) {
			vis[a[i]] = false;
		}
	} while (std::next_permutation(o.begin(), o.end()));

	std::cout << std::ranges::count(ans, true) << "\n";
	for (int i = 0; i < n; i++) {
		if (ans[i]) {
			std::cout << i + 1 << " ";
		}
	}
	std::cout << "\n";
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.setf(std::ios::fixed);
	std::cout.precision(10);

	solve();

	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4 2
1 2 4 3
1 3 4 2

output:

3
1 2 3 

result:

ok 4 number(s): "3 1 2 3"

Test #2:

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

input:

4 2
1 4 3 2
2 3 4 1

output:

2
1 2 

result:

ok 3 number(s): "2 1 2"

Test #3:

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

input:

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

output:

6
2 3 4 5 6 10 

result:

ok 7 numbers

Test #4:

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

input:

1000 5
890 508 800 793 148 422 569 817 41 303 52 946 691 273 719 918 920 464 640 596 905 187 425 483 292 290 987 343 145 888 754 348 894 454 818 654 225 688 369 616 785 784 294 485 551 272 798 668 451 565 534 122 809 329 168 772 282 467 112 886 66 965 926 521 836 297 305 386 288 717 255 151 568 43 9...

output:

5
255 279 360 643 890 

result:

ok 6 numbers

Test #5:

score: 0
Accepted
time: 29ms
memory: 3532kb

input:

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

output:

11
1 2 3 6 7 8 9 10 11 14 15 

result:

ok 12 numbers

Test #6:

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

input:

1000 9
2 700 292 58 153 387 688 770 589 533 94 442 35 706 75 300 881 898 10 70 377 892 433 313 983 12 494 733 53 179 502 495 44 606 539 647 646 672 520 69 997 239 403 426 944 18 979 81 782 133 671 792 336 327 630 38 821 775 456 25 852 656 711 16 529 169 935 318 140 550 759 471 250 546 742 951 440 35...

output:

9
2 185 383 431 439 728 852 921 983 

result:

ok 10 numbers

Test #7:

score: 0
Accepted
time: 281ms
memory: 3608kb

input:

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

output:

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

result:

ok 15 numbers

Test #8:

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

input:

1000 10
22 671 550 260 689 981 935 62 270 596 224 202 156 937 715 520 812 378 400 702 546 517 344 236 235 949 109 282 294 106 652 956 994 380 366 830 810 283 95 304 231 750 728 189 495 388 170 348 64 462 522 674 307 309 752 371 919 384 430 313 377 39 35 237 941 310 976 497 234 683 817 525 989 514 73...

output:

10
22 247 521 534 590 658 671 682 763 820 

result:

ok 11 numbers

Test #9:

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

input:

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

output:

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

result:

ok 16 numbers

Test #10:

score: 0
Accepted
time: 2705ms
memory: 3576kb

input:

1000 11
780 479 30 770 201 920 302 972 558 420 542 251 706 46 232 559 713 222 477 633 791 957 740 202 314 837 353 928 724 265 589 357 458 673 332 910 429 946 714 697 110 206 561 855 22 216 994 423 882 830 564 149 987 930 921 409 1000 329 551 708 878 993 33 480 67 787 700 826 412 927 735 854 829 229 ...

output:

11
111 224 285 384 431 508 516 708 780 803 955 

result:

ok 12 numbers

Test #11:

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

input:

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

output:

5
1 2 3 4 5 

result:

ok 6 numbers

Test #12:

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

input:

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

output:

5
1 2 3 4 5 

result:

ok 6 numbers

Test #13:

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

input:

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

output:

7
1 2 4 5 8 9 10 

result:

ok 8 numbers

Test #14:

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

input:

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

output:

5
2 3 7 9 10 

result:

ok 6 numbers

Test #15:

score: 0
Accepted
time: 47ms
memory: 3608kb

input:

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

output:

9
1 2 3 4 5 6 7 8 9 

result:

ok 10 numbers

Test #16:

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

input:

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

output:

9
1 2 3 4 5 6 7 8 9 

result:

ok 10 numbers

Test #17:

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

input:

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

output:

10
1 2 3 6 7 9 10 12 18 19 

result:

ok 11 numbers

Test #18:

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

input:

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

output:

14
1 2 3 4 5 6 7 8 12 13 14 16 17 20 

result:

ok 15 numbers

Test #19:

score: 0
Accepted
time: 526ms
memory: 3544kb

input:

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

output:

10
1 2 3 4 5 6 7 8 9 10 

result:

ok 11 numbers

Test #20:

score: 0
Accepted
time: 528ms
memory: 3544kb

input:

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

output:

10
1 2 3 4 5 6 7 8 9 10 

result:

ok 11 numbers

Test #21:

score: 0
Accepted
time: 266ms
memory: 3528kb

input:

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

output:

12
1 2 3 4 5 8 9 10 12 13 15 17 

result:

ok 13 numbers

Test #22:

score: 0
Accepted
time: 260ms
memory: 3480kb

input:

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

output:

14
1 2 4 5 7 8 9 10 11 12 14 16 18 20 

result:

ok 15 numbers

Test #23:

score: 0
Accepted
time: 525ms
memory: 3808kb

input:

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

output:

10
1 2 3 4 5 6 7 8 9 10 

result:

ok 11 numbers

Test #24:

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

input:

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

output:

10
1 2 3 4 5 6 7 8 9 10 

result:

ok 11 numbers

Test #25:

score: 0
Accepted
time: 465ms
memory: 3532kb

input:

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

output:

17
1 2 3 4 5 6 7 8 9 24 28 39 46 54 62 77 80 

result:

ok 18 numbers

Test #26:

score: 0
Accepted
time: 289ms
memory: 3540kb

input:

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

output:

13
1 3 5 6 7 8 9 10 13 24 34 64 92 

result:

ok 14 numbers

Test #27:

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

input:

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

output:

11
1 5 14 21 38 41 65 79 89 98 99 

result:

ok 12 numbers

Test #28:

score: 0
Accepted
time: 224ms
memory: 3576kb

input:

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

output:

10
4 8 18 19 48 58 61 80 83 94 

result:

ok 11 numbers

Test #29:

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

input:

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

output:

11
1 2 19 39 40 41 53 69 85 90 94 

result:

ok 12 numbers

Test #30:

score: 0
Accepted
time: 235ms
memory: 3540kb

input:

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

output:

11
5 10 19 24 66 68 69 73 74 75 98 

result:

ok 12 numbers

Test #31:

score: -100
Time Limit Exceeded

input:

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

output:


result: