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 |
|---|---|---|---|---|---|---|
| 843 | AIM Tech Round 4 (Div. 1) | FINISHED | False | 9000 | 272813123 | Aug. 24, 2017, 4:35 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 407 ) | C | Upgrading Tree | PROGRAMMING | constructive algorithms dfs and similar graphs math trees | 2900 |
You are given a tree with n vertices and you are allowed to perform no more than 2 n transformations on it. Transformation is defined by three vertices x , y , y ' and consists of deleting edge ( x , y ) and adding edge ( x , y ') . Transformation x , y , y ' could be performed if all the following conditions are satisfied: There is an edge ( x , y ) in the current tree. After the transformation the graph remains a tree. After the deletion of edge ( x , y ) the tree would consist of two connected components. Let's denote the set of nodes in the component containing vertex x by V x , and the set of nodes in the component containing vertex y by V y . Then condition | V x | > | V y | should be satisfied, i.e. the size of the component with x should be strictly larger than the size of the component with y . You should minimize the sum of squared distances between all pairs of vertices in a tree, which you could get after no more than 2 n transformations and output any sequence of transformations leading initial tree to such state. Note that you don't need to minimize the number of operations. It is necessary to minimize only the sum of the squared distances. The first line of input contains integer n ( 1 ≤ n ≤ 2·10 5 ) — number of vertices in tree. The next n - 1 lines of input contains integers a and b ( 1 ≤ a , b ≤ n , a ≠ b ) — the descriptions of edges. It is guaranteed that the given edges form a tree. In the first line output integer k ( 0 ≤ k ≤ 2 n ) — the number of transformations from your example, minimizing sum of squared distances between all pairs of vertices. In each of the next k lines output three integers x , y , y ' — indices of vertices from the corresponding transformation. Transformations with y = y ' are allowed (even though they don't change tree) if transformation conditions are satisfied. If there are several possible answers, print any of them. This is a picture for the second sample. Added edges are dark, deleted edges are dotted. |
| AIM Tech Round 4 -- Editorial |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 29747663 | yosupo | C | Aug. 24, 2017, 5:30 p.m. | OK | D | TESTS | 112 | 764 | 36454400 | 2900 | |
| 42294451 | Scut82 | C | Aug. 31, 2018, 1:30 a.m. | OK | GNU C++ | TESTS | 112 | 187 | 22016000 | 2900 | |
| 42348197 | Scut82 | C | Sept. 2, 2018, 1:11 a.m. | OK | GNU C++ | TESTS | 112 | 202 | 22425600 | 2900 | |
| 29946509 | vjudge3 | C | Aug. 31, 2017, 2:02 p.m. | OK | GNU C++ | TESTS | 112 | 280 | 17612800 | 2900 | |
| 29946490 | TGSteven | C | Aug. 31, 2017, 2:01 p.m. | OK | GNU C++ | TESTS | 112 | 295 | 17612800 | 2900 | |
| 29773598 | Cydiater | C | Aug. 25, 2017, 8:24 a.m. | OK | GNU C++ | TESTS | 112 | 296 | 16793600 | 2900 | |
| 29774018 | FoolMike | C | Aug. 25, 2017, 8:43 a.m. | OK | GNU C++ | TESTS | 112 | 296 | 50688000 | 2900 | |
| 30902642 | iamz | C | Oct. 1, 2017, 8:04 a.m. | OK | GNU C++ | TESTS | 112 | 311 | 16793600 | 2900 | |
| 29776880 | zx2003 | C | Aug. 25, 2017, 10:50 a.m. | OK | GNU C++ | TESTS | 112 | 311 | 18227200 | 2900 | |
| 29940801 | Feeey | C | Aug. 31, 2017, 11:18 a.m. | OK | GNU C++ | TESTS | 112 | 311 | 25395200 | 2900 | |
| 29868925 | xht13127 | C | Aug. 29, 2017, 2:59 p.m. | OK | GNU C++ | TESTS | 112 | 326 | 31641600 | 2900 | |
| 40980203 | ReaLNero1 | C | July 30, 2018, 5:25 p.m. | OK | GNU C++11 | TESTS | 112 | 155 | 30924800 | 2900 | |
| 37138155 | yasugongshang | C | April 10, 2018, 7:32 a.m. | OK | GNU C++11 | TESTS | 112 | 155 | 34406400 | 2900 | |
| 37138173 | yasugongshang | C | April 10, 2018, 7:33 a.m. | OK | GNU C++11 | TESTS | 112 | 155 | 34508800 | 2900 | |
| 37138112 | yasugongshang | C | April 10, 2018, 7:29 a.m. | OK | GNU C++11 | TESTS | 112 | 156 | 23552000 | 2900 | |
| 37138130 | yasugongshang | C | April 10, 2018, 7:30 a.m. | OK | GNU C++11 | TESTS | 112 | 187 | 23552000 | 2900 | |
| 42348287 | Scut82 | C | Sept. 2, 2018, 1:23 a.m. | OK | GNU C++11 | TESTS | 112 | 218 | 26521600 | 2900 | |
| 30531838 | King_George | C | Sept. 20, 2017, 1:04 a.m. | OK | GNU C++11 | TESTS | 112 | 265 | 92160000 | 2900 | |
| 34189739 | zhouyuyang | C | Jan. 15, 2018, 6:15 a.m. | OK | GNU C++11 | TESTS | 112 | 280 | 21299200 | 2900 | |
| 37138211 | yasugongshang | C | April 10, 2018, 7:35 a.m. | OK | GNU C++11 | TESTS | 112 | 280 | 23654400 | 2900 | |
| 29747700 | FizzyDavid | C | Aug. 24, 2017, 5:31 p.m. | OK | GNU C++11 | TESTS | 112 | 280 | 25600000 | 2900 | |
| 29778221 | Egor.Lifar | C | Aug. 25, 2017, 11:55 a.m. | OK | GNU C++14 | TESTS | 112 | 202 | 23654400 | 2900 | |
| 34650709 | LiChenKoh | C | Jan. 29, 2018, 5:34 a.m. | OK | GNU C++14 | TESTS | 112 | 312 | 23961600 | 2900 | |
| 29868496 | survivorone | C | Aug. 29, 2017, 2:37 p.m. | OK | GNU C++14 | TESTS | 112 | 312 | 27340800 | 2900 | |
| 29868447 | vjudge1 | C | Aug. 29, 2017, 2:34 p.m. | OK | GNU C++14 | TESTS | 112 | 326 | 27340800 | 2900 | |
| 30497629 | The_Unbeatable | C | Sept. 19, 2017, 12:43 p.m. | OK | GNU C++14 | TESTS | 112 | 343 | 17510400 | 2900 | |
| 29757976 | majk | C | Aug. 24, 2017, 6:51 p.m. | OK | GNU C++14 | TESTS | 112 | 358 | 20172800 | 2900 | |
| 30655910 | bzh | C | Sept. 24, 2017, 3:07 a.m. | OK | GNU C++14 | TESTS | 112 | 358 | 22835200 | 2900 | |
| 30260858 | pb0207 | C | Sept. 11, 2017, 7:34 a.m. | OK | GNU C++14 | TESTS | 112 | 374 | 23859200 | 2900 | |
| 29747541 | V--o_o--V | C | Aug. 24, 2017, 5:30 p.m. | OK | GNU C++14 | TESTS | 112 | 374 | 25088000 | 2900 | |
| 29778096 | please_delete_account | C | Aug. 25, 2017, 11:49 a.m. | OK | GNU C++14 | TESTS | 112 | 374 | 27033600 | 2900 | |
| 62545591 | Polygon-yg | C | Oct. 14, 2019, 6:17 a.m. | OK | GNU C++17 | TESTS | 112 | 296 | 21606400 | 2900 | |
| 48660239 | desert97 | C | Jan. 21, 2019, 5:41 a.m. | OK | GNU C++17 | TESTS | 112 | 374 | 34406400 | 2900 | |
| 67481133 | Arpa | C | Dec. 23, 2019, 4 p.m. | OK | GNU C++17 | TESTS | 112 | 389 | 27648000 | 2900 | |
| 55500036 | hjk1030 | C | June 12, 2019, 2:36 p.m. | OK | GNU C++17 | TESTS | 112 | 389 | 34713600 | 2900 | |
| 39953533 | Ali_Pi | C | July 4, 2018, 11:43 a.m. | OK | GNU C++17 | TESTS | 112 | 405 | 16998400 | 2900 | |
| 67684840 | justfocusplease | C | Dec. 27, 2019, 8:23 a.m. | OK | GNU C++17 | TESTS | 112 | 420 | 30208000 | 2900 | |
| 46054821 | chielo | C | Nov. 22, 2018, 10:16 a.m. | OK | GNU C++17 | TESTS | 112 | 592 | 36966400 | 2900 | |
| 46542354 | Shayan.P | C | Dec. 3, 2018, 12:41 p.m. | OK | GNU C++17 | TESTS | 112 | 748 | 32972800 | 2900 | |
| 29780006 | jufusong | C | Aug. 25, 2017, 12:55 p.m. | OK | Java 8 | TESTS | 112 | 998 | 133120000 | 2900 | |
| 29757267 | mmaxio | C | Aug. 24, 2017, 6:44 p.m. | OK | Java 8 | TESTS | 112 | 1091 | 80691200 | 2900 | |
| 29769044 | uwi | C | Aug. 25, 2017, 5:26 a.m. | OK | Java 8 | TESTS | 112 | 1138 | 117248000 | 2900 | |
| 34620636 | happybelly | C | Jan. 28, 2018, 1:21 a.m. | OK | Java 8 | TESTS | 112 | 2995 | 160256000 | 2900 | |
| 34570512 | happybelly | C | Jan. 26, 2018, 9:01 a.m. | OK | Java 8 | TESTS | 112 | 3026 | 126566400 | 2900 | |
| 29791891 | Sergey.Bankevich | C | Aug. 25, 2017, 8:29 p.m. | OK | Kotlin | TESTS | 112 | 1528 | 150937600 | 2900 | |
| 29803257 | leign | C | Aug. 26, 2017, 10:04 a.m. | OK | Mono C# | TESTS | 112 | 764 | 53350400 | 2900 | |
| 29755837 | Perforator | C | Aug. 24, 2017, 6:32 p.m. | OK | MS C++ | TESTS | 112 | 452 | 22220800 | 2900 | |
| 29756089 | Taube | C | Aug. 24, 2017, 6:34 p.m. | OK | MS C++ | TESTS | 112 | 514 | 25907200 | 2900 |
Back to search problems