Codeforces Global Round 27

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
2035 Codeforces Global Round 27 FINISHED False 10800 46365923 Oct. 27, 2024, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 11480 ) C Alya and Permutation PROGRAMMING bitmasks constructive algorithms data structures

Alya has been given a hard problem. Unfortunately, she is too busy running for student council. Please solve this problem for her. Given an integer (n), construct a permutation (p) of integers (1, 2, \ldots, n) that maximizes the value of (k) (which is initially (0)) after the following process. Perform (n) operations, on the (i)-th operation ((i=1, 2, \dots, n)), If (i) is odd, (k=k\,\&\,p_i), where (\&) denotes the bitwise AND operation . If (i) is even, (k=k\,|\,p_i), where (|) denotes the bitwise OR operation . The first line contains a single integer (t) ((1\le t\le 500)) — the number of test cases. The only line of each test case contains a single integer (n) ((5\le n\le 2 \cdot 10^5)) — the length of the permutation. It is guaranteed that the sum of (n) over all test cases does not exceed (2 \cdot 10^5). For each test case, output the maximum value of (k) in the first line and output the permutation (p_1, p_2,\ldots, p_n) in the second line. If there are multiple such permutations, output any. For the first test case, the value of (k) is determined as follows: (k = 0) initially. On the (1)st operation, (1) is odd, so Alya sets (k) to be (k\&p_1 = 0\&2 = 0). On the (2)nd operation, (2) is even, so Alya sets (k) to be (k|p_2 = 0|1 = 1). On the (3)rd operation, (3) is odd, so Alya sets (k) to be (k\&p_3 = 1\&3 = 1). On the (4)th operation, (4) is even, so Alya sets (k) to be (k|p_4 = 1|4 = 5). On the (5)th operation, (5) is odd, so Alya sets (k) to be (k\&p_5 = 5\&5 = 5). The final value of (k) is (5). It can be shown that the final value of (k) is at most (5) for all permutations of length (5). Another valid output is (2, 3, 1, 4, 5). For the second test case, the final value of (k) is (7). It can be shown that the final value of (k) is at m

Tutorials

