Codeforces Round 746 (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
1592 Codeforces Round 746 (Div. 2) FINISHED False 7200 98551499 Oct. 3, 2021, 2:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 8074 ) C Bakry and Partitioning PROGRAMMING bitmasks constructive algorithms dfs and similar dp graphs trees

B'Bakry faced a problem, but since he 's lazy to solve it, he asks for your help. You are given a tree of n nodes, the i -th node has value a_i assigned to it for each i from 1 to n . As a reminder, a tree on n nodes is a connected graph with n-1 edges. You want to delete at least 1 , but at most k-1 edges from the tree, so that the following condition would hold: For every connected component calculate the bitwise XOR of the values of the nodes in it. Then, these values have to be the same for all connected components. Is it possible to achieve this condition? Each test contains multiple test cases. The first line contains the number of test cases t (1 <= q t <= q 5 cdot 10^4) . Description of the test cases follows. The first line of each test case contains two integers n and k (2 <= q k <= q n <= q 10^5) . The second line of each test case contains n integers a_1, a_2, ..., a_n (1 <= q a_i <= q 10^9) . The i -th of the next n-1 lines contains two integers u_i and v_i ( 1 <= q u_i, v_i <= q n , u_i neq v_i ), which means that there 's an edge between nodes u_i and v_i . It is guaranteed that the given graph is a tree. It is guaranteed that the sum of n over all test cases doesn 't exceed 2 cdot 10^5 . For each test case, you should output a single string. If you can delete the edges according to the conditions written above, output "YES" (without quotes). Otherwise, output "NO" (without quotes). You can print each letter of "YES" and "NO" in any case (upper or lower). It can be shown that the objection is not achievable for first, third, and fifth test cases. In the second test case, you can just remove all the edges. There will be 5 connected components, each containing only one node with value 3 , so the bitwise XORs will be 3 for all of them. In the fourth test case, this is the tree:'...

Tutorials

