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'A tree is an undirected connected graph without cycles. You are given a tree of n vertices. Find the number of ways to choose exactly k vertices in this tree (i. xe2 x80 x89e. a k -element subset of vertices) so that all pairwise distances between the selected vertices are equal (in other words, there exists an integer c such that for all u, v ( u ne v , u, v are in selected vertices) d_{u,v}=c , where d_{u,v} is the distance from u to v ). Since the answer may be very large, you need to output it modulo 10^9 + 7 . The first line contains one integer t ( 1 <= t <= 10 ) -- the number of test cases. Then t test cases follow. Each test case is preceded by an empty line. Each test case consists of several lines. The first line of the test case contains two integers n and k ( 2 <= k <= n <= 100 ) -- the number of vertices in the tree and the number of vertices to be selected, respectively. Then n - 1 lines follow, each of them contains two integers u and v ( 1 <= u, v <= n , u neq v ) which describe a pair of vertices connected by an edge. It is guaranteed that the given graph is a tree and has no loops or multiple edges. For each test case output in a separate line a single integer -- the number of ways to select exactly k vertices so that for all pairs of selected vertices the distances between the vertices in the pairs are equal, modulo 10^9 + 7 (in other words, print the remainder when divided by 1000000007 ). '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
123528207 |
CallmeChallenger |
F |
July 23, 2021, 4:34 p.m. |
OK |
GNU C++11 |
TESTS |
15 |
15 |
4096000 |
|
|
123569891 |
fishcathu. |
F |
July 24, 2021, 4:56 a.m. |
OK |
GNU C++11 |
TESTS |
15 |
31 |
3891200 |
|
|
123571576 |
Archer_ |
F |
July 24, 2021, 5:22 a.m. |
OK |
GNU C++11 |
TESTS |
15 |
31 |
3993600 |
|
|
123526103 |
ycxtzctietie |
F |
July 23, 2021, 4:32 p.m. |
OK |
GNU C++11 |
TESTS |
15 |
31 |
3993600 |
|
|
123547040 |
dumb_boi |
F |
July 23, 2021, 8:01 p.m. |
OK |
GNU C++11 |
TESTS |
15 |
46 |
4198400 |
|
|
123557442 |
Acfboy |
F |
July 24, 2021, 1:02 a.m. |
OK |
GNU C++11 |
TESTS |
15 |
78 |
4608000 |
|
|
123555316 |
Solstice |
F |
July 23, 2021, 11:43 p.m. |
OK |
GNU C++11 |
TESTS |
15 |
78 |
13209600 |
|
|
123570679 |
Hoa_Dau_Biec |
F |
July 24, 2021, 5:08 a.m. |
OK |
GNU C++11 |
TESTS |
15 |
93 |
20172800 |
|
|
123560423 |
TrumpisChinese |
F |
July 24, 2021, 2:11 a.m. |
OK |
GNU C++11 |
TESTS |
15 |
109 |
3993600 |
|
|
123534090 |
_Rainbow_ |
F |
July 23, 2021, 5:14 p.m. |
OK |
GNU C++11 |
TESTS |
15 |
139 |
13824000 |
|
|
123528594 |
Abhi60 |
F |
July 23, 2021, 4:36 p.m. |
OK |
GNU C++14 |
TESTS |
15 |
30 |
3993600 |
|
|
123537195 |
owen_up |
F |
July 23, 2021, 5:48 p.m. |
OK |
GNU C++14 |
TESTS |
15 |
30 |
4198400 |
|
|
123540089 |
AST_TheCoder |
F |
July 23, 2021, 6:24 p.m. |
OK |
GNU C++14 |
TESTS |
15 |
31 |
3891200 |
|
|
123571367 |
ngpin04 |
F |
July 24, 2021, 5:18 a.m. |
OK |
GNU C++14 |
TESTS |
15 |
31 |
3891200 |
|
|
123535774 |
LptN21 |
F |
July 23, 2021, 5:31 p.m. |
OK |
GNU C++14 |
TESTS |
15 |
31 |
3891200 |
|
|
123533476 |
Yuki726 |
F |
July 23, 2021, 5:08 p.m. |
OK |
GNU C++14 |
TESTS |
15 |
31 |
3993600 |
|
|
123550000 |
Bedo_Sayed |
F |
July 23, 2021, 8:56 p.m. |
OK |
GNU C++14 |
TESTS |
15 |
31 |
3993600 |
|
|
123541443 |
naveenls |
F |
July 23, 2021, 6:41 p.m. |
OK |
GNU C++14 |
TESTS |
15 |
31 |
3993600 |
|
|
123536006 |
LptN21 |
F |
July 23, 2021, 5:33 p.m. |
OK |
GNU C++14 |
TESTS |
15 |
31 |
3993600 |
|
|
123525397 |
Neal_lee |
F |
July 23, 2021, 4:31 p.m. |
OK |
GNU C++14 |
TESTS |
15 |
31 |
3993600 |
|
|
123554243 |
ShJ |
F |
July 23, 2021, 10:55 p.m. |
OK |
GNU C++17 |
TESTS |
15 |
15 |
3891200 |
|
|
123550315 |
iwriaw |
F |
July 23, 2021, 9:03 p.m. |
OK |
GNU C++17 |
TESTS |
15 |
15 |
3891200 |
|
|
123532914 |
ei133333 |
F |
July 23, 2021, 5:03 p.m. |
OK |
GNU C++17 |
TESTS |
15 |
15 |
3993600 |
|
|
123569600 |
HealthyUG |
F |
July 24, 2021, 4:51 a.m. |
OK |
GNU C++17 |
TESTS |
15 |
15 |
3993600 |
|
|
123537283 |
TISparta |
F |
July 23, 2021, 5:49 p.m. |
OK |
GNU C++17 |
TESTS |
15 |
15 |
3993600 |
|
|
123536189 |
_FireGhost_ |
F |
July 23, 2021, 5:35 p.m. |
OK |
GNU C++17 |
TESTS |
15 |
15 |
3993600 |
|
|
123526555 |
bi11a1 |
F |
July 23, 2021, 4:32 p.m. |
OK |
GNU C++17 |
TESTS |
15 |
15 |
3993600 |
|
|
123547460 |
1127193030 |
F |
July 23, 2021, 8:08 p.m. |
OK |
GNU C++17 |
TESTS |
15 |
30 |
3891200 |
|
|
123561211 |
V4V |
F |
July 24, 2021, 2:26 a.m. |
OK |
GNU C++17 |
TESTS |
15 |
30 |
3993600 |
|
|
123542354 |
1e9_plus_7 |
F |
July 23, 2021, 6:55 p.m. |
OK |
GNU C++17 |
TESTS |
15 |
30 |
3993600 |
|
|
123528653 |
kiyoshi0205 |
F |
July 23, 2021, 4:37 p.m. |
OK |
GNU C++17 (64) |
TESTS |
15 |
15 |
4403200 |
|
|
123564977 |
AccioAC |
F |
July 24, 2021, 3:31 a.m. |
OK |
GNU C++17 (64) |
TESTS |
15 |
15 |
4403200 |
|
|
123529058 |
Prateek |
F |
July 23, 2021, 4:38 p.m. |
OK |
GNU C++17 (64) |
TESTS |
15 |
15 |
4403200 |
|
|
123541182 |
Wielomian |
F |
July 23, 2021, 6:38 p.m. |
OK |
GNU C++17 (64) |
TESTS |
15 |
15 |
4505600 |
|
|
123557155 |
Bakkar- |
F |
July 24, 2021, 12:56 a.m. |
OK |
GNU C++17 (64) |
TESTS |
15 |
15 |
4505600 |
|
|
123553068 |
beedle |
F |
July 23, 2021, 10:15 p.m. |
OK |
GNU C++17 (64) |
TESTS |
15 |
15 |
4505600 |
|
|
123535284 |
purple_waxberry |
F |
July 23, 2021, 5:25 p.m. |
OK |
GNU C++17 (64) |
TESTS |
15 |
15 |
4505600 |
|
|
123558494 |
crescent_yhw |
F |
July 24, 2021, 1:29 a.m. |
OK |
GNU C++17 (64) |
TESTS |
15 |
30 |
4300800 |
|
|
123548521 |
Mangooste |
F |
July 23, 2021, 8:26 p.m. |
OK |
GNU C++17 (64) |
TESTS |
15 |
30 |
4300800 |
|
|
123574008 |
mjtai |
F |
July 24, 2021, 5:56 a.m. |
OK |
GNU C++17 (64) |
TESTS |
15 |
30 |
4403200 |
|
|
123562673 |
GennadyTran |
F |
July 24, 2021, 2:51 a.m. |
OK |
Java 11 |
TESTS |
15 |
218 |
23859200 |
|
|
123547917 |
sarthakmanna |
F |
July 23, 2021, 8:16 p.m. |
OK |
Java 11 |
TESTS |
15 |
312 |
32051200 |
|
|
123562699 |
GennadyTran |
F |
July 24, 2021, 2:52 a.m. |
OK |
Java 11 |
TESTS |
15 |
701 |
23756800 |
|
|
123526519 |
2020akadaver |
F |
July 23, 2021, 4:32 p.m. |
OK |
Java 11 |
TESTS |
15 |
779 |
33280000 |
|
|
123553004 |
hu_tao |
F |
July 23, 2021, 10:14 p.m. |
OK |
Java 8 |
TESTS |
15 |
171 |
20787200 |
|
|
123530376 |
Hakiobo |
F |
July 23, 2021, 4:45 p.m. |
OK |
Kotlin |
TESTS |
15 |
140 |
22732800 |
|
|
123542547 |
knightL |
F |
July 23, 2021, 6:57 p.m. |
OK |
Kotlin |
TESTS |
15 |
264 |
21811200 |
|
|
123547215 |
grey |
F |
July 23, 2021, 8:04 p.m. |
OK |
MS C++ 2017 |
TESTS |
15 |
31 |
3993600 |
|
|
123549438 |
danilgrig |
F |
July 23, 2021, 8:44 p.m. |
OK |
MS C++ 2017 |
TESTS |
15 |
78 |
3891200 |
|
|
123537305 |
mban259 |
F |
July 23, 2021, 5:49 p.m. |
OK |
.NET Core C# |
TESTS |
15 |
108 |
17305600 |
|
|
123540022 |
hxu10 |
F |
July 23, 2021, 6:23 p.m. |
OK |
PyPy 3 |
TESTS |
15 |
187 |
24576000 |
|
|
123548251 |
manish.17 |
F |
July 23, 2021, 8:21 p.m. |
OK |
PyPy 3 |
TESTS |
15 |
218 |
29593600 |
|
|
123551039 |
silvertint |
F |
July 23, 2021, 9:21 p.m. |
OK |
PyPy 3 |
TESTS |
15 |
249 |
29798400 |
|
|
123547332 |
titia |
F |
July 23, 2021, 8:06 p.m. |
OK |
PyPy 3 |
TESTS |
15 |
343 |
48537600 |
|
|
123547780 |
manish.17 |
F |
July 23, 2021, 8:13 p.m. |
OK |
PyPy 3 |
TESTS |
15 |
467 |
36556800 |
|
|
123546290 |
manish.17 |
F |
July 23, 2021, 7:49 p.m. |
OK |
PyPy 3 |
TESTS |
15 |
468 |
36556800 |
|
|
remove filters
Back to search problems