Codeforces Round 798 (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
1689 Codeforces Round 798 (Div. 2) FINISHED False 7200 121526723 June 10, 2022, 4:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 1357 ) E ANDfinity PROGRAMMING bitmasks brute force constructive algorithms dfs and similar dsu graphs

Bit Lightyear, to the ANDfinity and beyond! After graduating from computer sciences, Vlad has been awarded an array a_1,a_2, ldots,a_n of n non-negative integers. As it is natural, he wanted to construct a graph consisting of n vertices, numbered 1, 2, ldots, n . He decided to add an edge between i and j if and only if a_i & a_j > 0 , where & denotes the bitwise AND operation. Vlad also wants the graph to be connected, which might not be the case initially. In order to satisfy that, he can do the following two types of operations on the array: It can be proven that there exists a finite sequence of operations such that the graph will be connected. So, can you please help Vlad find the minimum possible number of operations to do that and also provide the way how to do that? There are several test cases in the input data. The first line contains a single integer t ( 1 <= q t <= q 1000 ) -- the number of test cases. This is followed by the test cases description. The first line of each test case contains an integer n ( 2 <= q n <= q 2000 ). The second line of each test case contains n integers a_1, a_2, ldots, a_n ( 0 <= q a_i < 2^{30} ) -- the elements of the array. It is guaranteed that the sum of n over all test cases does not exceed 2000 . For each test case, print a single integer m in the first line -- the minimum number of operations. In the second line print the array after a valid sequence of operations that have been done such that the graph from the task becomes connected. If there are multiple solutions, output any. In the first test case, the graph is already connected. In the second test case, we can increment 0 twice and end up with the array [2,2] . Since 2 & 2 = 2 > 0 , the graph is connected. It can be shown that one operation is not enough. In the third test case, we can decrement 12 once and we end up with an a

Tutorials

