Codeforces Round 899 (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
1882 Codeforces Round 899 (Div. 2) FINISHED False 7200 36170699 Sept. 25, 2023, 2:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 5583 ) D Tree XOR PROGRAMMING bitmasks dfs and similar dp greedy trees

B'You are given a tree with n vertices labeled from 1 to n . An integer a_{i} is written on vertex i for i = 1, 2, ldots, n . You want to make all a_{i} equal by performing some (possibly, zero) spells. Suppose you root the tree at some vertex. On each spell, you can select any vertex v and any non-negative integer c . Then for all vertices i in the subtree ^{ dagger} of v , replace a_{i} with a_{i} oplus c . The cost of this spell is s cdot c , where s is the number of vertices in the subtree. Here oplus denotes the bitwise XOR operation. Let m_r be the minimum possible total cost required to make all a_i equal, if vertex r is chosen as the root of the tree. Find m_{1}, m_{2}, ldots, m_{n} . ^{ dagger} Suppose vertex r is chosen as the root of the tree. Then vertex i belongs to the subtree of v if the simple path from i to r contains v . Each test contains multiple test cases. The first line contains the number of test cases t ( 1 <= t <= 10^{4} ). The description of the test cases follows. The first line of each test case contains a single integer n ( 1 <= n <= 2 cdot 10^{5} ). The second line of each test case contains n integers a_1, a_2, ldots, a_n ( 0 <= a_i < 2^{20} ). Each of the next n-1 lines contains two integers u and v ( 1 <= u, v <= n ), denoting that there is an edge connecting two vertices u and v . It is guaranteed that the given edges form a tree. It is guaranteed that the sum of n over all test cases does not exceed 2 cdot 10^{5} . For each test case, print m_1, m_2, ldots, m_n on a new line. In the first test case, to find m_1 we root the tree at vertex 1 . Now all the values in array a are equal, and the total cost is 3 + 3 + 2 = 8 . The values m_2 , '...

Tutorials

