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 |
|---|---|---|---|---|---|---|
| 2042 | Educational Codeforces Round 172 (Rated for Div. 2) | FINISHED | False | 7200 | 43255523 | Dec. 2, 2024, 2:35 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 520 ) | E | Vertex Pairs | PROGRAMMING | binary search brute force dfs and similar dp greedy trees |
You are given a tree consisting of (2n) vertices. Recall that a tree is a connected undirected graph with no cycles. Each vertex has an integer from (1) to (n) written on it. Each value from (1) to (n) is written on exactly two different vertices. Each vertex also has a cost —vertex (i) costs (2^i). You need to choose a subset of vertices of the tree such that: the subset is connected; that is, from each vertex in the subset, you can reach every other vertex in the subset by passing only through the vertices in the subset; each value from (1) to (n) is written on at least one vertex in the subset. Among all such subsets, you need to find the one with the smallest total cost of the vertices in it. Note that you are not required to minimize the number of vertices in the subset. The first line contains a single integer (n) ((1 \le n \le 2 \cdot 10^5)). The second line contains (2n) integers (a_1, a_2, \dots, a_{2n}) ((1 \le a_i \le n)). Each value from (1) to (n) appears exactly twice. Each of the next (2n-1) lines contains two integers (v) and (u) ((1 \le v, u \le 2n)) — the edges of the tree. These edges form a valid tree. In the first line, print a single integer (k) — the number of vertices in the subset. In the second line, print (k) distinct integers from (1) to (2n) — the indices of the vertices in the chosen subset. The vertices can be printed in an arbitrary order. The images show the answers to the first two examples. The numbers in parentheses are the values written on the vertices. In the first example, there are valid subsets such as: (2, 4, 5) (with a cost of (2^2 + 2^4 + 2^5 = 52)), (2, 4, 5, 6) (with a cost of (116)), (1, 6, 3) (with a cost of (74)), (2, 6, 3) (with a cost of (76)), and many others. In the second example, the cost of the subset (4, 6, 3, 1) is (90). |
| 136886 |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 294525012 | zqyyy | E | Dec. 3, 2024, 4:59 a.m. | OK | C++17 (GCC 7-32) | TESTS | 43 | 1203 | 70963200 | ||
| 294490126 | Heart_Blue | E | Dec. 2, 2024, 7:10 p.m. | OK | C++17 (GCC 7-32) | TESTS | 41 | 1217 | 50995200 | ||
| 294455995 | licn090605 | E | Dec. 2, 2024, 4:32 p.m. | OK | C++17 (GCC 7-32) | TESTS | 41 | 1359 | 116940800 | ||
| 294506157 | kyuukyuusha | E | Dec. 2, 2024, 10:35 p.m. | OK | C++17 (GCC 7-32) | TESTS | 41 | 1483 | 82534400 | ||
| 294469535 | IsaacMoris | E | Dec. 2, 2024, 4:42 p.m. | OK | C++17 (GCC 7-32) | TESTS | 41 | 1515 | 75161600 | ||
| 294455706 | IsaacMoris | E | Dec. 2, 2024, 4:32 p.m. | OK | C++17 (GCC 7-32) | TESTS | 41 | 1624 | 74854400 | ||
| 294462348 | vinakaa | E | Dec. 2, 2024, 4:34 p.m. | OK | C++17 (GCC 7-32) | TESTS | 41 | 1655 | 111308800 | ||
| 294517647 | qwe1rt1yuiop1 | E | Dec. 3, 2024, 3:08 a.m. | OK | C++17 (GCC 7-32) | TESTS | 41 | 1843 | 83046400 | ||
| 294493732 | gabriel88766 | E | Dec. 2, 2024, 7:45 p.m. | OK | C++17 (GCC 7-32) | TESTS | 41 | 1858 | 106700800 | ||
| 294478226 | liympanda | E | Dec. 2, 2024, 5:39 p.m. | OK | C++17 (GCC 7-32) | TESTS | 41 | 1905 | 69529600 | ||
| 294527834 | T404 | E | Dec. 3, 2024, 5:37 a.m. | OK | C++20 (GCC 13-64) | TESTS | 43 | 593 | 66150400 | ||
| 294525159 | T404 | E | Dec. 3, 2024, 5:01 a.m. | OK | C++20 (GCC 13-64) | TESTS | 43 | 749 | 82227200 | ||
| 294444794 | sha7dow | E | Dec. 2, 2024, 4:15 p.m. | OK | C++20 (GCC 13-64) | TESTS | 41 | 827 | 80896000 | ||
| 294525826 | sztcodeforces | E | Dec. 3, 2024, 5:10 a.m. | OK | C++20 (GCC 13-64) | TESTS | 43 | 828 | 80384000 | ||
| 294448465 | sha7dow | E | Dec. 2, 2024, 4:22 p.m. | OK | C++20 (GCC 13-64) | TESTS | 41 | 842 | 86528000 | ||
| 294518364 | Kitty-Milk | E | Dec. 3, 2024, 3:21 a.m. | OK | C++20 (GCC 13-64) | TESTS | 41 | 842 | 201420800 | ||
| 294470523 | YocyCraft | E | Dec. 2, 2024, 4:48 p.m. | OK | C++20 (GCC 13-64) | TESTS | 41 | 905 | 73523200 | ||
| 294454894 | Porumb | E | Dec. 2, 2024, 4:29 p.m. | OK | C++20 (GCC 13-64) | TESTS | 41 | 952 | 42598400 | ||
| 294474499 | include_BM | E | Dec. 2, 2024, 5:14 p.m. | OK | C++20 (GCC 13-64) | TESTS | 41 | 1155 | 110899200 | ||
| 294475429 | wprqxr | E | Dec. 2, 2024, 5:20 p.m. | OK | C++20 (GCC 13-64) | TESTS | 41 | 1249 | 91545600 | ||
| 294517842 | hcywoi | E | Dec. 3, 2024, 3:12 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 41 | 984 | 71475200 | ||
| 294509078 | rainboy | E | Dec. 3, 2024, 12:04 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 41 | 1046 | 50995200 | ||
| 294469471 | Normalizerr | E | Dec. 2, 2024, 4:42 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 41 | 1062 | 69836800 | ||
| 294516290 | SussykinWantsNatalia | E | Dec. 3, 2024, 2:43 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 41 | 1155 | 98508800 | ||
| 294509868 | peti1234 | E | Dec. 3, 2024, 12:17 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 41 | 1171 | 95129600 | ||
| 294509844 | peti1234 | E | Dec. 3, 2024, 12:16 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 41 | 1233 | 99123200 | ||
| 294521238 | K-423 | E | Dec. 3, 2024, 4:02 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 41 | 1265 | 97894400 | ||
| 294523605 | HUST_USELESS | E | Dec. 3, 2024, 4:40 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 43 | 1421 | 162508800 | ||
| 294452832 | Farhod | E | Dec. 2, 2024, 4:23 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 41 | 1500 | 103628800 | ||
| 294517613 | Alwoosh | E | Dec. 3, 2024, 3:07 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 41 | 1546 | 257024000 | ||
| 294508574 | rainboy | E | Dec. 2, 2024, 11:45 p.m. | OK | GNU C11 | TESTS | 41 | 1984 | 40755200 | ||
| 294473805 | nguyenquocthao00 | E | Dec. 2, 2024, 5:09 p.m. | OK | Go | TESTS | 41 | 1734 | 423116800 | ||
| 294474028 | nguyenquocthao00 | E | Dec. 2, 2024, 5:11 p.m. | OK | Go | TESTS | 41 | 1843 | 456806400 | ||
| 294502058 | -dub-otrezkov- | E | Dec. 2, 2024, 9:30 p.m. | OK | Go | TESTS | 41 | 2984 | 211763200 | ||
| 294502170 | -dub-otrezkov- | E | Dec. 2, 2024, 9:32 p.m. | OK | Go | TESTS | 41 | 2999 | 217600000 | ||
| 294448006 | arvindf232 | E | Dec. 2, 2024, 4:22 p.m. | OK | Kotlin 1.9 | TESTS | 41 | 2484 | 274432000 | ||
| 294526180 | Little_Sheep_Yawn | E | Dec. 3, 2024, 5:15 a.m. | OK | PyPy 3-64 | TESTS | 43 | 2202 | 134860800 | ||
| 294520730 | Little_Sheep_Yawn | E | Dec. 3, 2024, 3:53 a.m. | OK | PyPy 3-64 | TESTS | 41 | 2218 | 134758400 |
Back to search problems