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, consisting of n vertices. Each edge has an integer value written on it. Let f(v, u) be the number of values that appear exactly once on the edges of a simple path between vertices v and u . Calculate the sum of f(v, u) over all pairs of vertices v and u such that 1 <= v < u <= n . The first line contains a single integer n ( 2 <= n <= 5 cdot 10^5 ) -- the number of vertices in the tree. Each of the next n-1 lines contains three integers v, u and x ( 1 <= v, u, x <= n ) -- the description of an edge: the vertices it connects and the value written on it. The given edges form a tree. Print a single integer -- the sum of f(v, u) over all pairs of vertices v and u such that v < u . '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
158355274 |
SOSCHINA |
F |
May 25, 2022, 6:14 a.m. |
OK |
GNU C++14 |
TESTS |
54 |
468 |
49254400 |
|
2300 |
158360249 |
Fairy_Tale |
F |
May 25, 2022, 7:21 a.m. |
OK |
GNU C++14 |
TESTS |
54 |
576 |
63283200 |
|
2300 |
158278545 |
Eric_hooo |
F |
May 24, 2022, 8:30 a.m. |
OK |
GNU C++14 |
TESTS |
54 |
623 |
67276800 |
|
2300 |
158273651 |
bcofwy060 |
F |
May 24, 2022, 7:21 a.m. |
OK |
GNU C++14 |
TESTS |
54 |
670 |
66969600 |
|
2300 |
158390145 |
blade_dance |
F |
May 25, 2022, 12:56 p.m. |
OK |
GNU C++14 |
TESTS |
54 |
686 |
71065600 |
|
2300 |
158355725 |
SOSCHINA |
F |
May 25, 2022, 6:20 a.m. |
OK |
GNU C++14 |
TESTS |
54 |
701 |
49254400 |
|
2300 |
158290949 |
BARBARIANNNNN |
F |
May 24, 2022, 11:15 a.m. |
OK |
GNU C++14 |
TESTS |
54 |
732 |
63283200 |
|
2300 |
158395012 |
jucason_xu |
F |
May 25, 2022, 1:53 p.m. |
OK |
GNU C++14 |
TESTS |
54 |
748 |
69324800 |
|
2300 |
158271282 |
Cu_OH_2 |
F |
May 24, 2022, 6:50 a.m. |
OK |
GNU C++14 |
TESTS |
54 |
764 |
85299200 |
|
2300 |
158371737 |
leexzq |
F |
May 25, 2022, 9:31 a.m. |
OK |
GNU C++14 |
TESTS |
54 |
779 |
71065600 |
|
2300 |
158356660 |
SOSCHINA |
F |
May 25, 2022, 6:31 a.m. |
OK |
GNU C++17 |
TESTS |
54 |
296 |
59289600 |
|
2300 |
158376975 |
frostylight |
F |
May 25, 2022, 10:11 a.m. |
OK |
GNU C++17 |
TESTS |
54 |
343 |
59187200 |
|
2300 |
158355775 |
SOSCHINA |
F |
May 25, 2022, 6:20 a.m. |
OK |
GNU C++17 |
TESTS |
54 |
498 |
49254400 |
|
2300 |
158296812 |
luyuanfei |
F |
May 24, 2022, 12:26 p.m. |
OK |
GNU C++17 |
TESTS |
54 |
561 |
65228800 |
|
2300 |
158358515 |
acwing_meow |
F |
May 25, 2022, 6:56 a.m. |
OK |
GNU C++17 |
TESTS |
54 |
577 |
41472000 |
|
2300 |
158359556 |
william555 |
F |
May 25, 2022, 7:10 a.m. |
OK |
GNU C++17 |
TESTS |
54 |
577 |
47308800 |
|
2300 |
158321336 |
Flocculuz |
F |
May 24, 2022, 4:59 p.m. |
OK |
GNU C++17 |
TESTS |
54 |
607 |
81305600 |
|
2300 |
158277992 |
yagoo |
F |
May 24, 2022, 8:23 a.m. |
OK |
GNU C++17 |
TESTS |
54 |
639 |
89907200 |
|
2300 |
158576182 |
zjs22 |
F |
May 27, 2022, 3:06 a.m. |
OK |
GNU C++17 |
TESTS |
54 |
670 |
49766400 |
|
2300 |
158484292 |
zjs22 |
F |
May 26, 2022, 2:57 a.m. |
OK |
GNU C++17 |
TESTS |
54 |
670 |
49766400 |
|
2300 |
158394178 |
CartesianTree |
F |
May 25, 2022, 1:43 p.m. |
OK |
GNU C++17 (64) |
TESTS |
54 |
420 |
139673600 |
|
2300 |
158305583 |
Bobocan |
F |
May 24, 2022, 2:04 p.m. |
OK |
GNU C++17 (64) |
TESTS |
54 |
421 |
82022400 |
|
2300 |
158364539 |
mrsrz |
F |
May 25, 2022, 8:21 a.m. |
OK |
GNU C++17 (64) |
TESTS |
54 |
545 |
76288000 |
|
2300 |
158339782 |
Kude |
F |
May 24, 2022, 10:59 p.m. |
OK |
GNU C++17 (64) |
TESTS |
54 |
576 |
129536000 |
|
2300 |
158371764 |
leexzq |
F |
May 25, 2022, 9:31 a.m. |
OK |
GNU C++17 (64) |
TESTS |
54 |
592 |
102092800 |
|
2300 |
158371908 |
leexzq |
F |
May 25, 2022, 9:33 a.m. |
OK |
GNU C++17 (64) |
TESTS |
54 |
607 |
92057600 |
|
2300 |
158371932 |
leexzq |
F |
May 25, 2022, 9:33 a.m. |
OK |
GNU C++17 (64) |
TESTS |
54 |
608 |
92057600 |
|
2300 |
158304831 |
wuhypzz |
F |
May 24, 2022, 1:55 p.m. |
OK |
GNU C++17 (64) |
TESTS |
54 |
639 |
117248000 |
|
2300 |
158287666 |
TennojiRina |
F |
May 24, 2022, 10:34 a.m. |
OK |
GNU C++17 (64) |
TESTS |
54 |
655 |
108544000 |
|
2300 |
158301169 |
Lucina |
F |
May 24, 2022, 1:16 p.m. |
OK |
GNU C++17 (64) |
TESTS |
54 |
717 |
100147200 |
|
2300 |
158377301 |
frostylight |
F |
May 25, 2022, 10:15 a.m. |
OK |
GNU C++20 (64) |
TESTS |
54 |
327 |
104857600 |
|
2300 |
158372603 |
frostylight |
F |
May 25, 2022, 9:42 a.m. |
OK |
GNU C++20 (64) |
TESTS |
54 |
404 |
99532800 |
|
2300 |
158267196 |
yuexia |
F |
May 24, 2022, 5:46 a.m. |
OK |
GNU C++20 (64) |
TESTS |
54 |
436 |
121036800 |
|
2300 |
158483646 |
xls_is_real_dd |
F |
May 26, 2022, 2:42 a.m. |
OK |
GNU C++20 (64) |
TESTS |
54 |
467 |
88064000 |
|
2300 |
158382510 |
luogu_bot4 |
F |
May 25, 2022, 11:23 a.m. |
OK |
GNU C++20 (64) |
TESTS |
54 |
514 |
79155200 |
|
2300 |
158376640 |
08150442 |
F |
May 25, 2022, 10:07 a.m. |
OK |
GNU C++20 (64) |
TESTS |
54 |
514 |
79155200 |
|
2300 |
158576649 |
zn_com |
F |
May 27, 2022, 3:20 a.m. |
OK |
GNU C++20 (64) |
TESTS |
54 |
529 |
107008000 |
|
2300 |
158370080 |
prvocislo |
F |
May 25, 2022, 9:07 a.m. |
OK |
GNU C++20 (64) |
TESTS |
54 |
546 |
104140800 |
|
2300 |
158413070 |
xiaohuli |
F |
May 25, 2022, 5:25 p.m. |
OK |
GNU C++20 (64) |
TESTS |
54 |
561 |
88064000 |
|
2300 |
158336109 |
fishcathu. |
F |
May 24, 2022, 8:52 p.m. |
OK |
GNU C++20 (64) |
TESTS |
54 |
561 |
103014400 |
|
2300 |
158572903 |
Sempr |
F |
May 27, 2022, 1:25 a.m. |
OK |
Go |
TESTS |
54 |
841 |
222412800 |
|
2300 |
158572321 |
Sempr |
F |
May 27, 2022, 1:01 a.m. |
OK |
Go |
TESTS |
54 |
904 |
236339200 |
|
2300 |
158572401 |
Sempr |
F |
May 27, 2022, 1:05 a.m. |
OK |
Go |
TESTS |
54 |
951 |
237977600 |
|
2300 |
158572264 |
Sempr |
F |
May 27, 2022, 12:58 a.m. |
OK |
Go |
TESTS |
54 |
1123 |
243097600 |
|
2300 |
158572221 |
Sempr |
F |
May 27, 2022, 12:56 a.m. |
OK |
Go |
TESTS |
54 |
1201 |
264704000 |
|
2300 |
158572123 |
Sempr |
F |
May 27, 2022, 12:51 a.m. |
OK |
Go |
TESTS |
54 |
2105 |
267878400 |
|
2300 |
158336227 |
dzhi |
F |
May 24, 2022, 8:55 p.m. |
OK |
Java 11 |
TESTS |
54 |
3822 |
297062400 |
|
2300 |
158335870 |
dzhi |
F |
May 24, 2022, 8:46 p.m. |
OK |
Java 11 |
TESTS |
54 |
3931 |
297062400 |
|
2300 |
158335321 |
poopoop |
F |
May 24, 2022, 8:32 p.m. |
OK |
Java 11 |
TESTS |
54 |
5833 |
259276800 |
|
2300 |
158282604 |
arvindf232 |
F |
May 24, 2022, 9:21 a.m. |
OK |
Kotlin 1.4 |
TESTS |
54 |
2448 |
146944000 |
|
2300 |
158282405 |
arvindf232 |
F |
May 24, 2022, 9:19 a.m. |
OK |
Kotlin 1.4 |
TESTS |
54 |
2464 |
146944000 |
|
2300 |
158335513 |
DavitMarg |
F |
May 24, 2022, 8:37 p.m. |
OK |
MS C++ 2017 |
TESTS |
54 |
5054 |
59392000 |
|
2300 |
158335461 |
MrPupsik |
F |
May 24, 2022, 8:36 p.m. |
OK |
MS C++ 2017 |
TESTS |
54 |
5054 |
59392000 |
|
2300 |
158376671 |
zouyu9631 |
F |
May 25, 2022, 10:07 a.m. |
OK |
PyPy 3 |
TESTS |
54 |
3619 |
353689600 |
|
2300 |
158377619 |
zouyu9631 |
F |
May 25, 2022, 10:20 a.m. |
OK |
PyPy 3 |
TESTS |
54 |
3837 |
353075200 |
|
2300 |
158376704 |
zouyu9631 |
F |
May 25, 2022, 10:08 a.m. |
OK |
PyPy 3-64 |
TESTS |
54 |
4352 |
650547200 |
|
2300 |
158283050 |
Muhammad.Daniyal |
F |
May 24, 2022, 9:27 a.m. |
OK |
PyPy 3-64 |
TESTS |
54 |
5474 |
536576000 |
|
2300 |
158300471 |
sansen |
F |
May 24, 2022, 1:08 p.m. |
OK |
Rust 2021 |
TESTS |
54 |
217 |
99942400 |
|
2300 |
158305484 |
Spheniscine |
F |
May 24, 2022, 2:03 p.m. |
OK |
Rust 2021 |
TESTS |
54 |
607 |
108646400 |
|
2300 |
158307172 |
Spheniscine |
F |
May 24, 2022, 2:23 p.m. |
OK |
Rust 2021 |
TESTS |
54 |
623 |
112640000 |
|
2300 |
158305265 |
Spheniscine |
F |
May 24, 2022, 2:01 p.m. |
OK |
Rust 2021 |
TESTS |
54 |
655 |
108646400 |
|
2300 |
158305332 |
Spheniscine |
F |
May 24, 2022, 2:01 p.m. |
OK |
Rust 2021 |
TESTS |
54 |
686 |
108748800 |
|
2300 |
158378248 |
robostac |
F |
May 25, 2022, 10:28 a.m. |
OK |
Rust 2021 |
TESTS |
54 |
1886 |
213094400 |
|
2300 |
158269137 |
LaplacianMatrix |
F |
May 24, 2022, 6:15 a.m. |
OK |
Rust 2021 |
TESTS |
54 |
5880 |
301670400 |
|
2300 |
remove filters
Back to search problems