Order Capital Round 2 (Codeforces Round 1104, Div. 1 + Div. 2)

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
2237 Order Capital Round 2 (Codeforces Round 1104, Div. 1 + Div. 2) FINISHED False 10800 4807484 June 18, 2026, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 98 ) I2 DBFS Order (Hard Version) PROGRAMMING dp trees

This is the hard version of the problem. The difference between the versions is that in this version, the string (s) may also contain character 1 . You can hack only if you solved all versions of this problem. You are given a rooted tree with (n) vertices, rooted at vertex (1). For each vertex, its children are given in a fixed order. Each vertex except the root has a color, either (0) or (1). For a fixed coloring, define the following traversal. After the process ends, the list (p) is called the traversal list of this coloring. It can be shown that (p) is always a permutation of (1,2,\ldots,n). In particular, if all colors are (0), then (p) is the DFS preorder of the tree; if all colors are (1), then (p) is the BFS order of the tree, where children are visited in the given order. You are given a string (s) of length (n-1), consisting of characters 0 , 1 , and ? . For each vertex (i) with (2\le i\le n), the character (s_{i-1}) describes the possible color of vertex (i): if (s_{i-1}=0), then vertex (i) must have color (0); if (s_{i-1}=1), then vertex (i) must have color (1); if (s_{i-1}=?), then vertex (i) may have color (0) or (1). Find the number of distinct traversal lists that can be obtained over all valid colorings. Since the answer may be large, output it modulo (10^9+7). 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 first line of each test case contains an integer (n) ((2 \le n \le 3000)) — the number of vertices in the tree. The second line contains a string (s) of length (n-1). In the hard version, (s) consists of characters 0 , 1 , and ? . The character (s_i) describes the possible color of vertex (i+1). The next (n) lines describe the ordered lists of

Tutorials

Order Capital Round 2 (Codeforces Round 1104, Div. 1 + Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
379438628 ProblemI2isEasy I2 June 18, 2026, 11:44 p.m. OK C++17 (GCC 7-32) TESTS 102 312 289792000
379439092 ProblemI2isEasy I2 June 19, 2026, 12:02 a.m. OK C++17 (GCC 7-32) TESTS 102 421 102400
379444378 montasirmasrol I2 June 19, 2026, 2:44 a.m. OK C++20 (GCC 13-64) TESTS 102 234 579379200
379452962 liuwanpeng I2 June 19, 2026, 5:18 a.m. OK C++20 (GCC 13-64) TESTS 102 265 577638400
379438495 FreddieLiu I2 June 18, 2026, 11:38 p.m. OK C++20 (GCC 13-64) TESTS 102 281 577638400
379444590 StarSilk I2 June 19, 2026, 2:48 a.m. OK C++23 (GCC 14-64, msys2) TESTS 102 203 577638400
379442082 hungchi17 I2 June 19, 2026, 1:46 a.m. OK C++23 (GCC 14-64, msys2) TESTS 102 265 577638400
379449300 MATH00001 I2 June 19, 2026, 4:18 a.m. OK C++23 (GCC 14-64, msys2) TESTS 102 281 577638400
379448795 MATH00001 I2 June 19, 2026, 4:09 a.m. OK C++23 (GCC 14-64, msys2) TESTS 102 281 577638400
379456029 edmondium23 I2 June 19, 2026, 5:59 a.m. OK C++23 (GCC 14-64, msys2) TESTS 102 1265 647987200
379439323 ProblemI2isEasy I2 June 19, 2026, 12:12 a.m. OK PyPy 3-64 TESTS 102 1843 77824000

remove filters

Back to search problems