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 vertices. A hero k times do the following operation: You are given an initial tree and the a sequence of written numbers. Find the number of ways to make operations such that the written numbers are equal to the given numbers. Due to the answer can be big, find it by modulo 998 ,244 ,353 . Two ways are considered different, if on some operation edge or remaining part are selected differently. The first line contains a single integer n ( 2 <= q n <= q 5000 ) -- the number of vertices. Each of the next n-1 lines contains two integers s , f ( 1 <= q s, f <= q n , s neq f ) -- description of edge (s, f) . Next line contains a single integer k ( 1 <= q k <= q min{(6, n - 1)} ) -- the number of operations. Next line contains k integers s_1, s_2, ldots, s_k ( n > s_1 > s_2 > ldots > s_k geq 1 ) -- written numbers. Print a single integer -- the answer to the problem by modulo 998 ,244 ,353 . In the first test there are four possible ways to make operations: In the second test there are two possible ways to make operations: '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
195177627 |
inaFSTream |
H |
Feb. 27, 2023, 4:40 p.m. |
OK |
GNU C++14 |
TESTS |
43 |
233 |
19251200 |
|
|
195192378 |
emptyhope |
H |
Feb. 27, 2023, 6:03 p.m. |
OK |
GNU C++17 |
TESTS |
43 |
202 |
7270400 |
|
|
195226059 |
vjudge5 |
H |
Feb. 28, 2023, 3:48 a.m. |
OK |
GNU C++17 (64) |
TESTS |
43 |
46 |
3993600 |
|
|
195226028 |
luogu_bot1 |
H |
Feb. 28, 2023, 3:47 a.m. |
OK |
GNU C++17 (64) |
TESTS |
43 |
62 |
3993600 |
|
|
195181162 |
orzdevinwang |
H |
Feb. 27, 2023, 4:56 p.m. |
OK |
GNU C++17 (64) |
TESTS |
43 |
249 |
83456000 |
|
|
195187046 |
ainta |
H |
Feb. 27, 2023, 5:23 p.m. |
OK |
GNU C++17 (64) |
TESTS |
43 |
280 |
37273600 |
|
|
195223481 |
torisasami |
H |
Feb. 28, 2023, 2:58 a.m. |
OK |
GNU C++17 (64) |
TESTS |
43 |
390 |
14745600 |
|
|
195224350 |
SugoiTurtle |
H |
Feb. 28, 2023, 3:17 a.m. |
OK |
GNU C++20 (64) |
TESTS |
43 |
46 |
3481600 |
|
|
195223143 |
bkifhr10 |
H |
Feb. 28, 2023, 2:51 a.m. |
OK |
GNU C++20 (64) |
TESTS |
43 |
46 |
3481600 |
|
|
195176943 |
noimi |
H |
Feb. 27, 2023, 4:37 p.m. |
OK |
GNU C++20 (64) |
TESTS |
43 |
46 |
4505600 |
|
|
195194874 |
jtnydv25 |
H |
Feb. 27, 2023, 6:18 p.m. |
OK |
GNU C++20 (64) |
TESTS |
43 |
46 |
16793600 |
|
|
195223400 |
goingdown |
H |
Feb. 28, 2023, 2:56 a.m. |
OK |
GNU C++20 (64) |
TESTS |
43 |
46 |
72704000 |
|
|
195223116 |
njwrz |
H |
Feb. 28, 2023, 2:50 a.m. |
OK |
GNU C++20 (64) |
TESTS |
43 |
62 |
3481600 |
|
|
195226593 |
goingdown |
H |
Feb. 28, 2023, 4 a.m. |
OK |
GNU C++20 (64) |
TESTS |
43 |
77 |
72704000 |
|
|
195181900 |
ugly2333 |
H |
Feb. 27, 2023, 5 p.m. |
OK |
GNU C++20 (64) |
TESTS |
43 |
78 |
3276800 |
|
|
195183885 |
Petr |
H |
Feb. 27, 2023, 5:09 p.m. |
OK |
GNU C++20 (64) |
TESTS |
43 |
78 |
5529600 |
|
|
195186163 |
ksun48 |
H |
Feb. 27, 2023, 5:20 p.m. |
OK |
GNU C++20 (64) |
TESTS |
43 |
93 |
11468800 |
|
|
195192548 |
sansen |
H |
Feb. 27, 2023, 6:04 p.m. |
OK |
Rust 2021 |
TESTS |
43 |
904 |
4096000 |
|
|
remove filters
Back to search problems