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.
Problems
B"You are given a tree consisting of n vertices. A number is written on each vertex; the number on vertex i is equal to a_i . Recall that a simple path is a path that visits each vertex at most once. Let the weight of the path be the bitwise XOR of the values written on vertices it consists of. Let's say that a tree is good if no simple path has weight 0 . You can apply the following operation any number of times (possibly, zero): select a vertex of the tree and replace the value written on it with an arbitrary positive integer. What is the minimum number of times you have to apply this operation in order to make the tree good? The first line contains one integer n ( 1 <= n <= 2 cdot 10^5 ) -- the number of vertices. The second line contains n integers a_1 , a_2 , ..., a_n ( 1 <= a_i < 2^{30} ) -- the numbers written on vertices. Then n - 1 lines follow, each containing two integers x and y ( 1 <= x, y <= n; x ne y ) denoting an edge connecting vertex x with vertex y . It is guaranteed that these edges form a tree. Print a single integer -- the minimum number of times you have to apply the operation in order to make the tree good. In the first example, it is enough to replace the value on the vertex 1 with 13 , and the value on the vertex 4 with 42 . "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
165264725 |
jiangbowen |
E |
July 22, 2022, 4:54 a.m. |
OK |
GNU C++14 |
TESTS |
57 |
358 |
29696000 |
|
|
165264807 |
jiangbowen |
E |
July 22, 2022, 4:55 a.m. |
OK |
GNU C++14 |
TESTS |
57 |
358 |
29696000 |
|
|
165252088 |
win10 |
E |
July 22, 2022, 1:57 a.m. |
OK |
GNU C++14 |
TESTS |
57 |
452 |
67276800 |
|
|
165263789 |
keywet06 |
E |
July 22, 2022, 4:41 a.m. |
OK |
GNU C++14 |
TESTS |
57 |
467 |
24268800 |
|
|
165268449 |
PolarAid |
E |
July 22, 2022, 5:45 a.m. |
OK |
GNU C++14 |
TESTS |
57 |
467 |
24678400 |
|
|
165228485 |
anubhavdhar |
E |
July 21, 2022, 6:19 p.m. |
OK |
GNU C++14 |
TESTS |
57 |
467 |
62054400 |
|
|
165252621 |
zzt_ |
E |
July 22, 2022, 2:05 a.m. |
OK |
GNU C++14 |
TESTS |
57 |
482 |
28160000 |
|
|
165268072 |
CK6100LGEV2 |
E |
July 22, 2022, 5:40 a.m. |
OK |
GNU C++14 |
TESTS |
57 |
483 |
59699200 |
|
|
165253014 |
CK2021 |
E |
July 22, 2022, 2:10 a.m. |
OK |
GNU C++14 |
TESTS |
57 |
498 |
22016000 |
|
|
165249601 |
Tyyyyyy |
E |
July 22, 2022, 1:19 a.m. |
OK |
GNU C++14 |
TESTS |
57 |
499 |
59699200 |
|
|
165238334 |
SEGFAULTSEGFAULTSEGFAULT |
E |
July 21, 2022, 8:44 p.m. |
OK |
GNU C++17 |
TESTS |
57 |
374 |
54476800 |
|
|
165238921 |
SEGFAULTSEGFAULTSEGFAULT |
E |
July 21, 2022, 8:56 p.m. |
OK |
GNU C++17 |
TESTS |
57 |
374 |
54476800 |
|
|
165266031 |
Bobocan |
E |
July 22, 2022, 5:12 a.m. |
OK |
GNU C++17 |
TESTS |
57 |
374 |
59494400 |
|
|
165232663 |
SEGFAULTSEGFAULTSEGFAULT |
E |
July 21, 2022, 7:09 p.m. |
OK |
GNU C++17 |
TESTS |
57 |
405 |
54476800 |
|
|
165229312 |
awasthiakshit11 |
E |
July 21, 2022, 6:28 p.m. |
OK |
GNU C++17 |
TESTS |
57 |
436 |
66969600 |
|
|
165256203 |
kk19212 |
E |
July 22, 2022, 2:55 a.m. |
OK |
GNU C++17 |
TESTS |
57 |
436 |
67072000 |
|
|
165229724 |
cjmyyds |
E |
July 21, 2022, 6:32 p.m. |
OK |
GNU C++17 |
TESTS |
57 |
451 |
53555200 |
|
|
165239693 |
LeMinhHoangFake |
E |
July 21, 2022, 9:14 p.m. |
OK |
GNU C++17 |
TESTS |
57 |
451 |
58982400 |
|
|
165229740 |
cjmyyds |
E |
July 21, 2022, 6:32 p.m. |
OK |
GNU C++17 |
TESTS |
57 |
452 |
41164800 |
|
|
165217723 |
zjbztianya |
E |
July 21, 2022, 4:49 p.m. |
OK |
GNU C++17 |
TESTS |
57 |
452 |
67788800 |
|
|
165254032 |
Coki628 |
E |
July 22, 2022, 2:25 a.m. |
OK |
GNU C++17 (64) |
TESTS |
57 |
312 |
110080000 |
|
|
165254117 |
Coki628 |
E |
July 22, 2022, 2:26 a.m. |
OK |
GNU C++17 (64) |
TESTS |
57 |
342 |
85196800 |
|
|
165261273 |
CartesianTree |
E |
July 22, 2022, 4:06 a.m. |
OK |
GNU C++17 (64) |
TESTS |
57 |
358 |
79462400 |
|
|
165255684 |
yamate11 |
E |
July 22, 2022, 2:48 a.m. |
OK |
GNU C++17 (64) |
TESTS |
57 |
374 |
79667200 |
|
|
165253634 |
Coki628 |
E |
July 22, 2022, 2:19 a.m. |
OK |
GNU C++17 (64) |
TESTS |
57 |
420 |
51200000 |
|
|
165217363 |
Kenshin2438 |
E |
July 21, 2022, 4:47 p.m. |
OK |
GNU C++17 (64) |
TESTS |
57 |
420 |
61542400 |
|
|
165222186 |
zzlzzlzzl |
E |
July 21, 2022, 5:16 p.m. |
OK |
GNU C++17 (64) |
TESTS |
57 |
420 |
121036800 |
|
|
165236949 |
propane |
E |
July 21, 2022, 8:19 p.m. |
OK |
GNU C++17 (64) |
TESTS |
57 |
436 |
35635200 |
|
|
165225286 |
Romy67 |
E |
July 21, 2022, 5:44 p.m. |
OK |
GNU C++17 (64) |
TESTS |
57 |
436 |
53452800 |
|
|
165244352 |
Beevo |
E |
July 21, 2022, 11:06 p.m. |
OK |
GNU C++17 (64) |
TESTS |
57 |
436 |
91340800 |
|
|
165215147 |
WAutomaton |
E |
July 21, 2022, 4:38 p.m. |
OK |
GNU C++20 (64) |
TESTS |
57 |
311 |
73318400 |
|
|
165221471 |
ttmred |
E |
July 21, 2022, 5:11 p.m. |
OK |
GNU C++20 (64) |
TESTS |
57 |
358 |
53145600 |
|
|
165232305 |
Ferume |
E |
July 21, 2022, 7:04 p.m. |
OK |
GNU C++20 (64) |
TESTS |
57 |
358 |
64000000 |
|
|
165231574 |
shatovoleg |
E |
July 21, 2022, 6:54 p.m. |
OK |
GNU C++20 (64) |
TESTS |
57 |
358 |
75059200 |
|
|
165221296 |
lis05 |
E |
July 21, 2022, 5:09 p.m. |
OK |
GNU C++20 (64) |
TESTS |
57 |
358 |
96358400 |
|
|
165257521 |
shaosy |
E |
July 22, 2022, 3:13 a.m. |
OK |
GNU C++20 (64) |
TESTS |
57 |
374 |
63385600 |
|
|
165257865 |
shaosy |
E |
July 22, 2022, 3:18 a.m. |
OK |
GNU C++20 (64) |
TESTS |
57 |
374 |
63385600 |
|
|
165222424 |
lis05 |
E |
July 21, 2022, 5:18 p.m. |
OK |
GNU C++20 (64) |
TESTS |
57 |
374 |
96358400 |
|
|
165227178 |
Andreikkaa |
E |
July 21, 2022, 6:03 p.m. |
OK |
GNU C++20 (64) |
TESTS |
57 |
389 |
48844800 |
|
|
165243940 |
guperman |
E |
July 21, 2022, 10:54 p.m. |
OK |
GNU C++20 (64) |
TESTS |
57 |
389 |
54374400 |
|
|
165227528 |
Dukkha |
E |
July 21, 2022, 6:09 p.m. |
OK |
Java 17 |
TESTS |
57 |
1933 |
191897600 |
|
|
165226550 |
MagentaCobra |
E |
July 21, 2022, 5:56 p.m. |
OK |
Java 8 |
TESTS |
57 |
935 |
112332800 |
|
|
165250398 |
O_E |
E |
July 22, 2022, 1:33 a.m. |
OK |
Java 8 |
TESTS |
57 |
1075 |
109568000 |
|
|
165224619 |
misorin |
E |
July 21, 2022, 5:38 p.m. |
OK |
PyPy 3 |
TESTS |
57 |
1669 |
132198400 |
|
|
165229011 |
robostac |
E |
July 21, 2022, 6:25 p.m. |
OK |
Rust 2021 |
TESTS |
57 |
234 |
96358400 |
|
|
165236126 |
bjin |
E |
July 21, 2022, 8:05 p.m. |
OK |
Rust 2021 |
TESTS |
57 |
327 |
124518400 |
|
|
165234890 |
bjin |
E |
July 21, 2022, 7:45 p.m. |
OK |
Rust 2021 |
TESTS |
57 |
342 |
124518400 |
|
|
165236015 |
bjin |
E |
July 21, 2022, 8:03 p.m. |
OK |
Rust 2021 |
TESTS |
57 |
389 |
124518400 |
|
|
remove filters
Back to search problems