Codeforces Round 953 (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
1978 Codeforces Round 953 (Div. 2) FINISHED False 7200 18651263 June 16, 2024, 9:05 a.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 1382 ) F Large Graph PROGRAMMING data structures ds graphs number theory

B"Given an array a of length n . Let's construct a square matrix b of size n x n , in which the i -th row contains the array a cyclically shifted to the right by (i - 1) . For example, for the array a = [3, 4, 5] , the obtained matrix is b = begin{bmatrix} 3 & 4 & 5 5 & 3 & 4 4 & 5 & 3 end{bmatrix} Let's construct the following graph: Your task is to calculate the number of connected components ^{ dagger} in the obtained graph. ^{ dagger} A connected component of a graph is a set of vertices in which any vertex is reachable from any other via edges, and adding any other vertex to the set violates this rule. Each test consists of multiple test cases. The first line contains a single integer t ( 1 <= q t <= q 10^5 ) -- the number of test cases. The description of the test cases follows. The first line of each test case contains two integers n and k ( 2 <= n <= 10^6 , 2 <= k <= 2 cdot 10^6 ) -- the length of the array and the parameter k . The second line of each test case contains n integers a_1, a_2, ldots, a_n ( 1 <= a_i <= 10^6 ) -- the elements of the array a . It is guaranteed that the sum of n over all test cases does not exceed 10^6 . For each test case, output a single integer -- the number of connected components in the obtained graph. In the first test case, the matrix b is given in the statement. The first connected component contains the vertices (1, 1) , (2, 2) , and (3, 3) . The second connected component contains the vertices (1, 2) , (2, 3) , and (3, 1) . The third connected component contains the vertices (1, 3) , (2, 1) , and (3, 2) . Thus, the graph has 3 connected components. In the second test case, the following matrix is obtained: b = begin{bmatrix} 3 & 4 & 9 9 & 3 & 4 4 & 9 & 3 end{bmatrix} The first conn"...

Tutorials

