Educational Codeforces Round 189 (Rated for 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
2225 Educational Codeforces Round 189 (Rated for Div. 2) FINISHED False 7200 3684296 April 21, 2026, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 229 ) G Simple Problem PROGRAMMING graphs number theory

One day, Polycarp came up with the following simple problem: the numbers (0, 1, \ldots, n-1) are given. Is it possible to arrange them so that the absolute difference of every adjacent pair of numbers is divisible by at least one of the numbers (k_1, k_2, \ldots, k_m)? Polycarp spent a long time thinking about how to solve this problem and eventually realized that it is not so simple after all. Help him solve this problem. Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 10^3)). The description of the test cases follows. The first line of each test case contains two integers (n) and (m) ((3 \leq n \leq 5 \cdot 10^{3}); (1 \leq m \leq 10)). The second line of each test case contains (m) integers (k_{i}) ((1 \leq k_i \leq \left\lfloor \frac{n}{3} \right\rfloor)). Additional constraints on the input: the sum of (n) over all test cases does not exceed (5 \cdot 10^{3}). For each test case, output one of the following: -1 on a single line if no suitable arrangement exists; (n) integers (0, 1, \ldots, n-1) satisfying the condition. If there are multiple answers, print any of them.

Tutorials

Tutorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
372043513 Mostafafied G April 21, 2026, 4:08 p.m. OK C# 10 TESTS 88 78 204800
372048258 moh-kaz333 G April 21, 2026, 4:20 p.m. OK C# 10 TESTS 88 109 204800
372094250 1xx55 G April 22, 2026, 4:27 a.m. OK C++17 (GCC 7-32) TESTS 88 46 102400
372057464 Sayu_zzz G April 21, 2026, 4:53 p.m. OK C++17 (GCC 7-32) TESTS 88 46 102400
372055932 CrossFire1 G April 21, 2026, 4:42 p.m. OK C++17 (GCC 7-32) TESTS 88 46 102400
372050326 shreyanshm94 G April 21, 2026, 4:25 p.m. OK C++17 (GCC 7-32) TESTS 88 46 102400
372050057 oceeff G April 21, 2026, 4:24 p.m. OK C++17 (GCC 7-32) TESTS 88 46 2252800
372065318 oceanic G April 21, 2026, 6:02 p.m. OK C++17 (GCC 7-32) TESTS 88 62 102400
372096859 FantasyNumber G April 22, 2026, 5:15 a.m. OK C++20 (GCC 13-64) TESTS 88 31 1126400
372084469 rns_jhm G April 22, 2026, 12:16 a.m. OK C++20 (GCC 13-64) TESTS 88 46 102400
372062469 SATSKY_2025target_LGM G April 21, 2026, 5:33 p.m. OK C++20 (GCC 13-64) TESTS 88 46 102400
372058072 wuhudsm G April 21, 2026, 4:57 p.m. OK C++20 (GCC 13-64) TESTS 88 46 102400
372057396 Unrated_9483 G April 21, 2026, 4:52 p.m. OK C++20 (GCC 13-64) TESTS 88 46 102400
372057152 SATSKY_2025target_LGM G April 21, 2026, 4:50 p.m. OK C++20 (GCC 13-64) TESTS 88 46 102400
372051038 dugu_qiubai G April 21, 2026, 4:27 p.m. OK C++20 (GCC 13-64) TESTS 88 46 102400
372050675 hexahydride G April 21, 2026, 4:26 p.m. OK C++20 (GCC 13-64) TESTS 88 46 2150400
372089798 liaoz123 G April 22, 2026, 2:50 a.m. OK C++20 (GCC 13-64) TESTS 88 62 20070400
372046881 woyebuzhidaowoshishui G April 21, 2026, 4:17 p.m. OK C++20 (GCC 13-64) TESTS 88 62 64204800
372091598 jlass_ G April 22, 2026, 3:31 a.m. OK C++23 (GCC 14-64, msys2) TESTS 88 46 0
372080137 nzo G April 21, 2026, 9:50 p.m. OK C++23 (GCC 14-64, msys2) TESTS 88 46 102400
372078723 madamadam G April 21, 2026, 9:17 p.m. OK C++23 (GCC 14-64, msys2) TESTS 88 46 102400
372078427 madamadam G April 21, 2026, 9:10 p.m. OK C++23 (GCC 14-64, msys2) TESTS 88 46 102400
372073810 jumpmelon G April 21, 2026, 7:52 p.m. OK C++23 (GCC 14-64, msys2) TESTS 88 46 102400
372071996 pillow_penguin G April 21, 2026, 7:26 p.m. OK C++23 (GCC 14-64, msys2) TESTS 88 46 102400
372058676 go_tidy G April 21, 2026, 5:01 p.m. OK C++23 (GCC 14-64, msys2) TESTS 88 46 102400
372056813 A_G G April 21, 2026, 4:48 p.m. OK C++23 (GCC 14-64, msys2) TESTS 88 46 102400
372056386 LNight121 G April 21, 2026, 4:45 p.m. OK C++23 (GCC 14-64, msys2) TESTS 88 46 102400
372055997 Tanhhhhtjy G April 21, 2026, 4:43 p.m. OK C++23 (GCC 14-64, msys2) TESTS 88 46 102400
372056632 daniel.glabai G April 21, 2026, 4:47 p.m. OK Java 21 TESTS 88 250 1228800
372086432 smilences G April 22, 2026, 1:21 a.m. OK PyPy 3-64 TESTS 88 93 2355200
372051161 Mentholzzz G April 21, 2026, 4:27 p.m. OK PyPy 3-64 TESTS 88 93 2560000
372056368 Jynkoo G April 21, 2026, 4:45 p.m. OK PyPy 3-64 TESTS 88 125 3379200
372056501 Little_Sheep_Yawn G April 21, 2026, 4:46 p.m. OK PyPy 3-64 TESTS 88 343 5836800

remove filters

Back to search problems