Codeforces Round 889 (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
1855 Codeforces Round 889 (Div. 2) FINISHED False 9000 46538663 July 29, 2023, 2:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 28428 ) A Dalton the Teacher PROGRAMMING math

B'Dalton is the teacher of a class with n students, numbered from 1 to n . The classroom contains n chairs, also numbered from 1 to n . Initially student i is seated on chair p_i . It is guaranteed that p_1,p_2, ... , p_n is a permutation of length n . A student is happy if his/her number is different from the number of his/her chair. In order to make all of his students happy, Dalton can repeatedly perform the following operation: choose two distinct students and swap their chairs. What is the minimum number of moves required to make all the students happy? One can show that, under the constraints of this problem, it is possible to make all the students happy with a finite number of moves. 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 <= t <= 1000 ). The description of the test cases follows. The first line contains a single integer n ( 2 <= n <= 10^5 ) -- the number of students. The second line contains n integers p_1, p_2, ldots, p_n ( 1 <= p_i <= n ) -- p_i denotes the initial chair of student i . It is guaranteed that p is a permutation. It is guaranteed that the sum of n over all test cases does not exceed 10^5 . For each test case, output the minimum number of moves required. In the first test case, both students are already happy, so Dalton can perform 0 moves. In the second test case, Dalton can swap the chairs of students 1 and 2 to get the array [2, 1, 3] . Then he can swap chairs of students 2 and 3 '...

Tutorials

