Codeforces Round 1059 (Div. 3)

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
2162 Codeforces Round 1059 (Div. 3) FINISHED False 8100 15693923 Oct. 17, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 2886 ) F Beautiful Intervals PROGRAMMING constructive algorithms greedy

You are given an integer (n) and (m) intervals. Each interval is of the form (l_i, r_i) and satisfies (1 \le l_i \le r_i \le n). Note that there can be duplicate intervals. Let (p) be a permutation of length (n) containing all the integers (0,1,2,\dots,n-1) exactly once. There is a multiset (M) which is initially empty. For each interval (l_i, r_i): consider the subarray (pl_i \dots r_i), compute (v_i = \operatorname{mex})(^{\text{∗}})((pl_i \dots r_i)), insert (v_i) into (M). After processing all the intervals, (M) will be equal to (\{v_1, v_2, \dots, v_m\}). Your task is to construct a permutation (p) of length (n) containing all the integers (0,1,2,\dots,n-1) exactly once such that (\operatorname{mex}(M)) is minimized . (^{\text{∗}})(\operatorname{mex}(a)) denotes the minimum excluded (MEX) of the integers in (a). For example, (\operatorname{mex}(2,2,1)=0) because (0) does not belong to the array, and (\operatorname{mex}(0,3,1,2)=4) because (0), (1), (2), and (3) appear in the array, but (4) does not. The first line contains a single integer (t) ((1 \le t \le 1000)) — the number of test cases. Description of each testcase follows. The first line contains two integers (n) and (m) ((3 \le n \le 3000), (1 \le m \le 3000)). The next (m) lines each contain two space-separated integers (l_i, r_i) ((1 \le l_i \le r_i \le n)) each denoting an interval. It is guaranteed that the sum of (n) over all test cases does not exceed (3000), and the sum of (m) over all test cases does not exceed (3000). For each testcase, print a permutation (p) of length (n) containing all the integers (0,1,2,\dots,n-1) exactly once such that (\operatorname{mex}(M)) is minimized. If there are multiple answers, you may print any one of them. For the first testcase, if we choose to co

Tutorials

