Codeforces Round 906 (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
1889 Codeforces Round 906 (Div. 1) FINISHED False 9000 38676263 Oct. 28, 2023, 2:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 117 ) E Doremy's Swapping Trees PROGRAMMING dfs and similar graphs trees

B'Consider two undirected graphs G_1 and G_2 . Every node in G_1 and in G_2 has a label. Doremy calls G_1 and G_2 similar if and only if: Now Doremy gives you two trees T_1 and T_2 with n nodes, labeled from 1 to n . You can do the following operation any number of times: Now Doremy is wondering how many distinct T_1 you can get after any number of operations. Can you help her find the answer? Output the answer modulo 10^9+7 . The input consists of multiple test cases. The first line contains a single integer t ( 1 <= t <= 2 cdot 10^4 ) -- the number of test cases. The description of the test cases follows. The first line contains an integer n ( 2 <= n <= 10^5 ) -- the number of nodes in the trees T_1 and T_2 . Each of the following n-1 lines contain two integers u,v ( 1 <= u,v <= n ), representing an undirected edge in T_1 . It is guaranteed these edges form a tree. Each of the following n-1 lines contain two integers u,v ( 1 <= u,v <= n ), representing an undirected edge in T_2 . It is guaranteed these edges form a tree. It is guaranteed that the sum of n does not exceed 2 cdot 10^5 . For each test case, you should output a single line with an integer, representing the number of distinct T_1 after any number of operations, modulo 10^9+7 . In the first test case, there is at most one distinct T_1 having the only edge (1,2) . In the second test case, you can choose the edge set {(1,3),(2,3) } in T_1 , the edge set {(1,2),(2,3) } in T_2 and swap them. So T_1 can be 1-3-2 or 1-2-3 . In the third test case, there are 4 distinct T_1 , as the following pictures. '...

Tutorials

Codeforces Round 906 Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
230293371 chappy1 E Oct. 28, 2023, 10:14 p.m. OK GNU C++20 (64) TESTS 20 1013 143257600
230246832 ecnerwala E Oct. 28, 2023, 4:23 p.m. OK GNU C++20 (64) TESTS 19 1045 104140800
230300914 nguyenquocthinhhung E Oct. 29, 2023, 2:09 a.m. OK GNU C++20 (64) TESTS 20 1045 143257600
230256898 Benq E Oct. 28, 2023, 4:49 p.m. OK GNU C++20 (64) TESTS 19 1528 285593600
230304204 magnus.hegdahl E Oct. 29, 2023, 3:14 a.m. OK GNU C++20 (64) TESTS 20 1934 268288000
230310411 magnus.hegdahl E Oct. 29, 2023, 4:49 a.m. OK GNU C++20 (64) TESTS 20 1981 343449600

remove filters

Back to search problems