130527

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
266118572 int_R F June 16, 2024, 11:40 p.m. OK C++14 (GCC 6-32) TESTS 49 531 46284800
266118532 int_R F June 16, 2024, 11:38 p.m. OK C++14 (GCC 6-32) TESTS 49 546 46284800
266122982 eggegg185 F June 17, 2024, 1:43 a.m. OK C++14 (GCC 6-32) TESTS 49 936 79974400
266076726 Gatina F June 16, 2024, 2:47 p.m. OK C++14 (GCC 6-32) TESTS 49 937 32256000
266129915 bear203 F June 17, 2024, 3:46 a.m. OK C++14 (GCC 6-32) TESTS 49 1280 88883200
266064288 chennie F June 16, 2024, 1:12 p.m. OK C++14 (GCC 6-32) TESTS 49 1452 74547200
266063323 xzzduang F June 16, 2024, 1:04 p.m. OK C++14 (GCC 6-32) TESTS 49 1515 107315200
266128979 bro_jie F June 17, 2024, 3:32 a.m. OK C++14 (GCC 6-32) TESTS 49 1577 110796800
266118655 SimpleCloud F June 16, 2024, 11:42 p.m. OK C++14 (GCC 6-32) TESTS 49 1686 175820800
266063846 caiyuanqi F June 16, 2024, 1:08 p.m. OK C++14 (GCC 6-32) TESTS 49 1749 187801600
266102162 Noobish_Monk F June 16, 2024, 6:26 p.m. OK C++17 (GCC 7-32) TESTS 49 546 61644800
266117091 sg0071729 F June 16, 2024, 10:54 p.m. OK C++17 (GCC 7-32) TESTS 49 577 28979200
266137886 Sparkle_Twilight F June 17, 2024, 5:41 a.m. OK C++17 (GCC 7-32) TESTS 49 1014 117760000
266135842 Lihg F June 17, 2024, 5:15 a.m. OK C++17 (GCC 7-32) TESTS 49 1014 117760000
266125345 shrimpballs F June 17, 2024, 2:32 a.m. OK C++17 (GCC 7-32) TESTS 49 1077 114483200
266066388 zas111lll F June 16, 2024, 1:28 p.m. OK C++17 (GCC 7-32) TESTS 49 1124 19046400
266115009 GALA F June 16, 2024, 9:54 p.m. OK C++17 (GCC 7-32) TESTS 49 1140 91238400
266134119 Lihg F June 17, 2024, 4:52 a.m. OK C++17 (GCC 7-32) TESTS 49 1155 114380800
266117143 FzArK F June 16, 2024, 10:55 p.m. OK C++17 (GCC 7-32) TESTS 49 1280 73523200
266134276 Lihg F June 17, 2024, 4:54 a.m. OK C++17 (GCC 7-32) TESTS 49 1390 110284800
266119881 N_z__ F June 17, 2024, 12:20 a.m. OK C++20 (GCC 13-64) TESTS 49 312 24985600
266127766 fishcathu. F June 17, 2024, 3:13 a.m. OK C++20 (GCC 13-64) TESTS 49 436 28057600
266128207 fishcathu. F June 17, 2024, 3:20 a.m. OK C++20 (GCC 13-64) TESTS 49 467 28057600
266127897 fishcathu. F June 17, 2024, 3:15 a.m. OK C++20 (GCC 13-64) TESTS 49 515 32153600
266093230 Otalp F June 16, 2024, 5 p.m. OK C++20 (GCC 13-64) TESTS 49 515 91955200
266128124 fishcathu. F June 17, 2024, 3:19 a.m. OK C++20 (GCC 13-64) TESTS 49 530 32153600
266082796 fishcathu. F June 16, 2024, 3:33 p.m. OK C++20 (GCC 13-64) TESTS 49 530 32153600
266127986 fishcathu. F June 17, 2024, 3:17 a.m. OK C++20 (GCC 13-64) TESTS 49 531 28057600
266130413 ArminArlert69 F June 17, 2024, 3:53 a.m. OK C++20 (GCC 13-64) TESTS 49 531 46080000
266125343 LChenl F June 17, 2024, 2:32 a.m. OK C++20 (GCC 13-64) TESTS 49 531 46080000
266091212 rainboy F June 16, 2024, 4:42 p.m. OK GNU C11 TESTS 49 937 52224000
266063195 0x3F F June 16, 2024, 1:03 p.m. OK Go TESTS 49 1561 117145600
266107257 man-ray F June 16, 2024, 7:29 p.m. OK Java 21 TESTS 49 2609 50073600
266081574 IceWolf898 F June 16, 2024, 3:23 p.m. OK Java 21 TESTS 49 3000 531353600
266127818 FierteDeCeylan F June 17, 2024, 3:14 a.m. OK Java 21 TESTS 49 3546 382361600
266081426 IceWolf898 F June 16, 2024, 3:22 p.m. OK Java 8 TESTS 49 2811 522752000
266081252 IceWolf898 F June 16, 2024, 3:20 p.m. OK Java 8 TESTS 49 2983 523264000
266066001 00zijian F June 16, 2024, 1:25 p.m. OK PyPy 3-64 TESTS 49 2250 133939200
266095968 the_last_smilodon F June 16, 2024, 5:25 p.m. OK PyPy 3-64 TESTS 49 2749 186163200
266064597 00zijian F June 16, 2024, 1:14 p.m. OK PyPy 3-64 TESTS 49 3749 426188800
266073302 liupengsay F June 16, 2024, 2:18 p.m. OK PyPy 3-64 TESTS 49 3796 360652800
266123333 krism F June 17, 2024, 1:50 a.m. OK PyPy 3-64 TESTS 49 3999 360755200
266095208 BetterThanNobita F June 16, 2024, 5:18 p.m. OK Rust 2021 TESTS 49 1921 173977600

remove filters

Back to search problems