Editorial of Codeforces Round 889 (Div. 1 + Div. 2)

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
216400589 cppc A July 30, 2023, 5:50 a.m. OK C# 10 TESTS 8 124 7987200
216400402 cppc A July 30, 2023, 5:47 a.m. OK C# 10 TESTS 8 139 7782400
216393466 bluemegane A July 30, 2023, 4:24 a.m. OK C# 8 TESTS 8 218 7987200
216378196 PLUTO_o A July 29, 2023, 11:58 p.m. OK Clang++17 Diagnostics TESTS 8 389 0
216377624 NKMYHinata A July 29, 2023, 11:43 p.m. OK Clang++17 Diagnostics TESTS 8 405 2150400
216364669 arctictern A July 29, 2023, 8:19 p.m. OK Clang++20 Diagnostics TESTS 8 389 0
216360782 FrobeniusNorm A July 29, 2023, 7:41 p.m. OK Clang++20 Diagnostics TESTS 8 420 0
216348347 MostakinAbedin A July 29, 2023, 6:01 p.m. OK GNU C11 TESTS 8 31 0
216364274 Taraksriram A July 29, 2023, 8:15 p.m. OK GNU C11 TESTS 8 31 409600
216338460 walee2radi A July 29, 2023, 5:01 p.m. OK GNU C11 TESTS 8 31 409600
216373062 kawsar_hridoy A July 29, 2023, 10:05 p.m. OK GNU C11 TESTS 8 31 409600
216344973 shashank_padamati A July 29, 2023, 5:46 p.m. OK GNU C11 TESTS 8 31 819200
216349900 _Akhi_azad_ A July 29, 2023, 6:10 p.m. OK GNU C11 TESTS 8 46 0
216383146 OMG_78 A July 30, 2023, 1:45 a.m. OK GNU C++14 TESTS 8 30 0
216360839 Prashant30123 A July 29, 2023, 7:42 p.m. OK GNU C++14 TESTS 8 30 0
216383090 123wwm A July 30, 2023, 1:44 a.m. OK GNU C++14 TESTS 8 30 409600
216385628 luogu_bot2 A July 30, 2023, 2:26 a.m. OK GNU C++14 TESTS 8 31 0
216389247 gty314159 A July 30, 2023, 3:24 a.m. OK GNU C++14 TESTS 8 31 0
216389119 XZRSEVEN A July 30, 2023, 3:22 a.m. OK GNU C++14 TESTS 8 31 0
216387537 ldh081122 A July 30, 2023, 2:56 a.m. OK GNU C++14 TESTS 8 31 0
216387162 mazharul0 A July 30, 2023, 2:50 a.m. OK GNU C++14 TESTS 8 31 0
216391239 cxh315 A July 30, 2023, 3:53 a.m. OK GNU C++14 TESTS 8 31 0
216392164 Cuberates A July 30, 2023, 4:06 a.m. OK GNU C++14 TESTS 8 31 0
216383026 xlxys A July 30, 2023, 1:43 a.m. OK GNU C++17 TESTS 8 15 0
216384903 1A2012 A July 30, 2023, 2:15 a.m. OK GNU C++17 TESTS 8 30 0
216339495 pjd.voyager A July 29, 2023, 5:03 p.m. OK GNU C++17 TESTS 8 30 409600
216372160 Rashed.Mamdouh A July 29, 2023, 9:49 p.m. OK GNU C++17 TESTS 8 30 409600
216363125 dulo25 A July 29, 2023, 8:04 p.m. OK GNU C++17 TESTS 8 30 409600
216347030 RYAD_08 A July 29, 2023, 5:54 p.m. OK GNU C++17 TESTS 8 30 1126400
216395526 suhaildhada10 A July 30, 2023, 4:50 a.m. OK GNU C++17 TESTS 8 30 1228800
216400492 Nada_A7med A July 30, 2023, 5:49 a.m. OK GNU C++17 TESTS 8 31 0
216400929 jisas A July 30, 2023, 5:53 a.m. OK GNU C++17 TESTS 8 31 0
216400967 myselffmou A July 30, 2023, 5:54 a.m. OK GNU C++17 TESTS 8 31 0
216370068 mykskxx A July 29, 2023, 9:19 p.m. OK GNU C++17 (64) TESTS 8 15 0
216395118 mostafasazid A July 30, 2023, 4:45 a.m. OK GNU C++17 (64) TESTS 8 15 0
216354848 prasanna2425 A July 29, 2023, 6:45 p.m. OK GNU C++17 (64) TESTS 8 15 0
216344560 akwa_blue A July 29, 2023, 5:44 p.m. OK GNU C++17 (64) TESTS 8 15 0
216385866 xuxu4213 A July 30, 2023, 2:29 a.m. OK GNU C++17 (64) TESTS 8 15 1638400
216338782 jorje A July 29, 2023, 5:02 p.m. OK GNU C++17 (64) TESTS 8 30 0
216380025 Once_I_Liked_AGirl A July 30, 2023, 12:45 a.m. OK GNU C++17 (64) TESTS 8 30 0
216381844 Giga_Cronos A July 30, 2023, 1:21 a.m. OK GNU C++17 (64) TESTS 8 30 0
216352816 The5threich A July 29, 2023, 6:30 p.m. OK GNU C++17 (64) TESTS 8 30 409600
216363938 Fatin007 A July 29, 2023, 8:12 p.m. OK GNU C++17 (64) TESTS 8 30 409600
216393055 ekramul11 A July 30, 2023, 4:19 a.m. OK GNU C++20 (64) TESTS 8 15 0
216392947 Vec1 A July 30, 2023, 4:17 a.m. OK GNU C++20 (64) TESTS 8 15 0
216391688 bashem A July 30, 2023, 3:59 a.m. OK GNU C++20 (64) TESTS 8 15 0
216385055 _SUGAR__DADDY_ A July 30, 2023, 2:17 a.m. OK GNU C++20 (64) TESTS 8 15 0
216400205 sz_zx A July 30, 2023, 5:45 a.m. OK GNU C++20 (64) TESTS 8 15 0
216399892 lightblue_pikachu A July 30, 2023, 5:42 a.m. OK GNU C++20 (64) TESTS 8 15 0
216398965 lin_jy A July 30, 2023, 5:31 a.m. OK GNU C++20 (64) TESTS 8 15 0
216397499 Fiatiustitia A July 30, 2023, 5:15 a.m. OK GNU C++20 (64) TESTS 8 15 0
216394688 palermo984 A July 30, 2023, 4:39 a.m. OK GNU C++20 (64) TESTS 8 15 0
216393719 -Victory A July 30, 2023, 4:27 a.m. OK GNU C++20 (64) TESTS 8 15 0
216349120 vana0kor A July 29, 2023, 6:05 p.m. OK Go TESTS 8 62 1638400
216343806 shojin_pro A July 29, 2023, 5:42 p.m. OK Java 11 TESTS 8 170 0
216345757 chess_nf3 A July 29, 2023, 5:49 p.m. OK Java 11 TESTS 8 186 0
216395225 sarvesh_bawari A July 30, 2023, 4:46 a.m. OK Java 11 TESTS 8 186 31129600
216344442 ujjwal_a0001 A July 29, 2023, 5:44 p.m. OK Java 11 TESTS 8 187 0
216348260 vijender_8601 A July 29, 2023, 6 p.m. OK Java 11 TESTS 8 187 0
216349922 snkv A July 29, 2023, 6:10 p.m. OK Java 11 TESTS 8 202 2457600
216373802 InfinitePath A July 29, 2023, 10:17 p.m. OK Java 11 TESTS 8 202 40243200
216352257 Siyaram_13 A July 29, 2023, 6:26 p.m. OK Java 11 TESTS 8 217 0
216386179 mschact A July 30, 2023, 2:34 a.m. OK Java 11 TESTS 8 296 0
216349649 achal5623 A July 29, 2023, 6:08 p.m. OK Java 11 TESTS 8 311 0
216348162 Zakaria_Eysa A July 29, 2023, 6 p.m. OK Java 17 TESTS 8 170 307200
216348251 vikash_45 A July 29, 2023, 6 p.m. OK Java 17 TESTS 8 186 409600
216347158 Utsav82 A July 29, 2023, 5:55 p.m. OK Java 17 TESTS 8 187 204800
216371228 raito3z A July 29, 2023, 9:35 p.m. OK Java 17 TESTS 8 218 0
216351738 Nagendravarma A July 29, 2023, 6:22 p.m. OK Java 17 TESTS 8 218 614400
216363092 Suraj1607 A July 29, 2023, 8:03 p.m. OK Java 17 TESTS 8 233 204800
216345385 miminguci A July 29, 2023, 5:47 p.m. OK Java 17 TESTS 8 233 204800
216365923 anacharsis A July 29, 2023, 8:32 p.m. OK Java 17 TESTS 8 233 409600
216344212 L1C1T A July 29, 2023, 5:43 p.m. OK Java 17 TESTS 8 311 716800
216357419 pranay_1012 A July 29, 2023, 7:08 p.m. OK Java 17 TESTS 8 326 921600
216374429 kevin91827 A July 29, 2023, 10:29 p.m. OK Java 8 TESTS 8 109 0
216393250 codechefpurpose2023 A July 30, 2023, 4:21 a.m. OK Java 8 TESTS 8 124 0
216358698 Rippahh A July 29, 2023, 7:20 p.m. OK Java 8 TESTS 8 124 0
216352785 tejasS-27 A July 29, 2023, 6:29 p.m. OK Java 8 TESTS 8 124 0
216343715 vijay_panwar12 A July 29, 2023, 5:42 p.m. OK Java 8 TESTS 8 124 0
216355780 BishoEzzat A July 29, 2023, 6:53 p.m. OK Java 8 TESTS 8 156 0
216368763 raaayyyaaaan A July 29, 2023, 9:03 p.m. OK Java 8 TESTS 8 202 0
216353392 sahilgupta2201 A July 29, 2023, 6:34 p.m. OK Java 8 TESTS 8 217 0
216344982 Aworlds A July 29, 2023, 5:46 p.m. OK Java 8 TESTS 8 233 0
216338747 Nrskhn A July 29, 2023, 5:02 p.m. OK Java 8 TESTS 8 249 0
216400798 Saumya_706 A July 30, 2023, 5:52 a.m. OK MS C++ 2017 TESTS 8 78 409600
216346283 maikh07 A July 29, 2023, 5:51 p.m. OK MS C++ 2017 TESTS 8 93 0
216354183 KingNafis A July 29, 2023, 6:40 p.m. OK MS C++ 2017 TESTS 8 93 409600
216363378 Compiler_10 A July 29, 2023, 8:06 p.m. OK PyPy 3 TESTS 8 155 7782400
216350741 jvatsal0709 A July 29, 2023, 6:15 p.m. OK PyPy 3 TESTS 8 170 9318400
216390552 philosolog A July 30, 2023, 3:43 a.m. OK PyPy 3 TESTS 8 233 10342400
216373841 zainijunaid8228 A July 29, 2023, 10:18 p.m. OK PyPy 3 TESTS 8 249 10649600
216370169 Track-Days A July 29, 2023, 9:21 p.m. OK PyPy 3-64 TESTS 8 77 13312000
216400172 I_Am_That A July 30, 2023, 5:45 a.m. OK PyPy 3-64 TESTS 8 77 13516800
216383597 Youarenotgood A July 30, 2023, 1:52 a.m. OK PyPy 3-64 TESTS 8 78 13312000
216368668 gosipov A July 29, 2023, 9:02 p.m. OK PyPy 3-64 TESTS 8 93 11366400
216360211 AndreiZherder A July 29, 2023, 7:36 p.m. OK PyPy 3-64 TESTS 8 93 11468800
216348533 DavidLoo A July 29, 2023, 6:02 p.m. OK PyPy 3-64 TESTS 8 93 13312000
216349353 gardengnome A July 29, 2023, 6:07 p.m. OK PyPy 3-64 TESTS 8 93 13516800
216357026 Keval_78 A July 29, 2023, 7:04 p.m. OK PyPy 3-64 TESTS 8 93 143667200
216385731 nealzane A July 30, 2023, 2:27 a.m. OK PyPy 3-64 TESTS 8 124 11161600
216375060 Kita A July 29, 2023, 10:42 p.m. OK PyPy 3-64 TESTS 8 139 13516800
216395543 dibya_mallick A July 30, 2023, 4:50 a.m. OK Python 3 TESTS 8 61 11059200
216352261 M4qa1 A July 29, 2023, 6:26 p.m. OK Python 3 TESTS 8 61 12390400
216368422 elistark A July 29, 2023, 8:59 p.m. OK Python 3 TESTS 8 62 8908800
216357218 adi2107 A July 29, 2023, 7:06 p.m. OK Python 3 TESTS 8 62 12390400
216356054 shanmukha19 A July 29, 2023, 6:56 p.m. OK Python 3 TESTS 8 62 12390400
216352839 Athlete_7 A July 29, 2023, 6:30 p.m. OK Python 3 TESTS 8 62 12390400
216348992 okay4869 A July 29, 2023, 6:04 p.m. OK Python 3 TESTS 8 62 12390400
216381877 pennymagic156 A July 30, 2023, 1:21 a.m. OK Python 3 TESTS 8 62 13926400
216346600 wwwqqq7 A July 29, 2023, 5:52 p.m. OK Python 3 TESTS 8 77 10240000
216397621 Lucky0820 A July 30, 2023, 5:17 a.m. OK Python 3 TESTS 8 77 12390400
216355415 0x81 A July 29, 2023, 6:50 p.m. OK Ruby 3 TESTS 8 358 6553600
216349647 cptahahab A July 29, 2023, 6:08 p.m. OK Rust 2021 TESTS 8 31 7065600
216349375 cptahahab A July 29, 2023, 6:07 p.m. OK Rust 2021 TESTS 8 31 7065600
216349164 cptahahab A July 29, 2023, 6:05 p.m. OK Rust 2021 TESTS 8 31 7065600
216350676 prog-student A July 29, 2023, 6:15 p.m. OK Scala TESTS 8 452 3788800

remove filters

Back to search problems