Codeforces Round 1024 (Div. 1)

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.

ContestId
Name
Phase
Frozen
Duration (Seconds)
Relative Time
Start Time
2101 Codeforces Round 1024 (Div. 1) FINISHED False 9000 29431523 May 11, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 13366 ) A Mex in the Grid PROGRAMMING constructive algorithms implementation

You are given (n^2) cards with values from (0) to (n^2-1). You are to arrange them in a (n) by (n) grid such that there is exactly one card in each cell. The MEX (minimum excluded value) of a subgrid(^{\text{∗}}) is defined as the smallest non-negative integer that does not appear in the subgrid. Your task is to arrange the cards such that the sum of MEX values over all (\left(\frac{n(n+1)}{2}\right)^2) subgrids is maximized. (^{\text{∗}})A subgrid of a (n) by (n) grid is specified by four numbers (l_1, r_1, l_2, r_2) satisfying (1\le l_1\le r_1\le n) and (1\le l_2\le r_2\le n). The element in the (i)-th row and the (j)-th column of the grid is part of the subgrid if and only if (l_1\le i\le r_1) and (l_2\le j\le r_2). Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 100)). The description of the test cases follows. The first line of each test case contains a single integer (n) ((1\le n\le 500)) — the side length of the grid. It is guaranteed that the sum of (n) over all test cases does not exceed (1000). For each test case, output (n) lines, each containing (n) integers representing the elements of the grid. If there are multiple answers, you can output any of them. In the first test case, one valid arrangement is: There are (9) subgrids in total, and the (4) of them with non-zero MEX are shown below: 0 values: (0) — MEX: (1) 0 1 values: (0, 1) — MEX: (2) 0 2 values: (0, 2) — MEX: (1) 0 1 2 3 values: (0, 1, 2, 3) — MEX: (4) The sum of MEX over all subgrids would be (1+2+1+4 = 8). It can be proven that no other arrangements have a larger sum of MEX values.

Tutorials

