Codeforces Round 499 (Div. 1)

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.

ContestId
Name
Phase
Frozen
Duration (Seconds)
Relative Time
Start Time
1010 Codeforces Round 499 (Div. 1) FINISHED False 7200 204908123 July 26, 2018, 3:05 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 225 ) F Tree PROGRAMMING fft graphs trees 3400

B"The Main Martian Tree grows on Mars. It is a binary tree (a rooted tree, with no more than two sons at each vertex) with n vertices, where the root vertex has the number 1 . Its fruits are the Main Martian Fruits. It's summer now, so this tree does not have any fruit yet. Autumn is coming soon, and leaves and branches will begin to fall off the tree. It is clear, that if a vertex falls off the tree, then its entire subtree will fall off too. In addition, the root will remain on the tree. Formally: the tree will have some connected subset of vertices containing the root. After that, the fruits will grow on the tree (only at those vertices which remain). Exactly x fruits will grow in the root. The number of fruits in each remaining vertex will be not less than the sum of the numbers of fruits in the remaining sons of this vertex. It is allowed, that some vertices will not have any fruits. Natasha wondered how many tree configurations can be after the described changes. Since this number can be very large, output it modulo 998244353 . Two configurations of the resulting tree are considered different if one of these two conditions is true: The first line contains two integers: n and x ( 1 <= n <= 10^5 , 0 <= x <= 10^{18} ) -- the size of the tree and the number of fruits in the root. The i -th of the following (n-1) lines contains two integers a_i and b_i ( 1 <= a_i, b_i <= n ) -- vertices connected by the i -th edge of the tree. It is guaranteed that the input data describes a correct binary tree with the root at the vertex 1 . Print one number -- the number of configurations of the resulting tree modulo 998244353 . Consider the first example. There are 2 fruits at the vertex 1 . The following 13 options are possible: Consider the second example. There are 5 fruits at the vertex 1 . The following 7 options are possible: "...

Tutorials

60851

Submissions

No solutions yet.