Codeforces Round 1030 (Div. 2)

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
2118 Codeforces Round 1030 (Div. 2) FINISHED False 7200 26666723 June 12, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 1412 ) E Grid Coloring PROGRAMMING constructive algorithms greedy sortings

There is a (n\times m) grid with each cell initially white. You have to color all the cells one-by-one. After you color a cell, all the colored cells furthest from it receive a penalty. Find a coloring order, where no cell has more than (3) penalties. Note that (n) and (m) are both odd. The distance metric used is the chessboard distance while we decide ties between cells with Manhattan distance . Formally, a cell ((x_2, y_2)) is further away than ((x_3, y_3)) from a cell ((x_1, y_1)) if one of the following holds: (\max\big(\lvert x_1 - x_2 \rvert, \lvert y_1 - y_2 \rvert\big)>\max\big(\lvert x_1 - x_3 \rvert, \lvert y_1 - y_3 \rvert\big)) (\max\big(\lvert x_1 - x_2 \rvert, \lvert y_1 - y_2 \rvert\big)=\max\big(\lvert x_1 - x_3 \rvert, \lvert y_1 - y_3 \rvert\big)) and (\lvert x_1 - x_2 \rvert + \lvert y_1 - y_2 \rvert>\lvert x_1 - x_3 \rvert + \lvert y_1 - y_3 \rvert) It can be proven that at least one solution always exists. 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 two odd integers (n) and (m) ((1 \le n, m \le 4999)) — the number of rows and columns. It is guaranteed that the sum of (n \cdot m) over all test cases does not exceed (5000). For each test case, output (n \cdot m) lines where the (i)-th line should contain the coordinates of the (i)-th cell in your coloring order. If there are multiple solutions, print any of them. The empty lines in the example output are just for increased readability. You're not required to print them. In the first test case, the grid can be colored as follows:

Tutorials

