Solutions are presented as using the least memory and the fastest execution time. It also takes the top
10 most recent solutions from each language. If you want to limit to a specific index, click the
"Solved" button and go to that problem.
Problems
B'Misha has a square n x n matrix, where the number in row i and column j is equal to a_{i, j} . Misha wants to modify the matrix to contain exactly k distinct integers. To achieve this goal, Misha can perform the following operation zero or more times: Please find the minimum number of operations that Misha needs to achieve his goal. The first input line contains two integers n and k ( 1 <= q n <= q 500, 1 <= q k <= q n^2 ) -- the size of the matrix and the desired amount of distinct elements in the matrix. Then n lines follows. The i -th of them contains n integers a_{i, 1}, a_{i, 2}, ldots, a_{i, n} ( 1 <= q a_{i,j} <= q n^2 ) -- the elements of the i -th row of the matrix. Output one integer -- the minimum number of operations required. In the first test case the answer is 1 , because one can change the value in the bottom right corner of the matrix to 1 . The resulting matrix can be found below: In the second test case the answer is 2 . First, one can change the entire matrix to contain only 1 s, and the change the value of any single cell to 2 . One of the possible resulting matrices is displayed below: '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
168861844 |
mtyzjm |
E |
Aug. 18, 2022, 3:29 p.m. |
OK |
GNU C++14 |
TESTS |
84 |
187 |
11571200 |
|
|
168862248 |
sdfzzsy |
E |
Aug. 18, 2022, 3:30 p.m. |
OK |
GNU C++14 |
TESTS |
84 |
374 |
10752000 |
|
|
168906152 |
meyi |
E |
Aug. 19, 2022, 1:07 a.m. |
OK |
GNU C++14 |
TESTS |
85 |
390 |
3072000 |
|
|
168907276 |
nuistdzq |
E |
Aug. 19, 2022, 1:31 a.m. |
OK |
GNU C++14 |
TESTS |
85 |
405 |
2048000 |
|
|
168914993 |
angry_face |
E |
Aug. 19, 2022, 3:45 a.m. |
OK |
GNU C++14 |
TESTS |
85 |
639 |
2867200 |
|
|
168913545 |
cqbz163003gzm |
E |
Aug. 19, 2022, 3:23 a.m. |
OK |
GNU C++14 |
TESTS |
85 |
670 |
7065600 |
|
|
168871208 |
meyi |
E |
Aug. 18, 2022, 4:52 p.m. |
OK |
GNU C++14 |
TESTS |
84 |
702 |
3072000 |
|
|
168919542 |
08kevin |
E |
Aug. 19, 2022, 4:59 a.m. |
OK |
GNU C++14 |
TESTS |
85 |
1060 |
12390400 |
|
|
168905840 |
luogubot |
E |
Aug. 19, 2022, 1 a.m. |
OK |
GNU C++14 |
TESTS |
85 |
1092 |
3174400 |
|
|
168912865 |
zzlzzlzzl |
E |
Aug. 19, 2022, 3:13 a.m. |
OK |
GNU C++14 |
TESTS |
85 |
1263 |
8192000 |
|
|
168870905 |
dreamoon_love_AA |
E |
Aug. 18, 2022, 4:49 p.m. |
OK |
GNU C++17 |
TESTS |
84 |
467 |
10342400 |
|
|
168920577 |
dsamain |
E |
Aug. 19, 2022, 5:12 a.m. |
OK |
GNU C++17 |
TESTS |
85 |
546 |
12288000 |
|
|
168882043 |
serotonin |
E |
Aug. 18, 2022, 6:13 p.m. |
OK |
GNU C++17 |
TESTS |
84 |
966 |
5836800 |
|
|
168913633 |
pkkkkkkk |
E |
Aug. 19, 2022, 3:24 a.m. |
OK |
GNU C++17 |
TESTS |
85 |
1091 |
8089600 |
|
|
168871895 |
RUSH_D_CAT |
E |
Aug. 18, 2022, 4:56 p.m. |
OK |
GNU C++17 |
TESTS |
84 |
1091 |
11264000 |
|
|
168868650 |
yyljkydr |
E |
Aug. 18, 2022, 4:39 p.m. |
OK |
GNU C++17 |
TESTS |
84 |
1123 |
6451200 |
|
|
168881883 |
vjudge2 |
E |
Aug. 18, 2022, 6:11 p.m. |
OK |
GNU C++17 |
TESTS |
84 |
1279 |
15667200 |
|
|
168912652 |
Asd_Orin |
E |
Aug. 19, 2022, 3:09 a.m. |
OK |
GNU C++17 |
TESTS |
85 |
1310 |
7270400 |
|
|
168868676 |
DerekFeng |
E |
Aug. 18, 2022, 4:39 p.m. |
OK |
GNU C++17 |
TESTS |
84 |
1325 |
9523200 |
|
|
168861604 |
Larry0101 |
E |
Aug. 18, 2022, 3:28 p.m. |
OK |
GNU C++17 |
TESTS |
84 |
1419 |
3072000 |
|
|
168914131 |
hehezhoutxdy |
E |
Aug. 19, 2022, 3:31 a.m. |
OK |
GNU C++17 (64) |
TESTS |
85 |
420 |
2048000 |
|
|
168914045 |
dXqwq |
E |
Aug. 19, 2022, 3:30 a.m. |
OK |
GNU C++17 (64) |
TESTS |
85 |
420 |
2048000 |
|
|
168878321 |
TheLostCookie |
E |
Aug. 18, 2022, 5:42 p.m. |
OK |
GNU C++17 (64) |
TESTS |
84 |
436 |
3174400 |
|
|
168915484 |
snowy2002 |
E |
Aug. 19, 2022, 3:54 a.m. |
OK |
GNU C++17 (64) |
TESTS |
85 |
763 |
5120000 |
|
|
168910901 |
zhangmj2008 |
E |
Aug. 19, 2022, 2:39 a.m. |
OK |
GNU C++17 (64) |
TESTS |
85 |
1154 |
7475200 |
|
|
168862232 |
dimss |
E |
Aug. 18, 2022, 3:30 p.m. |
OK |
GNU C++17 (64) |
TESTS |
84 |
1356 |
19558400 |
|
|
168889636 |
OMG_wc |
E |
Aug. 18, 2022, 7:31 p.m. |
OK |
GNU C++17 (64) |
TESTS |
85 |
1450 |
7168000 |
|
|
168921715 |
Pointy |
E |
Aug. 19, 2022, 5:26 a.m. |
OK |
GNU C++17 (64) |
TESTS |
85 |
1481 |
7168000 |
|
|
168899341 |
OMG_wc |
E |
Aug. 18, 2022, 10:08 p.m. |
OK |
GNU C++17 (64) |
TESTS |
85 |
1528 |
7168000 |
|
|
168904982 |
kongfang89 |
E |
Aug. 19, 2022, 12:40 a.m. |
OK |
GNU C++17 (64) |
TESTS |
85 |
1684 |
7270400 |
|
|
168870718 |
chunjiangchaoshui |
E |
Aug. 18, 2022, 4:48 p.m. |
OK |
GNU C++20 (64) |
TESTS |
84 |
373 |
3072000 |
|
|
168913432 |
ComplexPug |
E |
Aug. 19, 2022, 3:21 a.m. |
OK |
GNU C++20 (64) |
TESTS |
85 |
421 |
9420800 |
|
|
168897980 |
AnandOza |
E |
Aug. 18, 2022, 9:36 p.m. |
OK |
GNU C++20 (64) |
TESTS |
85 |
763 |
3174400 |
|
|
168862010 |
Be_dos |
E |
Aug. 18, 2022, 3:29 p.m. |
OK |
GNU C++20 (64) |
TESTS |
84 |
779 |
67584000 |
|
|
168919483 |
louhao088088 |
E |
Aug. 19, 2022, 4:58 a.m. |
OK |
GNU C++20 (64) |
TESTS |
85 |
904 |
3072000 |
|
|
168907351 |
czhang2718 |
E |
Aug. 19, 2022, 1:32 a.m. |
OK |
GNU C++20 (64) |
TESTS |
85 |
951 |
6041600 |
|
|
168916027 |
pbpbppb |
E |
Aug. 19, 2022, 4:03 a.m. |
OK |
GNU C++20 (64) |
TESTS |
85 |
1216 |
7270400 |
|
|
168895463 |
yfhuang |
E |
Aug. 18, 2022, 8:49 p.m. |
OK |
GNU C++20 (64) |
TESTS |
85 |
1232 |
6144000 |
|
|
168873918 |
A_G |
E |
Aug. 18, 2022, 5:09 p.m. |
OK |
GNU C++20 (64) |
TESTS |
84 |
1232 |
7577600 |
|
|
168878002 |
shadow221213 |
E |
Aug. 18, 2022, 5:40 p.m. |
OK |
GNU C++20 (64) |
TESTS |
84 |
1263 |
8704000 |
|
|
168868592 |
sansen |
E |
Aug. 18, 2022, 4:38 p.m. |
OK |
Rust 2021 |
TESTS |
84 |
499 |
8294400 |
|
|
168884358 |
Niklassanden |
E |
Aug. 18, 2022, 6:34 p.m. |
OK |
Rust 2021 |
TESTS |
85 |
1731 |
28672000 |
|
|
168883798 |
Niklassanden |
E |
Aug. 18, 2022, 6:29 p.m. |
OK |
Rust 2021 |
TESTS |
85 |
2776 |
28672000 |
|
|
remove filters
Back to search problems