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"Petya had a tree consisting of n vertices numbered with integers from 1 to n. Accidentally he lost his tree. Petya remembers information about k vertices: distances from each of them to each of the n tree vertices. Your task is to restore any tree that satisfies the information that Petya remembers or report that such tree doesn't exist. The first line contains two integers n and k (2 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n xe2 x80 x89 xe2 x89 xa4 xe2 x80 x8930 xe2 x80 x89000, 1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89k xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89min(200, xe2 x80 x89n)) -- the number of vertices in the tree and the number of vertices about which Petya remembers distance information. The following k lines contain remembered information. The i-th line contains n integers di, xe2 x80 x891, xe2 x80 x89di, xe2 x80 x892, xe2 x80 x89..., xe2 x80 x89di, xe2 x80 x89n (0 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89di, xe2 x80 x89j xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n xe2 x80 x89- xe2 x80 x891), where di, xe2 x80 x89j -- the distance to j-th vertex from the i-th vertex that Petya remembers. If there are no suitable trees, print -1. In the other case, print n xe2 x80 x89- xe2 x80 x891 lines: each line should contain two vertices connected by edge in the required tree. You can print edges and vertices in an edge in any order. The tree vertices are enumerated from 1 to n. If there are many solutions print any of them. Picture for the first sample: "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
33921178 |
_SHENZHEBEI_ |
E |
Jan. 5, 2018, 12:02 p.m. |
OK |
GNU C++ |
TESTS |
159 |
202 |
56217600 |
|
2800 |
40979515 |
ReaLNero1 |
E |
July 30, 2018, 5:06 p.m. |
OK |
GNU C++ |
TESTS |
159 |
233 |
54169600 |
|
2800 |
31379429 |
ez_zjt |
E |
Oct. 16, 2017, 12:40 a.m. |
OK |
GNU C++ |
TESTS |
159 |
1091 |
31027200 |
|
2800 |
32373216 |
vjudge4 |
E |
Nov. 17, 2017, 8:47 a.m. |
OK |
GNU C++ |
TESTS |
159 |
1216 |
84172800 |
|
2800 |
31355349 |
fateice |
E |
Oct. 15, 2017, 9:30 a.m. |
OK |
GNU C++ |
TESTS |
159 |
1372 |
54886400 |
|
2800 |
32149458 |
peehs_moorhsum |
E |
Nov. 9, 2017, 1:45 a.m. |
OK |
GNU C++ |
TESTS |
159 |
1856 |
76595200 |
|
2800 |
32373419 |
vjudge3 |
E |
Nov. 17, 2017, 8:57 a.m. |
OK |
GNU C++ |
TESTS |
159 |
2808 |
85504000 |
|
2800 |
32373130 |
vjudge4 |
E |
Nov. 17, 2017, 8:43 a.m. |
OK |
GNU C++ |
TESTS |
159 |
2947 |
85606400 |
|
2800 |
32373302 |
vjudge3 |
E |
Nov. 17, 2017, 8:51 a.m. |
OK |
GNU C++ |
TESTS |
159 |
2963 |
85606400 |
|
2800 |
32373065 |
vjudge2 |
E |
Nov. 17, 2017, 8:41 a.m. |
OK |
GNU C++ |
TESTS |
159 |
2963 |
85606400 |
|
2800 |
33963574 |
zhouyuyang |
E |
Jan. 6, 2018, 1:30 p.m. |
OK |
GNU C++11 |
TESTS |
159 |
248 |
54988800 |
|
2800 |
31362057 |
laofudasuan |
E |
Oct. 15, 2017, 11:24 a.m. |
OK |
GNU C++11 |
TESTS |
159 |
436 |
53964800 |
|
2800 |
39800624 |
Steaunk |
E |
June 30, 2018, 2:30 p.m. |
OK |
GNU C++11 |
TESTS |
159 |
654 |
29081600 |
|
2800 |
31349981 |
eddy1021 |
E |
Oct. 15, 2017, 8:59 a.m. |
OK |
GNU C++11 |
TESTS |
159 |
670 |
54374400 |
|
2800 |
39800636 |
Steaunk |
E |
June 30, 2018, 2:30 p.m. |
OK |
GNU C++11 |
TESTS |
159 |
826 |
140492800 |
|
2800 |
57872891 |
lopare |
E |
July 28, 2019, 3:09 a.m. |
OK |
GNU C++11 |
TESTS |
159 |
872 |
60416000 |
|
2800 |
45651814 |
zhouyuyang |
E |
Nov. 13, 2018, 2:15 a.m. |
OK |
GNU C++11 |
TESTS |
159 |
904 |
50585600 |
|
2800 |
31428722 |
atatomir |
E |
Oct. 16, 2017, 6:07 p.m. |
OK |
GNU C++11 |
TESTS |
159 |
967 |
54681600 |
|
2800 |
31428657 |
atatomir |
E |
Oct. 16, 2017, 6:05 p.m. |
OK |
GNU C++11 |
TESTS |
159 |
982 |
52633600 |
|
2800 |
33866840 |
jslijin |
E |
Jan. 2, 2018, 3:37 p.m. |
OK |
GNU C++11 |
TESTS |
159 |
998 |
52326400 |
|
2800 |
32231774 |
LiChenKoh |
E |
Nov. 11, 2017, 10:40 p.m. |
OK |
GNU C++14 |
TESTS |
159 |
670 |
238592000 |
|
2800 |
31840758 |
King_George |
E |
Oct. 28, 2017, 2:20 p.m. |
OK |
GNU C++14 |
TESTS |
159 |
701 |
99430400 |
|
2800 |
32231694 |
LiChenKoh |
E |
Nov. 11, 2017, 10:32 p.m. |
OK |
GNU C++14 |
TESTS |
159 |
701 |
238592000 |
|
2800 |
33889963 |
bmerry |
E |
Jan. 3, 2018, 5:26 p.m. |
OK |
GNU C++14 |
TESTS |
159 |
1184 |
41369600 |
|
2800 |
34611525 |
lbn187 |
E |
Jan. 27, 2018, 4:27 p.m. |
OK |
GNU C++14 |
TESTS |
159 |
1435 |
62464000 |
|
2800 |
64556908 |
thebes |
E |
Nov. 9, 2019, 4:17 a.m. |
OK |
GNU C++14 |
TESTS |
159 |
1497 |
49766400 |
|
2800 |
34611337 |
lbn187 |
E |
Jan. 27, 2018, 4:21 p.m. |
OK |
GNU C++14 |
TESTS |
159 |
1497 |
62464000 |
|
2800 |
31467047 |
I_Love_Umirzhanova_Amina |
E |
Oct. 18, 2017, 2:52 a.m. |
OK |
GNU C++14 |
TESTS |
159 |
1590 |
30105600 |
|
2800 |
33027076 |
Georgia_001 |
E |
Dec. 8, 2017, 3:43 p.m. |
OK |
GNU C++14 |
TESTS |
159 |
1606 |
30105600 |
|
2800 |
31593968 |
mishobaxa1234 |
E |
Oct. 22, 2017, 6:39 a.m. |
OK |
GNU C++14 |
TESTS |
159 |
1606 |
30105600 |
|
2800 |
47858003 |
Benq |
E |
Jan. 3, 2019, 2:12 a.m. |
OK |
GNU C++17 |
TESTS |
159 |
1279 |
28979200 |
|
2800 |
66303702 |
justfocusplease |
E |
Dec. 5, 2019, 8:25 a.m. |
OK |
GNU C++17 |
TESTS |
159 |
1419 |
49254400 |
|
2800 |
56732512 |
mocania |
E |
July 9, 2019, 2:36 a.m. |
OK |
GNU C++17 |
TESTS |
159 |
1591 |
103014400 |
|
2800 |
69552633 |
hjk1030 |
E |
Jan. 26, 2020, 7:13 a.m. |
OK |
GNU C++17 |
TESTS |
159 |
1606 |
37478400 |
|
2800 |
55859671 |
hjk1030 |
E |
June 21, 2019, 8:53 a.m. |
OK |
GNU C++17 |
TESTS |
159 |
1622 |
37478400 |
|
2800 |
67603151 |
Atreus |
E |
Dec. 25, 2019, 12:39 p.m. |
OK |
GNU C++17 |
TESTS |
159 |
1668 |
53350400 |
|
2800 |
67603080 |
vjudge4 |
E |
Dec. 25, 2019, 12:37 p.m. |
OK |
GNU C++17 |
TESTS |
159 |
1684 |
53350400 |
|
2800 |
61554336 |
vjudge2 |
E |
Sept. 30, 2019, 1:33 p.m. |
OK |
GNU C++17 |
TESTS |
159 |
1684 |
105472000 |
|
2800 |
41123051 |
LHiC |
E |
Aug. 2, 2018, 12:54 p.m. |
OK |
GNU C++17 |
TESTS |
159 |
1918 |
30822400 |
|
2800 |
66745356 |
icecuber |
E |
Dec. 13, 2019, 1:35 a.m. |
OK |
GNU C++17 |
TESTS |
159 |
1949 |
28364800 |
|
2800 |
61748766 |
vjudge2 |
E |
Oct. 3, 2019, 2:07 a.m. |
OK |
MS C++ |
TESTS |
159 |
1528 |
30924800 |
|
2800 |
remove filters
Back to search problems