Editorial for Codeforces Round #798 (Div. 2)

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
160158618 chro4896 E June 11, 2022, 3:58 a.m. OK GNU C11 TESTS 104 46 0
160152753 zhaojinjia E June 11, 2022, 1:09 a.m. OK GNU C++14 TESTS 104 31 409600
160146151 Sam_a17 E June 10, 2022, 8:51 p.m. OK GNU C++14 TESTS 104 31 614400
160148912 SuperJ6 E June 10, 2022, 10:07 p.m. OK GNU C++14 TESTS 104 31 716800
160129785 TadijaSebez E June 10, 2022, 6:17 p.m. OK GNU C++14 TESTS 104 31 1536000
160145435 Sam_a17 E June 10, 2022, 8:35 p.m. OK GNU C++14 TESTS 104 31 2764800
160148679 obaydullahmhs E June 10, 2022, 9:59 p.m. OK GNU C++14 TESTS 104 46 307200
160127041 bcofwy060 E June 10, 2022, 6:08 p.m. OK GNU C++14 TESTS 104 46 2355200
160156103 grass8cow E June 11, 2022, 2:58 a.m. OK GNU C++14 TESTS 104 62 0
160139869 xing89qs E June 10, 2022, 7:16 p.m. OK GNU C++14 TESTS 104 62 102400
160153675 qvzeyang E June 11, 2022, 1:45 a.m. OK GNU C++14 TESTS 104 62 11980800
160138460 trek_walker E June 10, 2022, 7:05 p.m. OK GNU C++17 TESTS 104 15 102400
160145319 panyan7 E June 10, 2022, 8:34 p.m. OK GNU C++17 TESTS 104 30 204800
160145920 stefanbalaz2 E June 10, 2022, 8:46 p.m. OK GNU C++17 TESTS 104 31 0
160130305 orz_wmg E June 10, 2022, 6:19 p.m. OK GNU C++17 TESTS 104 31 204800
160163271 luicosas E June 11, 2022, 5:21 a.m. OK GNU C++17 TESTS 104 31 204800
160139745 Ecrade_ E June 10, 2022, 7:15 p.m. OK GNU C++17 TESTS 104 31 307200
160164644 izlyforever E June 11, 2022, 5:41 a.m. OK GNU C++17 TESTS 104 31 307200
160153653 penguinhacker E June 11, 2022, 1:44 a.m. OK GNU C++17 TESTS 104 31 409600
160129585 4ever_in_queue E June 10, 2022, 6:16 p.m. OK GNU C++17 TESTS 104 31 512000
160148439 DiegoGarcia E June 10, 2022, 9:52 p.m. OK GNU C++17 TESTS 104 31 1126400
160138152 huangxiaohua E June 10, 2022, 7:03 p.m. OK GNU C++17 (64) TESTS 104 15 0
160146505 Bobocan E June 10, 2022, 8:59 p.m. OK GNU C++17 (64) TESTS 104 31 0
160145800 mattagar6 E June 10, 2022, 8:43 p.m. OK GNU C++17 (64) TESTS 104 31 0
160138652 huangxiaohua E June 10, 2022, 7:06 p.m. OK GNU C++17 (64) TESTS 104 31 0
160134730 enslaved E June 10, 2022, 6:32 p.m. OK GNU C++17 (64) TESTS 104 31 102400
160139132 UnoK E June 10, 2022, 7:10 p.m. OK GNU C++17 (64) TESTS 104 31 614400
160161089 jiajieshi E June 11, 2022, 4:47 a.m. OK GNU C++17 (64) TESTS 104 31 2457600
160162295 xcyle E June 11, 2022, 5:07 a.m. OK GNU C++17 (64) TESTS 104 46 0
160129450 lightseba E June 10, 2022, 6:16 p.m. OK GNU C++17 (64) TESTS 104 46 0
160142519 MarcosK E June 10, 2022, 7:46 p.m. OK GNU C++17 (64) TESTS 104 46 102400
160147889 MAKMED1337 E June 10, 2022, 9:35 p.m. OK GNU C++20 (64) TESTS 104 15 0
160132845 Himeko E June 10, 2022, 6:27 p.m. OK GNU C++20 (64) TESTS 104 15 0
160151766 johnLate E June 11, 2022, 12:22 a.m. OK GNU C++20 (64) TESTS 104 15 0
160149983 Junco_dh E June 10, 2022, 10:49 p.m. OK GNU C++20 (64) TESTS 104 15 102400
160143156 yash_daga E June 10, 2022, 7:55 p.m. OK GNU C++20 (64) TESTS 104 15 204800
160139485 AudM E June 10, 2022, 7:13 p.m. OK GNU C++20 (64) TESTS 104 15 2150400
160129401 yash_daga E June 10, 2022, 6:16 p.m. OK GNU C++20 (64) TESTS 104 15 2969600
160126381 physics0523 E June 10, 2022, 6:05 p.m. OK GNU C++20 (64) TESTS 104 30 0
160162991 jonathanps E June 11, 2022, 5:17 a.m. OK GNU C++20 (64) TESTS 104 31 0
160163709 jonathanps E June 11, 2022, 5:28 a.m. OK GNU C++20 (64) TESTS 104 31 0
160151394 profchi E June 11, 2022, 12:04 a.m. OK Java 11 TESTS 104 1013 0
160131364 DylanSmith E June 10, 2022, 6:22 p.m. OK Java 8 TESTS 104 1247 0
160145130 Hakiobo E June 10, 2022, 8:30 p.m. OK Kotlin 1.4 TESTS 104 140 1228800
160141583 Hakiobo E June 10, 2022, 7:35 p.m. OK Kotlin 1.4 TESTS 104 186 1126400
160139027 Hakiobo E June 10, 2022, 7:09 p.m. OK Kotlin 1.4 TESTS 104 202 1228800
160144895 Hakiobo E June 10, 2022, 8:25 p.m. OK Kotlin 1.4 TESTS 104 217 1228800
160139738 Hakiobo E June 10, 2022, 7:15 p.m. OK Kotlin 1.4 TESTS 104 217 1228800
160128328 Jimanbanashi E June 10, 2022, 6:12 p.m. OK PyPy 2 TESTS 104 249 3891200
160158173 eepsilon E June 11, 2022, 3:49 a.m. OK PyPy 3 TESTS 104 420 10752000
160143327 hxu10 E June 10, 2022, 7:58 p.m. OK PyPy 3 TESTS 104 608 10240000

remove filters

Back to search problems