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 |
---|---|---|---|---|---|---|
1844 | Codeforces Round 884 (Div. 1 + Div. 2) | FINISHED | False | 10800 | 48180263 | July 11, 2023, 2:35 p.m. |
Solved$ |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
---|---|---|---|---|---|---|
( 860 ) | G | Tree Weights | PROGRAMMING | bitmasks constructive algorithms data structures dfs and similar math matrices number theory trees |
B'You are given a tree with n nodes labelled 1,2, ... ,n . The i -th edge connects nodes u_i and v_i and has an unknown positive integer weight w_i . To help you figure out these weights, you are also given the distance d_i between the nodes i and i+1 for all 1 <= i <= n-1 (the sum of the weights of the edges on the simple path between the nodes i and i+1 in the tree). Find the weight of each edge. If there are multiple solutions, print any of them. If there are no weights w_i consistent with the information, print a single integer -1 . The first line contains a single integer n ( 2 <= n <= 10^5 ). The i -th of the next n-1 lines contains two integers u_i and v_i ( 1 <= u_i,v_i <= n , u_i ne v_i ). The last line contains n-1 integers d_1, ... ,d_{n-1} ( 1 <= d_i <= 10^{12} ). It is guaranteed that the given edges form a tree. If there is no solution, print a single integer -1 . Otherwise, output n-1 lines containing the weights w_1, ... ,w_{n-1} . If there are multiple solutions, print any of them. In the first sample, the tree is as follows: In the second sample, note that w_2 is not allowed to be 0 because it must be a positive integer, so there is no solution. In the third sample, the tree is as follows: '... |
Codeforces Round #884 (Div. 1 + Div. 2) Editorial |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
---|---|---|---|---|---|---|---|---|---|---|---|
213424721 | rainboy | G | July 11, 2023, 9:32 p.m. | OK | GNU C11 | TESTS | 72 | 748 | 13824000 | ||
213452097 | Starch | G | July 12, 2023, 4:44 a.m. | OK | GNU C++14 | TESTS | 72 | 234 | 23449600 | ||
213446940 | cyh_toby | G | July 12, 2023, 3:22 a.m. | OK | GNU C++14 | TESTS | 72 | 249 | 18944000 | ||
213449958 | wa_233 | G | July 12, 2023, 4:07 a.m. | OK | GNU C++14 | TESTS | 72 | 249 | 22835200 | ||
213447089 | Suwan | G | July 12, 2023, 3:23 a.m. | OK | GNU C++14 | TESTS | 72 | 265 | 24576000 | ||
213453588 | Scintilla06 | G | July 12, 2023, 5:08 a.m. | OK | GNU C++14 | TESTS | 72 | 358 | 20582400 | ||
213449276 | huzhaoyang | G | July 12, 2023, 3:56 a.m. | OK | GNU C++14 | TESTS | 72 | 405 | 20582400 | ||
213453892 | 0wuming0 | G | July 12, 2023, 5:13 a.m. | OK | GNU C++14 | TESTS | 72 | 4851 | 44646400 | ||
213406322 | TadijaSebez | G | July 11, 2023, 6:13 p.m. | OK | GNU C++17 | TESTS | 72 | 296 | 17715200 | ||
213421548 | abhishek6487209 | G | July 11, 2023, 8:45 p.m. | OK | GNU C++17 | TESTS | 72 | 296 | 19865600 | ||
213431278 | -kirito- | G | July 11, 2023, 11:48 p.m. | OK | GNU C++17 | TESTS | 72 | 358 | 82534400 | ||
213444908 | yan.silva | G | July 12, 2023, 2:52 a.m. | OK | GNU C++17 | TESTS | 72 | 514 | 20582400 | ||
213428547 | Dominater069 | G | July 11, 2023, 10:46 p.m. | OK | GNU C++17 | TESTS | 72 | 514 | 33996800 | ||
213397781 | misaka18931 | G | July 11, 2023, 5:20 p.m. | OK | GNU C++17 | TESTS | 72 | 607 | 20684800 | ||
213396107 | US3RN4M3 | G | July 11, 2023, 5:15 p.m. | OK | GNU C++17 | TESTS | 72 | 1559 | 23449600 | ||
213428436 | Dominater069 | G | July 11, 2023, 10:44 p.m. | OK | GNU C++17 | TESTS | 72 | 4555 | 33280000 | ||
213449342 | Alex_Wei | G | July 12, 2023, 3:57 a.m. | OK | GNU C++17 (64) | TESTS | 72 | 124 | 29491200 | ||
213414952 | lunchbox | G | July 11, 2023, 7:27 p.m. | OK | GNU C++17 (64) | TESTS | 72 | 171 | 24576000 | ||
213414357 | PurpleCrayon | G | July 11, 2023, 7:20 p.m. | OK | GNU C++17 (64) | TESTS | 72 | 202 | 24064000 | ||
213443469 | wsyear | G | July 12, 2023, 2:37 a.m. | OK | GNU C++17 (64) | TESTS | 72 | 311 | 21606400 | ||
213455067 | stan23456 | G | July 12, 2023, 5:32 a.m. | OK | GNU C++17 (64) | TESTS | 72 | 327 | 42291200 | ||
213418393 | neal | G | July 11, 2023, 8:07 p.m. | OK | GNU C++17 (64) | TESTS | 72 | 374 | 37478400 | ||
213445752 | SpadeA261 | G | July 12, 2023, 3:04 a.m. | OK | GNU C++17 (64) | TESTS | 72 | 389 | 22835200 | ||
213446388 | SpadeA261 | G | July 12, 2023, 3:14 a.m. | OK | GNU C++17 (64) | TESTS | 72 | 390 | 22835200 | ||
213405707 | icecuber | G | July 11, 2023, 6:10 p.m. | OK | GNU C++17 (64) | TESTS | 72 | 405 | 30924800 | ||
213438071 | xiaoziyao | G | July 12, 2023, 1:32 a.m. | OK | GNU C++17 (64) | TESTS | 72 | 436 | 23244800 | ||
213456060 | xnor | G | July 12, 2023, 5:47 a.m. | OK | GNU C++20 (64) | TESTS | 72 | 186 | 38400000 | ||
213446804 | CrTsIr | G | July 12, 2023, 3:20 a.m. | OK | GNU C++20 (64) | TESTS | 72 | 187 | 23654400 | ||
213405763 | brunovsky | G | July 11, 2023, 6:10 p.m. | OK | GNU C++20 (64) | TESTS | 72 | 202 | 32153600 | ||
213456376 | xnor | G | July 12, 2023, 5:52 a.m. | OK | GNU C++20 (64) | TESTS | 72 | 202 | 38400000 | ||
213395667 | Ormlis | G | July 11, 2023, 5:13 p.m. | OK | GNU C++20 (64) | TESTS | 72 | 218 | 27545600 | ||
213456109 | xnor | G | July 12, 2023, 5:48 a.m. | OK | GNU C++20 (64) | TESTS | 72 | 233 | 38400000 | ||
213418855 | Arnab_11 | G | July 11, 2023, 8:12 p.m. | OK | GNU C++20 (64) | TESTS | 72 | 296 | 32665600 | ||
213452168 | karrigan0108 | G | July 12, 2023, 4:45 a.m. | OK | GNU C++20 (64) | TESTS | 72 | 312 | 24883200 | ||
213451236 | karrigan0108 | G | July 12, 2023, 4:31 a.m. | OK | GNU C++20 (64) | TESTS | 72 | 312 | 24883200 | ||
213449662 | Tobo | G | July 12, 2023, 4:02 a.m. | OK | GNU C++20 (64) | TESTS | 72 | 327 | 29388800 |
Back to search problems