Codeforces Round 1059 (Div. 3) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
344510300 og.kostya F Oct. 18, 2025, 2:03 p.m. OK C# 10 TESTS 11 93 102400
344510039 og.kostya F Oct. 18, 2025, 2:02 p.m. OK C# 13 TESTS 11 93 0
344496537 ksandr1v F Oct. 18, 2025, 12:44 p.m. OK C# 13 TESTS 11 139 921600
344588876 ayushpan F Oct. 19, 2025, 5:42 a.m. OK C++17 (GCC 7-32) TESTS 11 46 0
344584371 joelchaconcastillo F Oct. 19, 2025, 4:44 a.m. OK C++17 (GCC 7-32) TESTS 11 46 0
344576962 travelor F Oct. 19, 2025, 2:26 a.m. OK C++17 (GCC 7-32) TESTS 11 46 0
344573591 guruiguhaihua F Oct. 19, 2025, 12:50 a.m. OK C++17 (GCC 7-32) TESTS 11 46 0
344569733 andreasn F Oct. 18, 2025, 10:31 p.m. OK C++17 (GCC 7-32) TESTS 11 46 0
344555752 khalaf F Oct. 18, 2025, 7:06 p.m. OK C++17 (GCC 7-32) TESTS 11 46 0
344548743 Papan10 F Oct. 18, 2025, 6:05 p.m. OK C++17 (GCC 7-32) TESTS 11 46 0
344536796 AryFox F Oct. 18, 2025, 4:43 p.m. OK C++17 (GCC 7-32) TESTS 11 46 0
344536252 aanjaneyeah F Oct. 18, 2025, 4:40 p.m. OK C++17 (GCC 7-32) TESTS 11 46 0
344528769 p__seervi5678 F Oct. 18, 2025, 3:52 p.m. OK C++17 (GCC 7-32) TESTS 11 46 0
344589218 ukoyotu F Oct. 19, 2025, 5:46 a.m. OK C++20 (GCC 13-64) TESTS 11 46 0
344583664 ethan7sky F Oct. 19, 2025, 4:33 a.m. OK C++20 (GCC 13-64) TESTS 11 46 0
344582470 usedchang F Oct. 19, 2025, 4:13 a.m. OK C++20 (GCC 13-64) TESTS 11 46 0
344579510 Chowen F Oct. 19, 2025, 3:19 a.m. OK C++20 (GCC 13-64) TESTS 11 46 0
344575833 ngmhhay F Oct. 19, 2025, 2:01 a.m. OK C++20 (GCC 13-64) TESTS 11 46 0
344573020 GOTKAKO F Oct. 19, 2025, 12:27 a.m. OK C++20 (GCC 13-64) TESTS 11 46 0
344572280 sailealt31 F Oct. 18, 2025, 11:53 p.m. OK C++20 (GCC 13-64) TESTS 11 46 0
344570956 snowythecat F Oct. 18, 2025, 11:04 p.m. OK C++20 (GCC 13-64) TESTS 11 46 0
344524972 n00bmaster__ F Oct. 18, 2025, 3:28 p.m. OK C++20 (GCC 13-64) TESTS 11 46 0
344508633 Vansh_Sohal F Oct. 18, 2025, 1:55 p.m. OK C++20 (GCC 13-64) TESTS 11 46 0
344524314 yslsj F Oct. 18, 2025, 3:24 p.m. OK C++23 (GCC 14-64, msys2) TESTS 11 31 0
344589499 ApuYe F Oct. 19, 2025, 5:49 a.m. OK C++23 (GCC 14-64, msys2) TESTS 11 46 0
344581480 Arslan_Yanybayev F Oct. 19, 2025, 3:55 a.m. OK C++23 (GCC 14-64, msys2) TESTS 11 46 0
344581349 S1lence_25 F Oct. 19, 2025, 3:53 a.m. OK C++23 (GCC 14-64, msys2) TESTS 11 46 0
344579723 Illya1221 F Oct. 19, 2025, 3:23 a.m. OK C++23 (GCC 14-64, msys2) TESTS 11 46 0
344579347 MartinezMiners F Oct. 19, 2025, 3:16 a.m. OK C++23 (GCC 14-64, msys2) TESTS 11 46 0
344578571 insta528. F Oct. 19, 2025, 3 a.m. OK C++23 (GCC 14-64, msys2) TESTS 11 46 0
344578546 Moriarty_Mu F Oct. 19, 2025, 2:59 a.m. OK C++23 (GCC 14-64, msys2) TESTS 11 46 0
344577371 vivekjd_9 F Oct. 19, 2025, 2:34 a.m. OK C++23 (GCC 14-64, msys2) TESTS 11 46 0
344575946 Yasho_ham F Oct. 19, 2025, 2:04 a.m. OK C++23 (GCC 14-64, msys2) TESTS 11 46 0
344570833 kartik__sethi F Oct. 18, 2025, 11 p.m. OK Java 21 TESTS 11 202 614400
344589044 ccj123 F Oct. 19, 2025, 5:44 a.m. OK Java 21 TESTS 11 249 921600
344558517 VinayakShetgar F Oct. 18, 2025, 7:35 p.m. OK Java 21 TESTS 11 281 614400
344549103 ccj123 F Oct. 18, 2025, 6:08 p.m. OK Java 21 TESTS 11 312 614400
344498651 vineetiwari F Oct. 18, 2025, 12:56 p.m. OK Java 21 TESTS 11 312 921600
344554163 jhap15762 F Oct. 18, 2025, 6:51 p.m. OK Java 21 TESTS 11 312 1228800
344511712 NpHardcore_05 F Oct. 18, 2025, 2:11 p.m. OK Java 21 TESTS 11 327 921600
344532102 kevin_0911 F Oct. 18, 2025, 4:14 p.m. OK Java 8 TESTS 11 187 0
344571423 CRACKA F Oct. 18, 2025, 11:20 p.m. OK PyPy 3 TESTS 11 296 9318400
344560097 monocrap F Oct. 18, 2025, 7:53 p.m. OK PyPy 3-64 TESTS 11 124 4710400
344499862 Om_Singh_ F Oct. 18, 2025, 1:04 p.m. OK PyPy 3-64 TESTS 11 140 2867200
344538041 hugoback01 F Oct. 18, 2025, 4:51 p.m. OK PyPy 3-64 TESTS 11 171 4608000
344547457 iN_siDious F Oct. 18, 2025, 5:55 p.m. OK PyPy 3-64 TESTS 11 171 5939200
344534236 rajavarapu.avinash F Oct. 18, 2025, 4:27 p.m. OK PyPy 3-64 TESTS 11 187 5120000
344530018 krism F Oct. 18, 2025, 4 p.m. OK PyPy 3-64 TESTS 11 233 11468800
344529226 helltractor F Oct. 18, 2025, 3:55 p.m. OK PyPy 3-64 TESTS 11 265 9318400
344427051 ChickenTamer F Oct. 18, 2025, 4:02 a.m. OK PyPy 3-64 TESTS 11 405 4198400
344536278 Coder_Ayush_ F Oct. 18, 2025, 4:40 p.m. OK Python 3 TESTS 11 93 1843200
344496978 ehsansoltanm F Oct. 18, 2025, 12:47 p.m. OK Python 3 TESTS 11 296 1536000

remove filters

Back to search problems