142788

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
319329508 og.kostya A May 12, 2025, 5:25 a.m. OK C# 10 TESTS 26 108 5120000
319229522 tangyigeng2028 A May 11, 2025, 2:57 p.m. OK C++17 (GCC 7-32) TESTS 26 78 3276800
319238007 shaikhmubin A May 11, 2025, 3:08 p.m. OK C++17 (GCC 7-32) TESTS 26 93 102400
319329752 TianyiWei A May 12, 2025, 5:28 a.m. OK C++17 (GCC 7-32) TESTS 26 93 1024000
319235807 _chroneZ A May 11, 2025, 3:05 p.m. OK C++17 (GCC 7-32) TESTS 26 93 4096000
319225160 lsflsf2023 A May 11, 2025, 2:51 p.m. OK C++17 (GCC 7-32) TESTS 26 93 29184000
319299303 WorldShine02 A May 11, 2025, 6:46 p.m. OK C++17 (GCC 7-32) TESTS 26 108 102400
319270821 9ovem A May 11, 2025, 4:05 p.m. OK C++17 (GCC 7-32) TESTS 26 108 102400
319242607 lwm7708 A May 11, 2025, 3:16 p.m. OK C++17 (GCC 7-32) TESTS 26 108 102400
319233800 hisoka44 A May 11, 2025, 3:02 p.m. OK C++17 (GCC 7-32) TESTS 26 108 102400
319225946 pkhaustov A May 11, 2025, 2:52 p.m. OK C++17 (GCC 7-32) TESTS 26 108 102400
319332052 Raiden_Mei_ A May 12, 2025, 5:53 a.m. OK C++20 (GCC 13-64) TESTS 26 62 1126400
319227381 Enoch006 A May 11, 2025, 2:54 p.m. OK C++20 (GCC 13-64) TESTS 26 62 16281600
319287396 oldEight A May 11, 2025, 4:54 p.m. OK C++20 (GCC 13-64) TESTS 26 77 0
319245455 asdhhjlckdja A May 11, 2025, 3:20 p.m. OK C++20 (GCC 13-64) TESTS 26 77 0
319225866 HusseinFarhat A May 11, 2025, 2:52 p.m. OK C++20 (GCC 13-64) TESTS 26 77 0
319223244 irogotm A May 11, 2025, 2:49 p.m. OK C++20 (GCC 13-64) TESTS 26 77 0
319221303 TheScrasse A May 11, 2025, 2:46 p.m. OK C++20 (GCC 13-64) TESTS 26 77 0
319217577 happypotato A May 11, 2025, 2:41 p.m. OK C++20 (GCC 13-64) TESTS 26 77 0
319217254 siganai A May 11, 2025, 2:41 p.m. OK C++20 (GCC 13-64) TESTS 26 77 0
319216381 tourist A May 11, 2025, 2:39 p.m. OK C++20 (GCC 13-64) TESTS 26 77 0
319311714 Mamedov A May 11, 2025, 10:45 p.m. OK C++23 (GCC 14-64, msys2) TESTS 26 62 102400
319216154 maspy A May 11, 2025, 2:39 p.m. OK C++23 (GCC 14-64, msys2) TESTS 26 62 307200
319242421 cuongaaaa A May 11, 2025, 3:15 p.m. OK C++23 (GCC 14-64, msys2) TESTS 26 77 0
319227276 bangan A May 11, 2025, 2:54 p.m. OK C++23 (GCC 14-64, msys2) TESTS 26 77 0
319217839 mooyomooyo A May 11, 2025, 2:42 p.m. OK C++23 (GCC 14-64, msys2) TESTS 26 77 0
319217053 Nyaan A May 11, 2025, 2:40 p.m. OK C++23 (GCC 14-64, msys2) TESTS 26 77 0
319325211 harshcooljn A May 12, 2025, 4:24 a.m. OK C++23 (GCC 14-64, msys2) TESTS 26 77 102400
319324353 PeruvianCartel A May 12, 2025, 4:08 a.m. OK C++23 (GCC 14-64, msys2) TESTS 26 77 102400
319317895 enslaved A May 12, 2025, 2:03 a.m. OK C++23 (GCC 14-64, msys2) TESTS 26 77 102400
319303241 ManTis7 A May 11, 2025, 7:38 p.m. OK C++23 (GCC 14-64, msys2) TESTS 26 77 102400
319217291 hos.lyric A May 11, 2025, 2:41 p.m. OK D TESTS 26 389 10649600
319226927 ghj1222 A May 11, 2025, 2:53 p.m. OK GNU C11 TESTS 26 77 5324800
319223960 pengin_2000 A May 11, 2025, 2:50 p.m. OK GNU C11 TESTS 26 155 1024000
319325230 muradbhai A May 12, 2025, 4:24 a.m. OK GNU C11 TESTS 26 1999 1024000
319324901 muradbhai A May 12, 2025, 4:18 a.m. OK GNU C11 TESTS 26 1999 1024000
319255856 cyclop5 A May 11, 2025, 3:39 p.m. OK Go TESTS 26 155 8089600
319225728 Dominion948 A May 11, 2025, 2:52 p.m. OK Go TESTS 26 156 14643200
319225928 lyongwolf A May 11, 2025, 2:52 p.m. OK Java 21 TESTS 26 280 1536000
319225117 Lilypad A May 11, 2025, 2:51 p.m. OK Java 21 TESTS 26 343 1843200
319219605 rakshit2611 A May 11, 2025, 2:44 p.m. OK Java 21 TESTS 26 359 614400
319241117 nathanballman A May 11, 2025, 3:13 p.m. OK Java 21 TESTS 26 390 1024000
319242581 MadinaAlili A May 11, 2025, 3:16 p.m. OK Java 21 TESTS 26 1671 1433600
319222785 golions A May 11, 2025, 2:48 p.m. OK Java 8 TESTS 26 264 2560000
319331818 kasiru_69 A May 12, 2025, 5:50 a.m. OK Java 8 TESTS 26 843 0
319247609 omdeshmukh1906 A May 11, 2025, 3:24 p.m. OK Java 8 TESTS 26 1015 5734400
319218360 Tlatoani A May 11, 2025, 2:43 p.m. OK Kotlin 1.9 TESTS 26 296 12492800
319222292 Toinfinity A May 11, 2025, 2:48 p.m. OK PyPy 3 TESTS 26 530 10444800
319222307 ow3nLLL A May 11, 2025, 2:48 p.m. OK PyPy 3-64 TESTS 26 155 20377600
319220222 Mukundan314 A May 11, 2025, 2:45 p.m. OK PyPy 3-64 TESTS 26 156 12083200
319331778 fawnPersona A May 12, 2025, 5:50 a.m. OK PyPy 3-64 TESTS 26 171 7782400
319222993 bribritt A May 11, 2025, 2:48 p.m. OK PyPy 3-64 TESTS 26 171 13004800
319217739 Maruzensky A May 11, 2025, 2:42 p.m. OK PyPy 3-64 TESTS 26 186 7475200
319230276 VulcanForge A May 11, 2025, 2:58 p.m. OK PyPy 3-64 TESTS 26 186 8704000
319220551 kavorka A May 11, 2025, 2:46 p.m. OK PyPy 3-64 TESTS 26 187 8192000
319226919 hxu10 A May 11, 2025, 2:53 p.m. OK PyPy 3-64 TESTS 26 187 10137600
319222786 eepsilon A May 11, 2025, 2:48 p.m. OK PyPy 3-64 TESTS 26 187 10444800
319317237 bronze_coder A May 12, 2025, 1:47 a.m. OK PyPy 3-64 TESTS 26 187 10547200
319237846 Jimanbanashi A May 11, 2025, 3:08 p.m. OK Python 2 TESTS 26 296 4608000
319243629 Taghi A May 11, 2025, 3:17 p.m. OK Python 3 TESTS 26 249 24883200
319220983 shade34 A May 11, 2025, 2:46 p.m. OK Python 3 TESTS 26 655 13107200
319233743 shashanksp851 A May 11, 2025, 3:02 p.m. OK Python 3 TESTS 26 968 27545600
319322684 Spheniscine A May 12, 2025, 3:40 a.m. OK Rust 2021 TESTS 26 77 102400
319217640 sansen A May 11, 2025, 2:41 p.m. OK Rust 2021 TESTS 26 77 102400
319220716 darkkcyan A May 11, 2025, 2:46 p.m. OK Rust 2021 TESTS 26 93 0
319222029 Egor A May 11, 2025, 2:47 p.m. OK Rust 2021 TESTS 26 124 0

remove filters

Back to search problems