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
Consider the following problem statement: You are given a tree with (n) vertices rooted at (1). For each (1 \leq i \leq n), a car will enter the root at time (l_i). It will then instantaneously travel from the root to vertex (i) through the unique simple path and park there. It will leave through the same path in the other direction at time (r_i). During the time when a car is parked in a vertex, it blocks other cars from traveling through that vertex. The tree is called valid if and only if all cars are able to enter and leave the tree at their desired times. Count the number of pairs of sequences (l), (r) such that (l_i < r_i), their concatenation is a permutation of (1 \ldots 2n), and the tree is valid. You are given a tree with (n) vertices rooted at (1). For each (1 \leq i \leq n), a car will enter the root at time (l_i). It will then instantaneously travel from the root to vertex (i) through the unique simple path and park there. It will leave through the same path in the other direction at time (r_i). During the time when a car is parked in a vertex, it blocks other cars from traveling through that vertex. The tree is called valid if and only if all cars are able to enter and leave the tree at their desired times. Count the number of pairs of sequences (l), (r) such that (l_i < r_i), their concatenation is a permutation of (1 \ldots 2n), and the tree is valid. Calculate the sum of the answers to the problem over all labeled trees(^{\text{∗}}) with (n) vertices and (k) leaves. The root is not considered a leaf. Since the answer may be large, calculate it modulo (998\,244\,353). (^{\text{∗}})Two labeled trees are considered different if and only if their edge sets are different. Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 10^4)). The description of the test cases follows. The only li |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|
329883810 |
lehaleha_2010 |
G |
July 19, 2025, 5:37 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
42 |
155 |
6451200 |
|
|
|
329875310 |
leinad2 |
G |
July 19, 2025, 4:43 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
42 |
155 |
6451200 |
|
|
|
329927379 |
Dia0si |
G |
July 20, 2025, 5:31 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
42 |
374 |
60211200 |
|
|
|
329927441 |
Dia0si |
G |
July 20, 2025, 5:32 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
42 |
390 |
60211200 |
|
|
|
329885431 |
August61945 |
G |
July 19, 2025, 5:48 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
42 |
62 |
5939200 |
|
|
|
329894347 |
SmolBrain |
G |
July 19, 2025, 7:10 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
42 |
62 |
6451200 |
|
|
|
329921688 |
rin204 |
G |
July 20, 2025, 4:06 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
42 |
77 |
307200 |
|
|
|
329920366 |
Network_Error |
G |
July 20, 2025, 3:44 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
42 |
77 |
3276800 |
|
|
|
329916456 |
le0n |
G |
July 20, 2025, 2:40 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
42 |
77 |
3276800 |
|
|
|
329883894 |
eric574 |
G |
July 19, 2025, 5:37 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
42 |
77 |
6451200 |
|
|
|
329878032 |
034_Bikash |
G |
July 19, 2025, 4:48 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
42 |
77 |
9625600 |
|
|
|
329882400 |
bachbeo2007 |
G |
July 19, 2025, 5:28 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
42 |
77 |
9728000 |
|
|
|
329920917 |
Qiubai_love |
G |
July 20, 2025, 3:54 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
42 |
77 |
12902400 |
|
|
|
329910940 |
L_Wave |
G |
July 20, 2025, 12:29 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
42 |
92 |
32153600 |
|
|
|
329909172 |
Badri41 |
G |
July 19, 2025, 11:26 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
42 |
62 |
102400 |
|
|
|
329929759 |
postpone |
G |
July 20, 2025, 5:59 a.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
42 |
62 |
1228800 |
|
|
|
329908909 |
Badri41 |
G |
July 19, 2025, 11:16 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
42 |
77 |
102400 |
|
|
|
329923722 |
ATRIQAQ |
G |
July 20, 2025, 4:40 a.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
42 |
77 |
2560000 |
|
|
|
329924506 |
ll931110 |
G |
July 20, 2025, 4:53 a.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
42 |
77 |
3276800 |
|
|
|
329885818 |
VanshVala |
G |
July 19, 2025, 5:51 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
42 |
77 |
3276800 |
|
|
|
329914343 |
ta2ly.id |
G |
July 20, 2025, 2 a.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
42 |
77 |
4505600 |
|
|
|
329870566 |
Georgewhba18 |
G |
July 19, 2025, 4:32 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
42 |
77 |
4505600 |
|
|
|
329888357 |
Zhou_Hang |
G |
July 19, 2025, 6:12 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
42 |
77 |
5632000 |
|
|
|
329913381 |
jiangbowen |
G |
July 20, 2025, 1:36 a.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
42 |
78 |
24064000 |
|
|
|
329881677 |
toam |
G |
July 19, 2025, 5:23 p.m. |
OK |
PyPy 3-64 |
TESTS |
42 |
218 |
14438400 |
|
|
|
329924133 |
shanks_jr10 |
G |
July 20, 2025, 4:46 a.m. |
OK |
Python 3 |
TESTS |
42 |
608 |
25088000 |
|
|
|
329871603 |
chayan381 |
G |
July 19, 2025, 4:35 p.m. |
OK |
Python 3 |
TESTS |
42 |
843 |
64921600 |
|
|
remove filters
Back to search problems