Codeforces Global Round 27 Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
288417362 dk986323350512 C Oct. 28, 2024, 4:28 a.m. OK C++17 (GCC 7-32) TESTS 7 46 102400
288391200 IF-THEN C Oct. 27, 2024, 7:56 p.m. OK C++17 (GCC 7-32) TESTS 7 61 0
288377022 MR_NoSolution C Oct. 27, 2024, 6:03 p.m. OK C++17 (GCC 7-32) TESTS 7 61 0
288370239 arpan2048 C Oct. 27, 2024, 5:25 p.m. OK C++17 (GCC 7-32) TESTS 7 61 0
288422652 Koishii C Oct. 28, 2024, 5:41 a.m. OK C++17 (GCC 7-32) TESTS 7 61 102400
288417458 ajaypunna9342 C Oct. 28, 2024, 4:30 a.m. OK C++17 (GCC 7-32) TESTS 7 61 102400
288416914 GaiaKing C Oct. 28, 2024, 4:21 a.m. OK C++17 (GCC 7-32) TESTS 7 61 102400
288414132 lucifier007 C Oct. 28, 2024, 3:37 a.m. OK C++17 (GCC 7-32) TESTS 7 61 102400
288411396 coder_on_earth C Oct. 28, 2024, 2:51 a.m. OK C++17 (GCC 7-32) TESTS 7 61 102400
288401019 adityagoyal_03 C Oct. 27, 2024, 10:20 p.m. OK C++17 (GCC 7-32) TESTS 7 61 102400
288406691 _Grey_ C Oct. 28, 2024, 1:06 a.m. OK C++20 (GCC 13-64) TESTS 7 46 0
288391320 sprkrd C Oct. 27, 2024, 7:57 p.m. OK C++20 (GCC 13-64) TESTS 7 46 0
288382476 BLWxSwapNil C Oct. 27, 2024, 6:40 p.m. OK C++20 (GCC 13-64) TESTS 7 46 0
288379990 debjit81 C Oct. 27, 2024, 6:20 p.m. OK C++20 (GCC 13-64) TESTS 7 46 0
288377798 averagecper C Oct. 27, 2024, 6:06 p.m. OK C++20 (GCC 13-64) TESTS 7 46 0
288368834 delelony C Oct. 27, 2024, 5:22 p.m. OK C++20 (GCC 13-64) TESTS 7 46 0
288423818 Lonelyper C Oct. 28, 2024, 5:54 a.m. OK C++20 (GCC 13-64) TESTS 7 46 102400
288421647 Jiangnan111 C Oct. 28, 2024, 5:29 a.m. OK C++20 (GCC 13-64) TESTS 7 46 102400
288421599 Sarvesh43 C Oct. 28, 2024, 5:28 a.m. OK C++20 (GCC 13-64) TESTS 7 46 102400
288417471 GoymyGo C Oct. 28, 2024, 4:30 a.m. OK C++20 (GCC 13-64) TESTS 7 46 102400
288412777 running_Turtle C Oct. 28, 2024, 3:15 a.m. OK C++23 (GCC 14-64, msys2) TESTS 7 46 0
288387438 codesikhi.com C Oct. 27, 2024, 7:18 p.m. OK C++23 (GCC 14-64, msys2) TESTS 7 46 0
288369622 Aryaprince C Oct. 27, 2024, 5:24 p.m. OK C++23 (GCC 14-64, msys2) TESTS 7 46 0
288424621 Clclclcl C Oct. 28, 2024, 6:02 a.m. OK C++23 (GCC 14-64, msys2) TESTS 7 46 102400
288419993 mostofa_masud.shu_04 C Oct. 28, 2024, 5:06 a.m. OK C++23 (GCC 14-64, msys2) TESTS 7 46 102400
288418773 kailtsit C Oct. 28, 2024, 4:49 a.m. OK C++23 (GCC 14-64, msys2) TESTS 7 46 102400
288413894 gokuu007 C Oct. 28, 2024, 3:33 a.m. OK C++23 (GCC 14-64, msys2) TESTS 7 46 102400
288412615 Joker_ylb C Oct. 28, 2024, 3:12 a.m. OK C++23 (GCC 14-64, msys2) TESTS 7 46 102400
288406243 Depressed_C0der C Oct. 28, 2024, 12:53 a.m. OK C++23 (GCC 14-64, msys2) TESTS 7 46 102400
288395441 HProKiller C Oct. 27, 2024, 8:45 p.m. OK C++23 (GCC 14-64, msys2) TESTS 7 46 102400
288385696 ruban C Oct. 27, 2024, 7:02 p.m. OK FPC TESTS 7 280 29286400
288373699 robiulhasan1 C Oct. 27, 2024, 5:33 p.m. OK GNU C11 TESTS 7 780 0
288362795 Kameswararao C Oct. 27, 2024, 5:04 p.m. OK GNU C11 TESTS 7 843 0
288417409 nguyenquocthao00 C Oct. 28, 2024, 4:29 a.m. OK Go TESTS 7 108 15872000
288370744 treasuryonly C Oct. 27, 2024, 5:26 p.m. OK Haskell TESTS 7 109 2867200
288385792 FaBy C Oct. 27, 2024, 7:03 p.m. OK Java 21 TESTS 7 249 614400
288371469 AyushVardhan C Oct. 27, 2024, 5:28 p.m. OK Java 21 TESTS 7 265 614400
288400804 polsage C Oct. 27, 2024, 10:15 p.m. OK Java 21 TESTS 7 280 614400
288414914 amit_roy C Oct. 28, 2024, 3:50 a.m. OK Java 21 TESTS 7 281 15667200
288416154 sulabhambule C Oct. 28, 2024, 4:09 a.m. OK Java 21 TESTS 7 296 512000
288379290 iamalizaidi C Oct. 27, 2024, 6:15 p.m. OK Java 21 TESTS 7 296 4710400
288392058 rj3377295 C Oct. 27, 2024, 8:06 p.m. OK Java 21 TESTS 7 327 1228800
288366885 _firstexception C Oct. 27, 2024, 5:16 p.m. OK Java 21 TESTS 7 390 44134400
288363204 neilchetty C Oct. 27, 2024, 5:06 p.m. OK Java 21 TESTS 7 405 16076800
288406155 sujalsharma_13 C Oct. 28, 2024, 12:51 a.m. OK Java 21 TESTS 7 531 1331200
288378085 tirthgohil1410 C Oct. 27, 2024, 6:08 p.m. OK Java 8 TESTS 7 156 0
288377831 BrutHawk C Oct. 27, 2024, 6:06 p.m. OK Java 8 TESTS 7 156 0
288411609 InfinityX C Oct. 28, 2024, 2:55 a.m. OK Java 8 TESTS 7 171 0
288365296 Artistic_code C Oct. 27, 2024, 5:12 p.m. OK Java 8 TESTS 7 171 2867200
288369180 rohilkadam36 C Oct. 27, 2024, 5:22 p.m. OK Java 8 TESTS 7 186 2867200
288392178 Into_Your_Arms C Oct. 27, 2024, 8:07 p.m. OK Java 8 TESTS 7 187 0
288370765 Burhan_Akkus C Oct. 27, 2024, 5:26 p.m. OK Java 8 TESTS 7 249 1331200
288369297 aditya888 C Oct. 27, 2024, 5:23 p.m. OK Java 8 TESTS 7 249 5120000
288422629 imsaurabhkhare C Oct. 28, 2024, 5:40 a.m. OK Java 8 TESTS 7 249 18227200
288370496 rajatmah032 C Oct. 27, 2024, 5:26 p.m. OK Java 8 TESTS 7 453 0
288373382 code_100m_amgf C Oct. 27, 2024, 5:32 p.m. OK Kotlin 1.9 TESTS 7 187 5632000
288367449 hotkey C Oct. 27, 2024, 5:18 p.m. OK Kotlin 1.9 TESTS 7 265 9728000
288361249 mr_barupal C Oct. 27, 2024, 5 p.m. OK Kotlin 1.9 TESTS 7 280 10240000
288372108 El-Demonio C Oct. 27, 2024, 5:30 p.m. OK Kotlin 1.9 TESTS 7 342 11980800
288373632 bnmanubharadwaj C Oct. 27, 2024, 5:33 p.m. OK Node.js TESTS 7 187 23552000
288372042 Vitaliy270604 C Oct. 27, 2024, 5:30 p.m. OK Perl TESTS 7 249 15360000
288414111 OpKos C Oct. 28, 2024, 3:37 a.m. OK PyPy 3 TESTS 7 171 8499200
288367850 bshkort C Oct. 27, 2024, 5:19 p.m. OK PyPy 3 TESTS 7 218 20070400
288369941 VladIvanov C Oct. 27, 2024, 5:24 p.m. OK PyPy 3 TESTS 7 249 13107200
288374251 BytesizeGenius C Oct. 27, 2024, 5:34 p.m. OK PyPy 3 TESTS 7 249 20480000
288364479 AFC2002 C Oct. 27, 2024, 5:09 p.m. OK PyPy 3 TESTS 7 280 12390400
288399441 Master_Hleb C Oct. 27, 2024, 9:46 p.m. OK PyPy 3 TESTS 7 281 11468800
288392826 lo_krlo_baatt C Oct. 27, 2024, 8:14 p.m. OK PyPy 3 TESTS 7 296 12800000
288373225 justbeingashutosh C Oct. 27, 2024, 5:32 p.m. OK PyPy 3 TESTS 7 374 9318400
288368032 chyragym C Oct. 27, 2024, 5:19 p.m. OK PyPy 3-64 TESTS 7 92 7680000
288424390 navadeepsai681 C Oct. 28, 2024, 6 a.m. OK PyPy 3-64 TESTS 7 93 7372800
288397809 gafgadfdfvswe C Oct. 27, 2024, 9:18 p.m. OK PyPy 3-64 TESTS 7 108 11980800
288372770 prathamsibal81 C Oct. 27, 2024, 5:31 p.m. OK PyPy 3-64 TESTS 7 124 7475200
288374343 black_coder007 C Oct. 27, 2024, 5:34 p.m. OK PyPy 3-64 TESTS 7 124 7577600
288370434 Kedar_Dixit C Oct. 27, 2024, 5:26 p.m. OK PyPy 3-64 TESTS 7 124 7577600
288416542 mjukaria9 C Oct. 28, 2024, 4:14 a.m. OK PyPy 3-64 TESTS 7 124 8192000
288389652 counterstrike2 C Oct. 27, 2024, 7:40 p.m. OK PyPy 3-64 TESTS 7 124 8294400
288397864 gafgadfdfvswe C Oct. 27, 2024, 9:19 p.m. OK PyPy 3-64 TESTS 7 124 11673600
288405929 Azimjonm2333 C Oct. 28, 2024, 12:45 a.m. OK PyPy 3-64 TESTS 7 124 13209600
288397791 gafgadfdfvswe C Oct. 27, 2024, 9:17 p.m. OK Python 3 TESTS 7 125 25292800
288366565 Mathemaddict C Oct. 27, 2024, 5:15 p.m. OK Python 3 TESTS 7 140 25907200
288371872 18_Vansh C Oct. 27, 2024, 5:29 p.m. OK Python 3 TESTS 7 155 25702400
288370932 java_unfriendme_ C Oct. 27, 2024, 5:27 p.m. OK Python 3 TESTS 7 156 25702400
288372927 Dark_King_Rayleigh C Oct. 27, 2024, 5:31 p.m. OK Python 3 TESTS 7 171 24883200
288372739 nooooo111 C Oct. 27, 2024, 5:31 p.m. OK Python 3 TESTS 7 171 25702400
288374830 paugh1612 C Oct. 27, 2024, 5:34 p.m. OK Python 3 TESTS 7 171 27648000
288372713 Kunal_2021331 C Oct. 27, 2024, 5:31 p.m. OK Python 3 TESTS 7 202 25190400
288370306 rairuaiuiuiqu C Oct. 27, 2024, 5:25 p.m. OK Python 3 TESTS 7 202 25600000
288361019 citrus_AJ C Oct. 27, 2024, 4:59 p.m. OK Python 3 TESTS 7 202 27033600
288374524 aa008 C Oct. 27, 2024, 5:34 p.m. OK Ruby 3 TESTS 7 390 409600
288403882 EFTEKHER2000 C Oct. 27, 2024, 11:39 p.m. OK Rust 2021 TESTS 7 62 102400
288369799 akash9518 C Oct. 27, 2024, 5:24 p.m. OK Rust 2021 TESTS 7 93 7577600
288382898 A.Elgazzar C Oct. 27, 2024, 6:44 p.m. OK Scala TESTS 7 577 11059200
288374135 posiedon_7 C Oct. 27, 2024, 5:34 p.m. OK Scala TESTS 7 842 409600

remove filters

Back to search problems