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.
Problems
B'You are given a tree with n nodes. You have to write non-negative integers on its edges so that the following condition would be satisfied: For every two nodes i , j , look at the path between them and count the sum of numbers on the edges of this path. Write all obtained sums on the blackboard. Then every integer from 1 to lfloor frac{2n^2}{9} rfloor has to be written on the blackboard at least once. It is guaranteed that such an arrangement exists. The first line contains a single integer n ( 1 <= n <= 1000 ) -- the number of nodes. Each of the next n-1 lines contains two integers u and v ( 1 <= u, v <= n , u neq v ), meaning that there is an edge between nodes u and v . It is guaranteed that these edges form a tree. Output n-1 lines, each of form u v x ( 0 <= x <= 10^6 ), which will mean that you wrote number x on the edge between u , v . Set of edges (u, v) has to coincide with the set of edges of the input graph, but you can output edges in any order. You can also output ends of edges in an order different from the order in input. In the first example, distance between nodes 1 and 2 is equal to 2 , between nodes 2 and 3 to 1 , between 1 and 3 to 3 . In the third example, numbers from 1 to 9 (inclusive) will be written on the blackboard, while we need just from 1 to 5 to pass the test. '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
59036700 |
panole |
D |
Aug. 18, 2019, 3:15 p.m. |
OK |
GNU C++11 |
TESTS |
37 |
30 |
8192000 |
|
2800 |
62086423 |
RNS_JKS |
D |
Oct. 8, 2019, 2:22 a.m. |
OK |
GNU C++11 |
TESTS |
37 |
31 |
0 |
|
2800 |
60932084 |
CaptainSlow |
D |
Sept. 20, 2019, 2:05 p.m. |
OK |
GNU C++11 |
TESTS |
37 |
31 |
0 |
|
2800 |
59899550 |
no_one_qwq |
D |
Sept. 2, 2019, 1:13 p.m. |
OK |
GNU C++11 |
TESTS |
37 |
31 |
0 |
|
2800 |
59845040 |
Knight_23 |
D |
Sept. 1, 2019, 9:04 a.m. |
OK |
GNU C++11 |
TESTS |
37 |
31 |
0 |
|
2800 |
59341958 |
luogu_bot1 |
D |
Aug. 23, 2019, 7:55 a.m. |
OK |
GNU C++11 |
TESTS |
37 |
31 |
0 |
|
2800 |
59335005 |
LJC00118 |
D |
Aug. 23, 2019, 4:04 a.m. |
OK |
GNU C++11 |
TESTS |
37 |
31 |
0 |
|
2800 |
59274012 |
sxd666 |
D |
Aug. 22, 2019, 1:50 p.m. |
OK |
GNU C++11 |
TESTS |
37 |
31 |
0 |
|
2800 |
61536237 |
yyf0309 |
D |
Sept. 30, 2019, 6:31 a.m. |
OK |
GNU C++11 |
TESTS |
37 |
31 |
0 |
|
2800 |
59272190 |
cjy2003 |
D |
Aug. 22, 2019, 1:09 p.m. |
OK |
GNU C++11 |
TESTS |
37 |
31 |
0 |
|
2800 |
59124649 |
Itst |
D |
Aug. 20, 2019, 8:05 a.m. |
OK |
GNU C++14 |
TESTS |
37 |
15 |
204800 |
|
2800 |
59132526 |
Itst |
D |
Aug. 20, 2019, 11:32 a.m. |
OK |
GNU C++14 |
TESTS |
37 |
15 |
204800 |
|
2800 |
60203954 |
_DYT |
D |
Sept. 7, 2019, 7:19 a.m. |
OK |
GNU C++14 |
TESTS |
37 |
30 |
0 |
|
2800 |
59810567 |
Zoli9 |
D |
Aug. 31, 2019, 1:27 p.m. |
OK |
GNU C++14 |
TESTS |
37 |
30 |
204800 |
|
2800 |
59650254 |
Cyanic |
D |
Aug. 29, 2019, 7:54 a.m. |
OK |
GNU C++14 |
TESTS |
37 |
30 |
204800 |
|
2800 |
59259235 |
Origenes |
D |
Aug. 22, 2019, 7:54 a.m. |
OK |
GNU C++14 |
TESTS |
37 |
30 |
204800 |
|
2800 |
59113702 |
Motarack |
D |
Aug. 19, 2019, 11:29 p.m. |
OK |
GNU C++14 |
TESTS |
37 |
30 |
204800 |
|
2800 |
64104351 |
faculty |
D |
Nov. 2, 2019, 4:03 p.m. |
OK |
GNU C++14 |
TESTS |
37 |
30 |
307200 |
|
2800 |
63385677 |
rterte |
D |
Oct. 25, 2019, 1:42 p.m. |
OK |
GNU C++14 |
TESTS |
37 |
30 |
307200 |
|
2800 |
59662986 |
ImpcO |
D |
Aug. 29, 2019, 1:11 p.m. |
OK |
GNU C++14 |
TESTS |
37 |
30 |
307200 |
|
2800 |
62905142 |
eidan |
D |
Oct. 19, 2019, 5:35 a.m. |
OK |
GNU C++17 |
TESTS |
37 |
15 |
204800 |
|
2800 |
59048078 |
LayCurse |
D |
Aug. 18, 2019, 4:40 p.m. |
OK |
GNU C++17 |
TESTS |
37 |
15 |
96256000 |
|
2800 |
60833874 |
Fulisike |
D |
Sept. 19, 2019, 8:10 a.m. |
OK |
GNU C++17 |
TESTS |
37 |
30 |
102400 |
|
2800 |
59100394 |
lqs2015 |
D |
Aug. 19, 2019, 3:50 p.m. |
OK |
GNU C++17 |
TESTS |
37 |
30 |
204800 |
|
2800 |
61403083 |
HNO2 |
D |
Sept. 28, 2019, 6:02 a.m. |
OK |
GNU C++17 |
TESTS |
37 |
30 |
204800 |
|
2800 |
61381348 |
bomo |
D |
Sept. 27, 2019, 5:35 p.m. |
OK |
GNU C++17 |
TESTS |
37 |
30 |
204800 |
|
2800 |
60189111 |
bmerry |
D |
Sept. 6, 2019, 8:09 p.m. |
OK |
GNU C++17 |
TESTS |
37 |
30 |
204800 |
|
2800 |
59687574 |
SleepZzz |
D |
Aug. 30, 2019, 3:04 a.m. |
OK |
GNU C++17 |
TESTS |
37 |
30 |
204800 |
|
2800 |
59136493 |
tirlimster |
D |
Aug. 20, 2019, 12:51 p.m. |
OK |
GNU C++17 |
TESTS |
37 |
30 |
204800 |
|
2800 |
59091255 |
hitonanode |
D |
Aug. 19, 2019, 12:49 p.m. |
OK |
GNU C++17 |
TESTS |
37 |
30 |
204800 |
|
2800 |
59037091 |
qwerty787788 |
D |
Aug. 18, 2019, 3:16 p.m. |
OK |
Java 8 |
TESTS |
37 |
139 |
0 |
|
2800 |
59074339 |
dalt |
D |
Aug. 19, 2019, 6:27 a.m. |
OK |
Java 8 |
TESTS |
37 |
156 |
0 |
|
2800 |
59063323 |
Darth_Jar_Jar_Binks |
D |
Aug. 19, 2019, 12:06 a.m. |
OK |
Java 8 |
TESTS |
37 |
156 |
0 |
|
2800 |
59266721 |
IgorSmirnov |
D |
Aug. 22, 2019, 11:05 a.m. |
OK |
Kotlin |
TESTS |
37 |
171 |
204800 |
|
2800 |
59266651 |
IgorSmirnov |
D |
Aug. 22, 2019, 11:03 a.m. |
OK |
Kotlin |
TESTS |
37 |
187 |
204800 |
|
2800 |
60141576 |
IgorSmirnov |
D |
Sept. 5, 2019, 8:32 p.m. |
OK |
Kotlin |
TESTS |
37 |
187 |
1228800 |
|
2800 |
59266450 |
IgorSmirnov |
D |
Aug. 22, 2019, 10:58 a.m. |
OK |
Kotlin |
TESTS |
37 |
202 |
1331200 |
|
2800 |
59541658 |
darnley |
D |
Aug. 26, 2019, 7:12 p.m. |
OK |
Kotlin |
TESTS |
37 |
280 |
1433600 |
|
2800 |
59542253 |
darnley |
D |
Aug. 26, 2019, 7:30 p.m. |
OK |
Kotlin |
TESTS |
37 |
280 |
1433600 |
|
2800 |
59541832 |
darnley |
D |
Aug. 26, 2019, 7:17 p.m. |
OK |
Kotlin |
TESTS |
37 |
295 |
1433600 |
|
2800 |
59344094 |
darnley |
D |
Aug. 23, 2019, 8:54 a.m. |
OK |
Kotlin |
TESTS |
37 |
343 |
1433600 |
|
2800 |
59543133 |
darnley |
D |
Aug. 26, 2019, 7:56 p.m. |
OK |
Kotlin |
TESTS |
37 |
358 |
1536000 |
|
2800 |
59543374 |
darnley |
D |
Aug. 26, 2019, 8:03 p.m. |
OK |
Kotlin |
TESTS |
37 |
374 |
1536000 |
|
2800 |
61092626 |
SpinDOS |
D |
Sept. 22, 2019, 11:11 p.m. |
OK |
Mono C# |
TESTS |
37 |
78 |
4403200 |
|
2800 |
59125294 |
camypaper |
D |
Aug. 20, 2019, 8:56 a.m. |
OK |
Mono C# |
TESTS |
37 |
108 |
6758400 |
|
2800 |
59038463 |
math957963 |
D |
Aug. 18, 2019, 3:22 p.m. |
OK |
MS C++ |
TESTS |
37 |
31 |
1331200 |
|
2800 |
remove filters
Back to search problems