think-cell Round 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
1930 think-cell Round 1 FINISHED False 10800 28999463 Feb. 17, 2024, 2:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 364 ) G Prefix Max Set Counting PROGRAMMING data structures trees

B'Define a function f such that for an array b , f(b) returns the array of prefix maxima of b . In other words, f(b) is an array containing only those elements b_i , for which b_i= max(b_1,b_2, ldots,b_i) , without changing their order. For example, f([3,10,4,10,15,1])=[3,10,10,15] . You are given a tree consisting of n nodes rooted at 1 . A permutation ^ dagger p of is considered a pre-order of the tree if for all i the following condition holds: Find the number of distinct values of f(a) over all possible pre-orders a . Since this value might be large, you only need to find it modulo 998 ,244 ,353 . ^ dagger A permutation of length n is an array consisting of n distinct integers from 1 to n in arbitrary order. For example, [2,3,1,5,4] is a permutation, but [1,2,2] is not a permutation ( 2 appears twice in the array), and [1,3,4] is also not a permutation ( n=3 but there is 4 in the array). ^ ddagger Node t is a proper descendant of node s if s neq t and s is on the unique simple path from t to 1 . Each test contains multiple test cases. The first line contains a single integer t ( 1 <= q t <= q 10^5 ) -- the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer n ( 1 <= q n <= q 10^6 ) -- the number of vertices. The following next n-1 lines contain two integers u and v ( 1 <= q u, v <= q n , u neq v ) -- denoting an edge between nodes u and v . It is guaranteed that the given edges form a tree. It is guaranteed that the sum of n over all test cases does not exceed 10^6 . For each test case, output the number of distinct values of f(a) modulo 998 ,244 ,353 that you can get. In the first test case, the only valid'...

Tutorials

think-cell Round 1 Editorial

Submissions

No solutions yet.