Codeforces Round 540 (Div. 3)

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
1118 Codeforces Round 540 (Div. 3) FINISHED False 8100 186938723 Feb. 19, 2019, 2:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 552 ) F2 Tree Cutting (Hard Version) PROGRAMMING combinatorics dfs and similar dp trees 2700

B"You are given an undirected tree of n vertices. Some vertices are colored one of the k colors, some are uncolored. It is guaranteed that the tree contains at least one vertex of each of the k colors. There might be no uncolored vertices. You choose a subset of exactly k - 1 edges and remove it from the tree. Tree falls apart into k connected components. Let's call this subset of edges nice if none of the resulting components contain vertices of different colors. How many nice subsets of edges are there in the given tree? Two subsets are considered different if there is some edge that is present in one subset and absent in the other. The answer may be large, so print it modulo 998244353 . The first line contains two integers n and k ( 2 <= n <= 3 cdot 10^5 , 2 <= k <= n ) -- the number of vertices in the tree and the number of colors, respectively. The second line contains n integers a_1, a_2, ... , a_n ( 0 <= a_i <= k ) -- the colors of the vertices. a_i = 0 means that vertex i is uncolored, any other value means the vertex i is colored that color. The i -th of the next n - 1 lines contains two integers v_i and u_i ( 1 <= v_i, u_i <= n , v_i ne u_i ) -- the edges of the tree. It is guaranteed that the given edges form a tree. It is guaranteed that the tree contains at least one vertex of each of the k colors. There might be no uncolored vertices. Print a single integer -- the number of nice subsets of edges in the given tree. Two subsets are considered different if there is some edge that is present in one subset and absent in the other. The answer may be large, so print it modulo 998244353 . Here is the tree from the first example: The only nice subset is edge (2, 4) . Removing it makes the tree fall apart into components {4 } and {1, 2, 3, 5 } . The first component only includes a vertex of"...

Tutorials

65396

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
50395070 rainboy F2 Feb. 23, 2019, 3:33 p.m. OK GNU C11 TESTS 78 343 43212800 2700
50284824 zylbeyondlimits F2 Feb. 21, 2019, 2:22 p.m. OK GNU C++11 TESTS 78 171 55296000 2700
58934215 luogu_bot5 F2 Aug. 17, 2019, 2:58 a.m. OK GNU C++11 TESTS 78 202 44441600 2700
50302238 xumingyang F2 Feb. 22, 2019, 3:18 a.m. OK GNU C++11 TESTS 78 202 44544000 2700
63295396 luogu_bot3 F2 Oct. 24, 2019, 12:51 p.m. OK GNU C++11 TESTS 78 202 64819200 2700
50229652 remoon F2 Feb. 20, 2019, 8:40 a.m. OK GNU C++11 TESTS 78 202 85504000 2700
63277989 Rikuki F2 Oct. 24, 2019, 7:40 a.m. OK GNU C++11 TESTS 78 217 33484800 2700
63289497 Roger_Bai F2 Oct. 24, 2019, 11:22 a.m. OK GNU C++11 TESTS 78 217 50278400 2700
63288473 luogu_bot1 F2 Oct. 24, 2019, 11:05 a.m. OK GNU C++11 TESTS 78 218 50278400 2700
52741321 EncodeTalker F2 April 14, 2019, 9:12 a.m. OK GNU C++11 TESTS 78 233 48640000 2700
51354833 was_n F2 March 16, 2019, 3:10 a.m. OK GNU C++11 TESTS 78 249 35942400 2700
50995202 emoairx F2 March 8, 2019, 3:03 a.m. OK GNU C++14 TESTS 78 202 44748800 2700
50342441 liouzhou_101 F2 Feb. 23, 2019, 3:37 a.m. OK GNU C++14 TESTS 78 249 52940800 2700
50342428 liouzhou_101 F2 Feb. 23, 2019, 3:36 a.m. OK GNU C++14 TESTS 78 296 52940800 2700
50315970 zjB_shadow F2 Feb. 22, 2019, 12:16 p.m. OK GNU C++14 TESTS 78 296 53043200 2700
63634776 luogu_bot3 F2 Oct. 28, 2019, 7:49 a.m. OK GNU C++14 TESTS 78 358 43212800 2700
50245652 jerome_wei F2 Feb. 20, 2019, 2:47 p.m. OK GNU C++14 TESTS 78 358 48230400 2700
50309142 Rabbittank F2 Feb. 22, 2019, 8:13 a.m. OK GNU C++14 TESTS 78 373 63795200 2700
68947685 Lucina F2 Jan. 16, 2020, 4:48 p.m. OK GNU C++14 TESTS 78 373 74752000 2700
63634676 vjudge5 F2 Oct. 28, 2019, 7:46 a.m. OK GNU C++14 TESTS 78 374 43212800 2700
50342388 liouzhou_101 F2 Feb. 23, 2019, 3:33 a.m. OK GNU C++14 TESTS 78 374 48128000 2700
50311498 libra8z F2 Feb. 22, 2019, 9:51 a.m. OK GNU C++17 TESTS 78 295 50790400 2700
61456930 tyzc F2 Sept. 29, 2019, 6:45 a.m. OK GNU C++17 TESTS 78 311 45670400 2700
50311435 libra8z F2 Feb. 22, 2019, 9:48 a.m. OK GNU C++17 TESTS 78 312 50790400 2700
68947934 Lucina F2 Jan. 16, 2020, 4:52 p.m. OK GNU C++17 TESTS 78 342 69939200 2700
50236305 adorable F2 Feb. 20, 2019, 10:54 a.m. OK GNU C++17 TESTS 78 343 49459200 2700
50347229 dmkozyrev F2 Feb. 23, 2019, 6:56 a.m. OK GNU C++17 TESTS 78 358 38604800 2700
50233851 gebixiaofang F2 Feb. 20, 2019, 9:49 a.m. OK GNU C++17 TESTS 78 358 49459200 2700
68948036 Lucina F2 Jan. 16, 2020, 4:54 p.m. OK GNU C++17 TESTS 78 358 69939200 2700
68947692 Lucina F2 Jan. 16, 2020, 4:48 p.m. OK GNU C++17 TESTS 78 358 69939200 2700
50247303 ivan100sic F2 Feb. 20, 2019, 3:33 p.m. OK GNU C++17 TESTS 78 358 71168000 2700
66382944 dalt F2 Dec. 6, 2019, 6:23 a.m. OK Java 8 TESTS 78 545 203264000 2700
50395071 Dukkha F2 Feb. 23, 2019, 3:33 p.m. OK Java 8 TESTS 78 1185 142848000 2700
65126481 barakraganosungam F2 Nov. 16, 2019, 2:44 a.m. OK Java 8 TESTS 78 1388 182476800 2700
50892621 Oopsimbad F2 March 6, 2019, 1:45 p.m. OK Java 8 TESTS 78 1918 268390400 2700
60373832 vjudge4 F2 Sept. 11, 2019, 5:02 a.m. OK MS C++ TESTS 78 249 93696000 2700
60373899 yst_ F2 Sept. 11, 2019, 5:05 a.m. OK MS C++ TESTS 78 265 93696000 2700
60336125 vjudge1 F2 Sept. 10, 2019, 8:38 a.m. OK MS C++ 2017 TESTS 78 451 50483200 2700
68200367 gearjack F2 Jan. 4, 2020, 3:27 p.m. OK Rust TESTS 78 467 117862400 2700

remove filters

Back to search problems