Codeforces Round 1112 (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
2249 Codeforces Round 1112 (Div. 1) FINISHED False 9000 2388314 July 26, 2026, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 1600 ) C Double-Rift Dial PROGRAMMING data structures dfs and similar dsu implementation two pointers

A permutation(^{\text{∗}}) (p) of length (n) is written clockwise on a circular dial. Choose a starting position (s) ((1\le s\le n)) and read one full circle clockwise from (p_s), wrapping around after (p_n). The resulting sequence is () q=p_s,p_{s+1},\ldots,p_n,p_1,\ldots,p_{s-1}, () which also has a length of (n). For any non-empty prefix of this sequence (q_1, q_2, \ldots, q_k) ((k\ge 1)), let (S) be the corresponding set of values, that is, (S=\{q_1, q_2,\ldots, q_k\}). Split (S) into maximal segments of consecutive integers, and we call these segments the blocks of (S). For example, (S=\{1,2,5,7,8,9\}) has (3) blocks : (\{1,2\}), (\{5\}), and (\{7,8,9\}). A starting position (s) is called good if and only if, for every non-empty prefix of (q), the corresponding set (S) has at most (2) blocks . Find the number of good starting positions. (^{\text{∗}})A permutation of length (n) is an array consisting of (n) distinct integers from (1) to (n) in arbitrary order. For example, (2,3,1,5,4) is a permutation, but (1,2,2) is not a permutation ((2) appears twice in the array), and (1,3,4) is also not a permutation ((n=3) but there is (4) in the array). Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 10^4)). The description of the test cases follows. The first line of each test case contains one integer (n) ((1\le n\le 2\cdot 10^5)) — the length of (p). The second line of each test case contains (n) integers (p_1,p_2,\ldots,p_n) ((1\le p_i\le n), all (p_i)-s are distinct) — the elements of (p). It is guaranteed that the sum of (n) over all test cases does not exceed (2\cdot 10^5). For each test case, print one integer — the number of good starting positions. In the first test case, there is only one starti

Tutorials

