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're given a tree with n vertices. The color of the i -th vertex is h_{i} . The value of the tree is defined as sum limits_{h_{i} = h_{j}, 1 <= i < j <= n}{dis(i,j)} , where dis(i,j) is the number of edges on the shortest path between i and j . The color of each vertex is lost, you only remember that h_{i} can be any integer from [l_{i}, r_{i}] (inclusive). You want to calculate the sum of values of all trees meeting these conditions modulo 10^9 + 7 (the set of edges is fixed, but each color is unknown, so there are prod limits_{i = 1}^{n} (r_{i} - l_{i} + 1) different trees). The first line contains one integer n ( 2 <= n <= 10^5 ) -- the number of vertices. Then n lines follow, each line contains two integers l_i and r_i ( 1 <= l_i <= r_i <= 10^5 ) denoting the range of possible colors of vertex i . Then n - 1 lines follow, each containing two integers u and v ( 1 <= u, v <= n , u ne v ) denoting an edge of the tree. It is guaranteed that these edges form a tree. Print one integer -- the sum of values of all possible trees, taken modulo 10^9 + 7 . In the first example there are four different ways to color the tree (so, there are four different trees): Overall the sum of all values is 10+4+4+4=22 . "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
65913015 |
Fuyuki |
F |
Nov. 28, 2019, 1:35 p.m. |
OK |
GNU C++11 |
TESTS |
26 |
233 |
14745600 |
|
2700 |
65912882 |
Fuyuki |
F |
Nov. 28, 2019, 1:33 p.m. |
OK |
GNU C++11 |
TESTS |
26 |
280 |
14745600 |
|
2700 |
65950287 |
nehnait |
F |
Nov. 29, 2019, 10:32 a.m. |
OK |
GNU C++11 |
TESTS |
26 |
296 |
22016000 |
|
2700 |
66044873 |
xht37 |
F |
Nov. 30, 2019, 2:48 p.m. |
OK |
GNU C++11 |
TESTS |
26 |
311 |
22016000 |
|
2700 |
66164672 |
alpc_qleonardo |
F |
Dec. 2, 2019, 6:52 a.m. |
OK |
GNU C++11 |
TESTS |
26 |
390 |
23142400 |
|
2700 |
66571569 |
2829908231 |
F |
Dec. 10, 2019, 4:56 a.m. |
OK |
GNU C++11 |
TESTS |
26 |
420 |
13312000 |
|
2700 |
65902583 |
dqa2020 |
F |
Nov. 28, 2019, 9:26 a.m. |
OK |
GNU C++11 |
TESTS |
26 |
421 |
15462400 |
|
2700 |
65904158 |
dqa2020 |
F |
Nov. 28, 2019, 10:08 a.m. |
OK |
GNU C++11 |
TESTS |
26 |
451 |
19251200 |
|
2700 |
65952501 |
Mr_Wu |
F |
Nov. 29, 2019, 11:27 a.m. |
OK |
GNU C++11 |
TESTS |
26 |
546 |
23859200 |
|
2700 |
65892149 |
wbs501 |
F |
Nov. 28, 2019, 4:02 a.m. |
OK |
GNU C++11 |
TESTS |
26 |
592 |
15052800 |
|
2700 |
66084581 |
shdut |
F |
Dec. 1, 2019, 3:30 a.m. |
OK |
GNU C++14 |
TESTS |
26 |
342 |
13312000 |
|
2700 |
65902534 |
yan-zp |
F |
Nov. 28, 2019, 9:25 a.m. |
OK |
GNU C++14 |
TESTS |
26 |
498 |
14131200 |
|
2700 |
66192446 |
xdu_lhz |
F |
Dec. 2, 2019, 5:01 p.m. |
OK |
GNU C++14 |
TESTS |
26 |
514 |
15155200 |
|
2700 |
65877636 |
icecuber |
F |
Nov. 27, 2019, 5:36 p.m. |
OK |
GNU C++14 |
TESTS |
26 |
514 |
25088000 |
|
2700 |
66212404 |
xdu_lhz |
F |
Dec. 3, 2019, 7:26 a.m. |
OK |
GNU C++14 |
TESTS |
26 |
530 |
25088000 |
|
2700 |
65873518 |
pr3pony |
F |
Nov. 27, 2019, 4:20 p.m. |
OK |
GNU C++14 |
TESTS |
26 |
546 |
52326400 |
|
2700 |
66822193 |
iefnah06 |
F |
Dec. 14, 2019, 7:45 a.m. |
OK |
GNU C++14 |
TESTS |
26 |
561 |
27136000 |
|
2700 |
65875286 |
sajibreadd |
F |
Nov. 27, 2019, 4:49 p.m. |
OK |
GNU C++14 |
TESTS |
26 |
608 |
23756800 |
|
2700 |
65887080 |
nhho |
F |
Nov. 27, 2019, 11:47 p.m. |
OK |
GNU C++14 |
TESTS |
26 |
624 |
13824000 |
|
2700 |
65928696 |
grazier |
F |
Nov. 28, 2019, 7:38 p.m. |
OK |
GNU C++14 |
TESTS |
26 |
670 |
38400000 |
|
2700 |
66654398 |
neal |
F |
Dec. 11, 2019, 9:14 p.m. |
OK |
GNU C++17 |
TESTS |
26 |
233 |
19046400 |
|
2700 |
66654291 |
neal |
F |
Dec. 11, 2019, 9:09 p.m. |
OK |
GNU C++17 |
TESTS |
26 |
233 |
19046400 |
|
2700 |
66654244 |
neal |
F |
Dec. 11, 2019, 9:07 p.m. |
OK |
GNU C++17 |
TESTS |
26 |
234 |
17510400 |
|
2700 |
66654464 |
neal |
F |
Dec. 11, 2019, 9:17 p.m. |
OK |
GNU C++17 |
TESTS |
26 |
234 |
18022400 |
|
2700 |
66654326 |
neal |
F |
Dec. 11, 2019, 9:11 p.m. |
OK |
GNU C++17 |
TESTS |
26 |
249 |
19046400 |
|
2700 |
66654302 |
neal |
F |
Dec. 11, 2019, 9:10 p.m. |
OK |
GNU C++17 |
TESTS |
26 |
249 |
19046400 |
|
2700 |
66654412 |
neal |
F |
Dec. 11, 2019, 9:15 p.m. |
OK |
GNU C++17 |
TESTS |
26 |
264 |
19046400 |
|
2700 |
66654187 |
neal |
F |
Dec. 11, 2019, 9:04 p.m. |
OK |
GNU C++17 |
TESTS |
26 |
265 |
17100800 |
|
2700 |
66654492 |
neal |
F |
Dec. 11, 2019, 9:18 p.m. |
OK |
GNU C++17 |
TESTS |
26 |
265 |
18022400 |
|
2700 |
66654365 |
neal |
F |
Dec. 11, 2019, 9:12 p.m. |
OK |
GNU C++17 |
TESTS |
26 |
295 |
19046400 |
|
2700 |
65944421 |
dalt |
F |
Nov. 29, 2019, 7:57 a.m. |
OK |
Java 8 |
TESTS |
26 |
966 |
51609600 |
|
2700 |
65880137 |
Harpae |
F |
Nov. 27, 2019, 6:37 p.m. |
OK |
Java 8 |
TESTS |
26 |
2215 |
7065600 |
|
2700 |
65880084 |
Harpae |
F |
Nov. 27, 2019, 6:36 p.m. |
OK |
Java 8 |
TESTS |
26 |
2293 |
7065600 |
|
2700 |
66086269 |
sansen |
F |
Dec. 1, 2019, 4:57 a.m. |
OK |
Rust |
TESTS |
26 |
810 |
21401600 |
|
2700 |
66087425 |
sansen |
F |
Dec. 1, 2019, 5:41 a.m. |
OK |
Rust |
TESTS |
26 |
872 |
21504000 |
|
2700 |
65928060 |
sansen |
F |
Nov. 28, 2019, 7:20 p.m. |
OK |
Rust |
TESTS |
26 |
1497 |
19251200 |
|
2700 |
65927965 |
sansen |
F |
Nov. 28, 2019, 7:18 p.m. |
OK |
Rust |
TESTS |
26 |
2105 |
19353600 |
|
2700 |
remove filters
Back to search problems