Codeforces Round 899 (Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
225204504 mban259 D Sept. 26, 2023, 4:06 a.m. OK C# 10 TESTS 30 561 86835200
225200209 lAMaLOSER D Sept. 26, 2023, 3 a.m. OK C# 10 TESTS 30 1138 78643200
225153278 garyfxc163 D Sept. 25, 2023, 4:32 p.m. OK C# 10 TESTS 30 1294 95334400
225145338 TermostatoEn24 D Sept. 25, 2023, 4:11 p.m. OK GNU C11 TESTS 30 2917 30412800
225211686 a999999 D Sept. 26, 2023, 5:50 a.m. OK GNU C++14 TESTS 30 202 25292800
225206517 order_rabbit D Sept. 26, 2023, 4:39 a.m. OK GNU C++14 TESTS 30 296 23244800
225198849 iterater D Sept. 26, 2023, 2:39 a.m. OK GNU C++14 TESTS 30 311 23347200
225212422 luck_lgd D Sept. 26, 2023, 5:59 a.m. OK GNU C++14 TESTS 30 311 28364800
225202573 itshawn D Sept. 26, 2023, 3:34 a.m. OK GNU C++14 TESTS 30 312 32972800
225202700 hardstone D Sept. 26, 2023, 3:36 a.m. OK GNU C++14 TESTS 30 327 18636800
225201000 huanghongye D Sept. 26, 2023, 3:11 a.m. OK GNU C++14 TESTS 30 327 19968000
225201542 huanghongye D Sept. 26, 2023, 3:19 a.m. OK GNU C++14 TESTS 30 327 19968000
225193219 OvO_Zuo D Sept. 26, 2023, 12:58 a.m. OK GNU C++14 TESTS 30 327 20172800
225198490 dtta D Sept. 26, 2023, 2:33 a.m. OK GNU C++14 TESTS 30 327 20787200
225199441 TheForsaking D Sept. 26, 2023, 2:48 a.m. OK GNU C++17 TESTS 30 280 24064000
225201889 value0 D Sept. 26, 2023, 3:24 a.m. OK GNU C++17 TESTS 30 312 15769600
225183037 lxyb D Sept. 25, 2023, 9:11 p.m. OK GNU C++17 TESTS 30 312 21811200
225145525 B0b_114514 D Sept. 25, 2023, 4:12 p.m. OK GNU C++17 TESTS 30 327 21606400
225160293 zeemanz D Sept. 25, 2023, 5:23 p.m. OK GNU C++17 TESTS 30 342 20787200
225199343 Fishermanz D Sept. 26, 2023, 2:47 a.m. OK GNU C++17 TESTS 30 342 23552000
225169932 zeemanz D Sept. 25, 2023, 6:38 p.m. OK GNU C++17 TESTS 30 342 23961600
225197515 ssaabbeerr D Sept. 26, 2023, 2:18 a.m. OK GNU C++17 TESTS 30 343 28160000
225204952 YakultGo D Sept. 26, 2023, 4:13 a.m. OK GNU C++17 TESTS 30 343 32153600
225202252 52xwj D Sept. 26, 2023, 3:29 a.m. OK GNU C++17 TESTS 30 358 16076800
225176834 shobonvip D Sept. 25, 2023, 7:47 p.m. OK GNU C++17 (64) TESTS 30 62 12083200
225168500 AuroraAlaska D Sept. 25, 2023, 6:25 p.m. OK GNU C++17 (64) TESTS 30 234 38400000
225202129 sorry_Misono_Mika D Sept. 26, 2023, 3:28 a.m. OK GNU C++17 (64) TESTS 30 280 37068800
225189978 jdurie D Sept. 25, 2023, 11:40 p.m. OK GNU C++17 (64) TESTS 30 280 38502400
225196077 Fakedreamer D Sept. 26, 2023, 1:52 a.m. OK GNU C++17 (64) TESTS 30 280 40038400
225196154 Taibo D Sept. 26, 2023, 1:54 a.m. OK GNU C++17 (64) TESTS 30 295 36864000
225190664 Maveriik D Sept. 26, 2023, midnight OK GNU C++17 (64) TESTS 30 295 56934400
225181066 shmax_ D Sept. 25, 2023, 8:39 p.m. OK GNU C++17 (64) TESTS 30 296 35225600
225201513 Owmicron D Sept. 26, 2023, 3:19 a.m. OK GNU C++17 (64) TESTS 30 296 35328000
225199445 XswPP D Sept. 26, 2023, 2:48 a.m. OK GNU C++17 (64) TESTS 30 296 43212800
225171035 shobonvip D Sept. 25, 2023, 6:48 p.m. OK GNU C++20 (64) TESTS 30 46 14540800
225176189 shobonvip D Sept. 25, 2023, 7:40 p.m. OK GNU C++20 (64) TESTS 30 61 12083200
225175715 shobonvip D Sept. 25, 2023, 7:35 p.m. OK GNU C++20 (64) TESTS 30 61 12083200
225176174 shobonvip D Sept. 25, 2023, 7:40 p.m. OK GNU C++20 (64) TESTS 30 62 12083200
225175996 shobonvip D Sept. 25, 2023, 7:38 p.m. OK GNU C++20 (64) TESTS 30 62 12083200
225176752 shobonvip D Sept. 25, 2023, 7:46 p.m. OK GNU C++20 (64) TESTS 30 62 12083200
225171430 shobonvip D Sept. 25, 2023, 6:52 p.m. OK GNU C++20 (64) TESTS 30 62 12902400
225172161 noya2 D Sept. 25, 2023, 7 p.m. OK GNU C++20 (64) TESTS 30 62 12902400
225171374 shobonvip D Sept. 25, 2023, 6:52 p.m. OK GNU C++20 (64) TESTS 30 62 12902400
225171461 shobonvip D Sept. 25, 2023, 6:53 p.m. OK GNU C++20 (64) TESTS 30 62 14540800
225207310 Panther369 D Sept. 26, 2023, 4:51 a.m. OK Java 11 TESTS 30 935 86323200
225145508 kratos56 D Sept. 25, 2023, 4:12 p.m. OK Java 11 TESTS 30 1013 69632000
225149165 djrfrn D Sept. 25, 2023, 4:22 p.m. OK Java 11 TESTS 30 1403 188518400
225173361 TCchen D Sept. 25, 2023, 7:11 p.m. OK Java 11 TESTS 30 2152 36147200
225207934 Mamimi D Sept. 26, 2023, 5:01 a.m. OK Java 17 TESTS 30 920 92774400
225157402 dusty.and.rusty D Sept. 25, 2023, 5:07 p.m. OK Java 17 TESTS 30 1076 81305600
225151121 keduolimm D Sept. 25, 2023, 4:27 p.m. OK Java 17 TESTS 30 1154 86220800
225156844 Ligh0x74 D Sept. 25, 2023, 5:04 p.m. OK Java 21 TESTS 30 1060 80076800
225192271 NerfThis D Sept. 26, 2023, 12:37 a.m. OK Java 8 TESTS 30 389 35737600
225149650 RMA-NB D Sept. 25, 2023, 4:23 p.m. OK Java 8 TESTS 30 1700 45056000
225152459 chinesedfan D Sept. 25, 2023, 4:30 p.m. OK Node.js TESTS 30 1325 72704000
225157546 misorin D Sept. 25, 2023, 5:08 p.m. OK PyPy 3-64 TESTS 30 280 42086400
225160830 CinaDor D Sept. 25, 2023, 5:27 p.m. OK PyPy 3-64 TESTS 30 716 56729600
225144917 kavorka D Sept. 25, 2023, 4:10 p.m. OK PyPy 3-64 TESTS 30 966 69734400
225147438 9.86960440109 D Sept. 25, 2023, 4:17 p.m. OK PyPy 3-64 TESTS 30 1060 139980800
225146810 samriddhjn D Sept. 25, 2023, 4:15 p.m. OK PyPy 3-64 TESTS 30 1247 132710400
225196353 toam D Sept. 26, 2023, 1:57 a.m. OK PyPy 3-64 TESTS 30 1294 100864000
225195866 Remineva D Sept. 26, 2023, 1:48 a.m. OK PyPy 3-64 TESTS 30 1310 116940800
225194406 toam D Sept. 26, 2023, 1:20 a.m. OK PyPy 3-64 TESTS 30 1357 102195200
225194850 toam D Sept. 26, 2023, 1:28 a.m. OK PyPy 3-64 TESTS 30 1388 103321600
225156854 mikeac D Sept. 25, 2023, 5:04 p.m. OK PyPy 3-64 TESTS 30 1419 148377600
225170094 0npata D Sept. 25, 2023, 6:39 p.m. OK Rust 2021 TESTS 30 373 121344000
225149288 haihamabossu D Sept. 25, 2023, 4:22 p.m. OK Rust 2021 TESTS 30 561 116326400
225148578 kiwiyou D Sept. 25, 2023, 4:20 p.m. OK Rust 2021 TESTS 30 2277 32358400

remove filters

Back to search problems