Codeforces Round 1112 (Div. 1, Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
384423636 sronak C July 26, 2026, 5:01 p.m. OK C# 13 TESTS 17 671 18022400
384423262 alexlikemath007 C July 26, 2026, 5 p.m. OK C++17 (GCC 7-32) TESTS 17 78 2560000
384389388 yinghua_luoxue C July 26, 2026, 3:27 p.m. OK C++17 (GCC 7-32) TESTS 17 125 2764800
384442504 therealdoug0986 C July 26, 2026, 8:57 p.m. OK C++17 (GCC 7-32) TESTS 17 171 5017600
384408827 zoutong C July 26, 2026, 4:10 p.m. OK C++17 (GCC 7-32) TESTS 17 234 16076800
384371556 potato167 C July 26, 2026, 3 p.m. OK C++17 (GCC 7-32) TESTS 17 265 5939200
384463721 rabbit_mygo C July 27, 2026, 4:44 a.m. OK C++17 (GCC 7-32) TESTS 17 281 15257600
384422930 dl2718281 C July 26, 2026, 4:59 p.m. OK C++17 (GCC 7-32) TESTS 17 296 11264000
384407637 gwance C July 26, 2026, 4:06 p.m. OK C++17 (GCC 7-32) TESTS 17 296 14438400
384394785 JianYuuuuu C July 26, 2026, 3:36 p.m. OK C++17 (GCC 7-32) TESTS 17 296 14540800
384391734 quanjun C July 26, 2026, 3:31 p.m. OK C++17 (GCC 7-32) TESTS 17 312 9625600
384417010 CHENRUIJIE C July 26, 2026, 4:37 p.m. OK C++20 (GCC 13-64) TESTS 17 78 2252800
384444066 Michael533239 C July 26, 2026, 9:41 p.m. OK C++20 (GCC 13-64) TESTS 17 78 8192000
384389939 Midhilesh C July 26, 2026, 3:28 p.m. OK C++20 (GCC 13-64) TESTS 17 109 2764800
384445119 JeffLegendPower C July 26, 2026, 10:16 p.m. OK C++20 (GCC 13-64) TESTS 17 125 921600
384427829 pooty C July 26, 2026, 5:33 p.m. OK C++20 (GCC 13-64) TESTS 17 125 6041600
384399385 stateCompressed C July 26, 2026, 3:46 p.m. OK C++20 (GCC 13-64) TESTS 17 125 13824000
384383652 AlRntn C July 26, 2026, 3:17 p.m. OK C++20 (GCC 13-64) TESTS 17 171 15360000
384405461 Xerxes C July 26, 2026, 4 p.m. OK C++20 (GCC 13-64) TESTS 17 187 4403200
384418411 Minzitong C July 26, 2026, 4:42 p.m. OK C++20 (GCC 13-64) TESTS 17 187 9113600
384404195 redbirdfly C July 26, 2026, 3:57 p.m. OK C++20 (GCC 13-64) TESTS 17 187 32051200
384410118 Dalek_of_Rivia C July 26, 2026, 4:14 p.m. OK C++23 (GCC 14-64, msys2) TESTS 17 78 102400
384401413 lcyxds C July 26, 2026, 3:51 p.m. OK C++23 (GCC 14-64, msys2) TESTS 17 125 1638400
384414222 Milmon C July 26, 2026, 4:27 p.m. OK C++23 (GCC 14-64, msys2) TESTS 17 125 12492800
384389334 ExplodingKonjac C July 26, 2026, 3:26 p.m. OK C++23 (GCC 14-64, msys2) TESTS 17 140 6758400
384399232 dinohaur C July 26, 2026, 3:46 p.m. OK C++23 (GCC 14-64, msys2) TESTS 17 140 8499200
384388554 zdc123456 C July 26, 2026, 3:25 p.m. OK C++23 (GCC 14-64, msys2) TESTS 17 140 17612800
384400179 justin_zed C July 26, 2026, 3:48 p.m. OK C++23 (GCC 14-64, msys2) TESTS 17 156 7065600
384420870 A_G C July 26, 2026, 4:52 p.m. OK C++23 (GCC 14-64, msys2) TESTS 17 156 9523200
384394905 socpite C July 26, 2026, 3:37 p.m. OK C++23 (GCC 14-64, msys2) TESTS 17 156 10240000
384460253 ktts0715 C July 27, 2026, 3:55 a.m. OK C++23 (GCC 14-64, msys2) TESTS 17 171 5939200
384416844 pengin_2000 C July 26, 2026, 4:36 p.m. OK GNU C11 TESTS 17 109 20172800
384393044 codecrasher_ C July 26, 2026, 3:33 p.m. OK Go TESTS 17 203 18124800
384380780 gofrozen21 C July 26, 2026, 3:12 p.m. OK Java 21 TESTS 17 375 5939200
384403415 MBBN C July 26, 2026, 3:55 p.m. OK Java 21 TESTS 17 843 72601600
384388851 AJ123496 C July 26, 2026, 3:26 p.m. OK Java 21 TESTS 17 890 5017600
384419016 nathanballman C July 26, 2026, 4:44 p.m. OK Java 21 TESTS 17 1656 59289600
384389265 dark_slayer007 C July 26, 2026, 3:26 p.m. OK Java 8 TESTS 17 437 2252800
384389833 Tlatoani C July 26, 2026, 3:27 p.m. OK Kotlin 2.2 TESTS 17 796 18739200
384386101 arvindf232 C July 26, 2026, 3:21 p.m. OK Kotlin 2.2 TESTS 17 890 7680000
384462632 superbcoder102 C July 27, 2026, 4:28 a.m. OK PyPy 3-64 TESTS 17 734 33996800
384393798 trycatchcry C July 26, 2026, 3:35 p.m. OK Rust 2024 TESTS 17 296 16896000
384388230 d11maan C July 26, 2026, 3:24 p.m. OK Rust 2024 TESTS 17 359 8908800
384396776 DanielAnker C July 26, 2026, 3:40 p.m. OK Rust 2024 TESTS 17 468 25292800
384422634 tomek C July 26, 2026, 4:57 p.m. OK Rust 2024 TESTS 17 500 7782400
384395663 Egor C July 26, 2026, 3:38 p.m. OK Rust 2024 TESTS 17 515 6041600
384412875 cvs-650 C July 26, 2026, 4:23 p.m. OK Rust 2024 TESTS 17 531 38092800
384397722 qwerty787788 C July 26, 2026, 3:42 p.m. OK Rust 2024 TESTS 17 562 18534400
384409742 darkkcyan C July 26, 2026, 4:13 p.m. OK Rust 2024 TESTS 17 859 28057600
384407105 Cyros C July 26, 2026, 4:05 p.m. OK Scala TESTS 17 1625 116224000

remove filters

Back to search problems