95583

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
130716290 rainboy C Oct. 3, 2021, 4:18 p.m. OK GNU C11 TESTS 39 140 9728000
130729920 xiaoziyao C Oct. 3, 2021, 6:02 p.m. OK GNU C++14 TESTS 42 124 10137600
130753074 Bananana. C Oct. 4, 2021, 3:24 a.m. OK GNU C++14 TESTS 45 140 8089600
130725109 rickwang C Oct. 3, 2021, 5:12 p.m. OK GNU C++14 TESTS 40 140 8089600
130727932 rickwang C Oct. 3, 2021, 5:41 p.m. OK GNU C++14 TESTS 42 155 6553600
130724622 Omar_AbdelGhani C Oct. 3, 2021, 5:09 p.m. OK GNU C++14 TESTS 40 155 7987200
130751575 codycode C Oct. 4, 2021, 2:56 a.m. OK GNU C++14 TESTS 45 155 8601600
130750738 PhaiCoGiaiQuocGia C Oct. 4, 2021, 2:40 a.m. OK GNU C++14 TESTS 45 155 9728000
130750424 myf C Oct. 4, 2021, 2:34 a.m. OK GNU C++14 TESTS 45 155 10035200
130756076 _jsgnt C Oct. 4, 2021, 4:19 a.m. OK GNU C++14 TESTS 45 155 10137600
130750221 oceeff C Oct. 4, 2021, 2:31 a.m. OK GNU C++14 TESTS 45 156 7270400
130750056 Mamba0Z C Oct. 4, 2021, 2:28 a.m. OK GNU C++17 TESTS 45 140 6963200
130751678 xiayichen C Oct. 4, 2021, 2:58 a.m. OK GNU C++17 TESTS 45 140 7372800
130719163 R136a1 C Oct. 3, 2021, 4:26 p.m. OK GNU C++17 TESTS 39 140 8806400
130758303 2019112325 C Oct. 4, 2021, 4:54 a.m. OK GNU C++17 TESTS 45 140 10342400
130757392 kongweisa C Oct. 4, 2021, 4:40 a.m. OK GNU C++17 TESTS 45 140 10342400
130725285 zhouzhi C Oct. 3, 2021, 5:13 p.m. OK GNU C++17 TESTS 40 155 7987200
130725533 ysl0310 C Oct. 3, 2021, 5:16 p.m. OK GNU C++17 TESTS 40 155 7987200
130724191 orzhouzhi C Oct. 3, 2021, 5:07 p.m. OK GNU C++17 TESTS 39 155 7987200
130753119 Froshine C Oct. 4, 2021, 3:24 a.m. OK GNU C++17 TESTS 45 155 8806400
130758356 _comfortably_numb C Oct. 4, 2021, 4:55 a.m. OK GNU C++17 TESTS 45 155 9113600
130732053 blueomega C Oct. 3, 2021, 6:29 p.m. OK GNU C++17 (64) TESTS 42 124 10444800
130750556 tyin C Oct. 4, 2021, 2:37 a.m. OK GNU C++17 (64) TESTS 45 124 10854400
130715033 HuaShanLunJian C Oct. 3, 2021, 4:14 p.m. OK GNU C++17 (64) TESTS 39 124 11468800
130753108 jjjjssss6 C Oct. 4, 2021, 3:24 a.m. OK GNU C++17 (64) TESTS 45 124 13107200
130731561 blueomega C Oct. 3, 2021, 6:23 p.m. OK GNU C++17 (64) TESTS 42 124 36147200
130757753 lucccff C Oct. 4, 2021, 4:46 a.m. OK GNU C++17 (64) TESTS 45 140 14028800
130739053 Shakib_Hossain2050 C Oct. 3, 2021, 8:30 p.m. OK GNU C++17 (64) TESTS 43 140 14438400
130753113 InFaNg C Oct. 4, 2021, 3:24 a.m. OK GNU C++17 (64) TESTS 45 140 15667200
130746134 Acc_Robin C Oct. 4, 2021, 12:33 a.m. OK GNU C++17 (64) TESTS 45 155 10342400
130733095 jimm89 C Oct. 3, 2021, 6:44 p.m. OK GNU C++17 (64) TESTS 42 155 10752000
130719659 humwawe C Oct. 3, 2021, 4:27 p.m. OK Java 11 TESTS 39 233 25804800
130757117 nitin23329 C Oct. 4, 2021, 4:36 a.m. OK Java 11 TESTS 45 483 44748800
130754415 Tarun200109 C Oct. 4, 2021, 3:48 a.m. OK Java 11 TESTS 45 592 32358400
130750831 yuruiyin C Oct. 4, 2021, 2:42 a.m. OK Java 11 TESTS 45 592 43724800
130715113 saptarshi1729 C Oct. 3, 2021, 4:14 p.m. OK Java 11 TESTS 39 670 85401600
130745250 bobbilyking C Oct. 3, 2021, 11:56 p.m. OK Java 11 TESTS 45 717 66150400
130717163 tankman890 C Oct. 3, 2021, 4:20 p.m. OK Java 11 TESTS 39 717 79155200
130762358 Lelouch_1 C Oct. 4, 2021, 5:57 a.m. OK Java 8 TESTS 45 498 36044800
130742489 invincible777 C Oct. 3, 2021, 10:03 p.m. OK Java 8 TESTS 43 514 40550400
130737727 Depool C Oct. 3, 2021, 8:04 p.m. OK Java 8 TESTS 43 561 20684800
130715900 naitikvarshney C Oct. 3, 2021, 4:16 p.m. OK Java 8 TESTS 39 670 46796800
130728034 nitinrishab2000 C Oct. 3, 2021, 5:42 p.m. OK Java 8 TESTS 42 717 41164800
130738079 Restricted C Oct. 3, 2021, 8:11 p.m. OK Java 8 TESTS 43 748 58572800
130734827 pras7946 C Oct. 3, 2021, 7:12 p.m. OK Java 8 TESTS 42 795 42598400
130758003 smahajan54842 C Oct. 4, 2021, 4:50 a.m. OK Java 8 TESTS 45 810 65433600
130738089 Restricted C Oct. 3, 2021, 8:11 p.m. OK Java 8 TESTS 43 811 62156800
130748124 koboshi C Oct. 4, 2021, 1:52 a.m. OK Kotlin 1.4 TESTS 45 499 41472000
130727785 procrastinate7 C Oct. 3, 2021, 5:40 p.m. OK Kotlin 1.5 TESTS 42 873 49766400
130727601 ILMS C Oct. 3, 2021, 5:38 p.m. OK MS C++ 2017 TESTS 42 499 11878400
130719981 BusIgor C Oct. 3, 2021, 4:28 p.m. OK MS C++ 2017 TESTS 39 561 7884800
130719776 theweird C Oct. 3, 2021, 4:28 p.m. OK MS C++ 2017 TESTS 39 561 9625600
130728156 Tangerine C Oct. 3, 2021, 5:43 p.m. OK MS C++ 2017 TESTS 42 576 11264000
130715784 Flyheck C Oct. 3, 2021, 4:16 p.m. OK MS C++ 2017 TESTS 39 576 11264000
130724383 KanishkGoel C Oct. 3, 2021, 5:08 p.m. OK PyPy 3 TESTS 39 420 49356800
130724102 oadey89 C Oct. 3, 2021, 5:07 p.m. OK PyPy 3 TESTS 39 530 48640000
130716822 brthyyjp C Oct. 3, 2021, 4:19 p.m. OK PyPy 3 TESTS 39 577 52224000
130742878 beethoven97 C Oct. 3, 2021, 10:16 p.m. OK PyPy 3 TESTS 43 717 58368000
130742791 beethoven97 C Oct. 3, 2021, 10:14 p.m. OK PyPy 3 TESTS 43 764 48844800
130724931 akshitm16 C Oct. 3, 2021, 5:11 p.m. OK PyPy 3 TESTS 40 810 53043200
130716837 not_akshitm16 C Oct. 3, 2021, 4:19 p.m. OK PyPy 3 TESTS 39 810 53043200
130728620 huikang C Oct. 3, 2021, 5:48 p.m. OK PyPy 3 TESTS 42 841 80281600
130726170 innocent_SINNER C Oct. 3, 2021, 5:26 p.m. OK PyPy 3 TESTS 40 841 184832000
130725255 giant-mammoth C Oct. 3, 2021, 5:13 p.m. OK PyPy 3 TESTS 40 904 58675200
130733065 r57shell C Oct. 3, 2021, 6:44 p.m. OK Python 3 TESTS 42 904 21606400
130732970 tcltk C Oct. 3, 2021, 6:42 p.m. OK Python 3 TESTS 42 982 140595200
130731942 kumalimak C Oct. 3, 2021, 6:28 p.m. OK Rust TESTS 42 156 11776000

remove filters

Back to search problems