Codeforces Round 1030 (Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
324153292 nottheonion E June 12, 2025, 6:39 p.m. OK C++17 (GCC 7-32) TESTS 9 46 0
324192448 konghaojie E June 13, 2025, 4:56 a.m. OK C++17 (GCC 7-32) TESTS 9 46 0
324186944 mogulus_tt E June 13, 2025, 3:50 a.m. OK C++17 (GCC 7-32) TESTS 9 46 0
324182148 ajoymathew07 E June 13, 2025, 2:45 a.m. OK C++17 (GCC 7-32) TESTS 9 46 0
324180011 jdurie E June 13, 2025, 2:13 a.m. OK C++17 (GCC 7-32) TESTS 9 46 0
324179998 ywjylx E June 13, 2025, 2:13 a.m. OK C++17 (GCC 7-32) TESTS 9 46 0
324173714 yud08 E June 13, 2025, 12:04 a.m. OK C++17 (GCC 7-32) TESTS 9 46 0
324167553 sk1234__ E June 12, 2025, 9:24 p.m. OK C++17 (GCC 7-32) TESTS 9 46 0
324165199 -adhd- E June 12, 2025, 8:45 p.m. OK C++17 (GCC 7-32) TESTS 9 46 0
324161568 macJedi E June 12, 2025, 7:58 p.m. OK C++17 (GCC 7-32) TESTS 9 46 0
324177811 Dinprosperity E June 13, 2025, 1:37 a.m. OK C++20 (GCC 13-64) TESTS 9 30 0
324157127 littlebluepenguins E June 12, 2025, 7:06 p.m. OK C++20 (GCC 13-64) TESTS 9 46 0
324189680 zac2010 E June 13, 2025, 4:25 a.m. OK C++20 (GCC 13-64) TESTS 9 46 0
324189238 neko31662 E June 13, 2025, 4:20 a.m. OK C++20 (GCC 13-64) TESTS 9 46 0
324187282 brusgry E June 13, 2025, 3:54 a.m. OK C++20 (GCC 13-64) TESTS 9 46 0
324184113 Muschuang123 E June 13, 2025, 3:13 a.m. OK C++20 (GCC 13-64) TESTS 9 46 0
324181874 GOTKAKO E June 13, 2025, 2:41 a.m. OK C++20 (GCC 13-64) TESTS 9 46 0
324181010 StayAlone E June 13, 2025, 2:29 a.m. OK C++20 (GCC 13-64) TESTS 9 46 0
324178051 MarioYC E June 13, 2025, 1:41 a.m. OK C++20 (GCC 13-64) TESTS 9 46 0
324160802 Senku E June 12, 2025, 7:48 p.m. OK C++20 (GCC 13-64) TESTS 9 46 0
324146064 Proofy E June 12, 2025, 5:44 p.m. OK C++23 (GCC 14-64, msys2) TESTS 9 31 0
324188348 kchhillar13 E June 13, 2025, 4:08 a.m. OK C++23 (GCC 14-64, msys2) TESTS 9 46 0
324198951 Varun_3124 E June 13, 2025, 6 a.m. OK C++23 (GCC 14-64, msys2) TESTS 9 46 0
324196098 gentlecoder29 E June 13, 2025, 5:33 a.m. OK C++23 (GCC 14-64, msys2) TESTS 9 46 0
324194234 Guitar_Jasmine E June 13, 2025, 5:13 a.m. OK C++23 (GCC 14-64, msys2) TESTS 9 46 0
324190223 King87arshia E June 13, 2025, 4:32 a.m. OK C++23 (GCC 14-64, msys2) TESTS 9 46 0
324189728 mengh04 E June 13, 2025, 4:26 a.m. OK C++23 (GCC 14-64, msys2) TESTS 9 46 0
324188076 lnight121 E June 13, 2025, 4:04 a.m. OK C++23 (GCC 14-64, msys2) TESTS 9 46 0
324187999 MoonLe E June 13, 2025, 4:04 a.m. OK C++23 (GCC 14-64, msys2) TESTS 9 46 0
324186999 xuexiaoyun E June 13, 2025, 3:50 a.m. OK C++23 (GCC 14-64, msys2) TESTS 9 46 0
324133778 James_bond_9089 E June 12, 2025, 4:31 p.m. OK C# 8 TESTS 9 140 1638400
324146541 pengin_2000 E June 12, 2025, 5:47 p.m. OK GNU C11 TESTS 9 61 102400
324134269 nathanballman E June 12, 2025, 4:32 p.m. OK Java 21 TESTS 9 281 921600
324131665 Abirpal12 E June 12, 2025, 4:27 p.m. OK Java 21 TESTS 9 296 512000
324143247 harshwardhan12 E June 12, 2025, 5:27 p.m. OK Java 21 TESTS 9 327 1331200
324134826 Karthikeya__00 E June 12, 2025, 4:32 p.m. OK Java 8 TESTS 9 249 102400
324130982 drMergen2 E June 12, 2025, 4:26 p.m. OK Kotlin 1.9 TESTS 9 234 1024000
324174246 pplodev E June 13, 2025, 12:19 a.m. OK PyPy 2 TESTS 9 124 1433600
324176757 LMeyling E June 13, 2025, 1:17 a.m. OK PyPy 3-64 TESTS 9 108 2969600
324136244 mysticalseeker02 E June 12, 2025, 4:34 p.m. OK PyPy 3-64 TESTS 9 109 2969600
324162118 stan23456 E June 12, 2025, 8:05 p.m. OK PyPy 3-64 TESTS 9 124 3686400
324140465 ayushjoshi1403 E June 12, 2025, 5:11 p.m. OK PyPy 3-64 TESTS 9 124 4198400
324162220 HasibEvnRiaz E June 12, 2025, 8:06 p.m. OK PyPy 3-64 TESTS 9 124 4300800
324162080 golomb E June 12, 2025, 8:05 p.m. OK PyPy 3-64 TESTS 9 124 4300800
324163528 porcif E June 12, 2025, 8:22 p.m. OK PyPy 3-64 TESTS 9 124 5324800
324139941 McPqndq E June 12, 2025, 5:09 p.m. OK PyPy 3-64 TESTS 9 125 3686400
324160206 smz.26 E June 12, 2025, 7:41 p.m. OK PyPy 3-64 TESTS 9 139 5222400
324134984 RTB99 E June 12, 2025, 4:33 p.m. OK PyPy 3-64 TESTS 9 155 4300800
324186036 svrmalaviya E June 13, 2025, 3:39 a.m. OK Python 3 TESTS 9 62 1331200
324191632 PalizU E June 13, 2025, 4:48 a.m. OK Python 3 TESTS 9 78 1126400
324133542 Khushi_jain_222001 E June 12, 2025, 4:30 p.m. OK Python 3 TESTS 9 78 2560000
324132149 codeforces.code E June 12, 2025, 4:28 p.m. OK Python 3 TESTS 9 93 1433600
324154825 arvindk0025 E June 12, 2025, 6:50 p.m. OK Python 3 TESTS 9 108 1126400
324135382 rocky_2307 E June 12, 2025, 4:33 p.m. OK Python 3 TESTS 9 108 1331200
324132662 JosiSol E June 12, 2025, 4:29 p.m. OK Python 3 TESTS 9 108 3379200

remove filters

Back to search problems