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 |
---|---|---|---|---|---|---|
1889 | Codeforces Round 906 (Div. 1) | FINISHED | False | 9000 | 38676263 | Oct. 28, 2023, 2:35 p.m. |
Solved$ |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
---|---|---|---|---|---|---|
( 86 ) | F | Doremy's Average Tree | PROGRAMMING | dp trees |
B'Doremy has a rooted tree of size n whose root is vertex r . Initially there is a number w_i written on vertex i . Doremy can use her power to perform this operation at most k times: Doremy wants to know what is the lexicographically smallest ^ dagger array w after performing all the operations. Can you help her? If there are multiple answers, you may output any one. ^ dagger For arrays a and b both of length n , a is lexicographically smaller than b if and only if there exist an index i ( 1 <= q i <= n ) such that a_i < b_i and for all indices j such that j<i , a_j=b_j is satisfied. The input consists of multiple test cases. The first line contains a single integer t ( 1 <= t <= 10^4 ) -- the number of test cases. The description of the test cases follows. The first line contains three integers n , r , k ( 2 <= n <= 5000 , 1 <= r <= n , 0 <= k <= min(500,n) ). The second line contains n integers w_1,w_2, ldots,w_n ( 1 <= w_i <= 10^6 ). Each of the next n-1 lines contains two integers u_i , v_i ( 1 <= q u_i, v_i <= q n ), representing an edge between u_i and v_i . It is guaranteed that the given edges form a tree. It is guaranteed that the sum of n does not exceed 50 ,000 . For each test case, In the first line, output a single integer cnt ( 0 <= cnt <= k ) -- the number of operations you perform. Then, in the second line output cnt integers p_1,p_2, ldots,p_{cnt} -- x is chosen to be p_i for i -th operation. If there are multiple answers, you may output any one. In the first test case: At first w=[1,9,2,6,1,8] . You can choose some vertex x to perform at most one operation. w is lexicographically smallest when x=2 . '... |
Codeforces Round 906 Editorial |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
---|---|---|---|---|---|---|---|---|---|---|---|
230289427 | rainboy | F | Oct. 28, 2023, 9:04 p.m. | OK | GNU C11 | TESTS | 116 | 1309 | 261734400 | ||
230286542 | Benq | F | Oct. 28, 2023, 8:26 p.m. | OK | GNU C++20 (64) | TESTS | 116 | 1310 | 74649600 | ||
230266065 | Petr | F | Oct. 28, 2023, 5:37 p.m. | OK | GNU C++20 (64) | TESTS | 116 | 2683 | 819200 | ||
230293665 | chappy1 | F | Oct. 28, 2023, 10:20 p.m. | OK | GNU C++20 (64) | TESTS | 116 | 2714 | 819200 | ||
230262442 | Petr | F | Oct. 28, 2023, 5:03 p.m. | OK | GNU C++20 (64) | TESTS | 116 | 2792 | 819200 | ||
230300931 | nguyenquocthinhhung | F | Oct. 29, 2023, 2:09 a.m. | OK | GNU C++20 (64) | TESTS | 116 | 2808 | 819200 |
Back to search problems