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
( 6071 ) F1 Tree Cutting (Easy Version) PROGRAMMING dfs and similar trees 1800

B"You are given an undirected tree of n vertices. Some vertices are colored blue, some are colored red and some are uncolored. It is guaranteed that the tree contains at least one red vertex and at least one blue vertex. You choose an edge and remove it from the tree. Tree falls apart into two connected components. Let's call an edge nice if neither of the resulting components contain vertices of both red and blue colors. How many nice edges are there in the given tree? The first line contains a single integer n ( 2 <= n <= 3 cdot 10^5 ) -- the number of vertices in the tree. The second line contains n integers a_1, a_2, ... , a_n ( 0 <= a_i <= 2 ) -- the colors of the vertices. a_i = 1 means that vertex i is colored red, a_i = 2 means that vertex i is colored blue and a_i = 0 means that vertex i is uncolored. 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 red vertex and at least one blue vertex. Print a single integer -- the number of nice edges in the given tree. Here is the tree from the first example: The only nice edge 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 red vertex and the second component includes blue vertices and uncolored vertices. Here is the tree from the second example: Every edge is nice in it. Here is the tree from the third example: Edge (1, 3) splits the into components {1 } and {3, 2 } , the latter one includes both red and blue vertex, thus the edge isn't nice. Edge (2, 3) splits the into components {1, 3 } and {2 } , the former one includes both red and blue vertex, thus the edge also isn't nice"...

Tutorials

65396

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
52133924 rr_ F1 April 1, 2019, 12:02 a.m. OK D TESTS 57 436 40448000 1800
50192633 ia7ck F1 Feb. 19, 2019, 4:22 p.m. OK D TESTS 57 436 48537600 1800
54577309 Denor F1 May 25, 2019, 12:49 a.m. OK Delphi TESTS 57 187 21811200 1800
54577064 Denor F1 May 25, 2019, 12:29 a.m. OK Delphi TESTS 57 249 26624000 1800
50199818 Ngohavi F1 Feb. 19, 2019, 5:01 p.m. OK FPC TESTS 57 280 14745600 1800
50195325 rainboy F1 Feb. 19, 2019, 4:36 p.m. OK GNU C11 TESTS 57 202 30003200 1800
50395182 rainboy F1 Feb. 23, 2019, 3:35 p.m. OK GNU C11 TESTS 57 296 43212800 1800
50283831 Mr_Wu F1 Feb. 21, 2019, 1:56 p.m. OK GNU C++11 TESTS 57 93 21401600 1800
50273239 Scut82 F1 Feb. 21, 2019, 8:29 a.m. OK GNU C++11 TESTS 57 93 25292800 1800
50418535 AndyMo F1 Feb. 24, 2019, 7:53 a.m. OK GNU C++11 TESTS 57 93 26214400 1800
58962290 Jim_CaiCaiCai_ F1 Aug. 17, 2019, 3:52 p.m. OK GNU C++11 TESTS 57 93 27648000 1800
50276703 Scut82 F1 Feb. 21, 2019, 10:29 a.m. OK GNU C++11 TESTS 57 93 30003200 1800
50289415 C919 F1 Feb. 21, 2019, 4:39 p.m. OK GNU C++11 TESTS 57 93 43212800 1800
53467867 heyuanjie F1 April 28, 2019, 11:10 a.m. OK GNU C++11 TESTS 57 93 48025600 1800
58962263 vjudge3 F1 Aug. 17, 2019, 3:51 p.m. OK GNU C++11 TESTS 57 109 27648000 1800
50267055 zylbeyondlimits F1 Feb. 21, 2019, 5:07 a.m. OK GNU C++11 TESTS 57 124 19558400 1800
50727219 xiezichen F1 March 3, 2019, 10:15 a.m. OK GNU C++11 TESTS 57 124 24985600 1800
50628656 interestingLSY F1 March 1, 2019, 7:44 a.m. OK GNU C++14 TESTS 57 187 27648000 1800
50239952 tokitsukaze F1 Feb. 20, 2019, 12:32 p.m. OK GNU C++14 TESTS 57 202 32665600 1800
50315318 infinis F1 Feb. 22, 2019, 11:58 a.m. OK GNU C++14 TESTS 57 218 17100800 1800
50526215 ziliuziliu F1 Feb. 26, 2019, 11:53 a.m. OK GNU C++14 TESTS 57 218 24064000 1800
50267043 100Coke F1 Feb. 21, 2019, 5:07 a.m. OK GNU C++14 TESTS 57 218 25190400 1800
50192765 Gotland F1 Feb. 19, 2019, 4:23 p.m. OK GNU C++14 TESTS 57 218 32665600 1800
58649854 vjudge2 F1 Aug. 12, 2019, 7:07 a.m. OK GNU C++14 TESTS 57 233 13312000 1800
58575539 vjudge4 F1 Aug. 11, 2019, 12:12 p.m. OK GNU C++14 TESTS 57 233 19251200 1800
50410126 pipishrimp F1 Feb. 24, 2019, 1:37 a.m. OK GNU C++14 TESTS 57 233 24064000 1800
58618855 vjudge5 F1 Aug. 11, 2019, 2:48 p.m. OK GNU C++14 TESTS 57 233 25190400 1800
51384935 .tx F1 March 16, 2019, 6:15 p.m. OK GNU C++17 TESTS 57 187 36249600 1800
50216343 HIT_Attacker F1 Feb. 20, 2019, 4:52 a.m. OK GNU C++17 TESTS 57 218 17100800 1800
58644645 vjudge5 F1 Aug. 12, 2019, 5:17 a.m. OK GNU C++17 TESTS 57 218 29081600 1800
50236803 cgtllp1 F1 Feb. 20, 2019, 11:07 a.m. OK GNU C++17 TESTS 57 218 51302400 1800
50235286 DeLus1oN F1 Feb. 20, 2019, 10:26 a.m. OK GNU C++17 TESTS 57 233 19251200 1800
50341875 stArliGht F1 Feb. 23, 2019, 3:06 a.m. OK GNU C++17 TESTS 57 233 24064000 1800
50195117 jasminjake F1 Feb. 19, 2019, 4:35 p.m. OK GNU C++17 TESTS 57 233 24064000 1800
50286375 wuzj F1 Feb. 21, 2019, 3:04 p.m. OK GNU C++17 TESTS 57 233 26419200 1800
50201546 TelmaZzzz F1 Feb. 19, 2019, 5:26 p.m. OK GNU C++17 TESTS 57 233 27238400 1800
50769281 ZGQ F1 March 4, 2019, 2:44 a.m. OK GNU C++17 TESTS 57 234 19558400 1800
69302308 synapse F1 Jan. 22, 2020, 2:11 p.m. OK Go TESTS 57 202 85504000 1800
69302051 synapse F1 Jan. 22, 2020, 2:07 p.m. OK Go TESTS 57 592 74137600 1800
50213996 2008061626 F1 Feb. 20, 2019, 2:53 a.m. OK Go TESTS 57 670 45465600 1800
68971471 satya_p54 F1 Jan. 17, 2020, 7:10 a.m. OK Java 11 TESTS 57 1060 111104000 1800
68591310 zhanyi_xiaolu F1 Jan. 11, 2020, 12:44 p.m. OK Java 11 TESTS 57 1918 97587200 1800
50214971 aman28rwt F1 Feb. 20, 2019, 3:44 a.m. OK Java 8 TESTS 57 389 42598400 1800
50195483 hiromi_ayase F1 Feb. 19, 2019, 4:36 p.m. OK Java 8 TESTS 57 405 41472000 1800
50201826 Taran_1407 F1 Feb. 19, 2019, 5:33 p.m. OK Java 8 TESTS 57 436 49356800 1800
50196039 SevenDeadlySins F1 Feb. 19, 2019, 4:39 p.m. OK Java 8 TESTS 57 592 18636800 1800
50233453 karthickmj F1 Feb. 20, 2019, 9:38 a.m. OK Java 8 TESTS 57 607 105881600 1800
52879565 MaxHeap F1 April 16, 2019, 10:24 p.m. OK Java 8 TESTS 57 639 83456000 1800
66601462 manish_98 F1 Dec. 10, 2019, 4:41 p.m. OK Java 8 TESTS 57 654 74137600 1800
50344205 rookie19 F1 Feb. 23, 2019, 5:21 a.m. OK Java 8 TESTS 57 670 246067200 1800
51124236 sonusingh.nitaa F1 March 10, 2019, 10:53 a.m. OK Java 8 TESTS 57 685 104550400 1800
50271951 prabhat236218 F1 Feb. 21, 2019, 7:49 a.m. OK Java 8 TESTS 57 686 176640000 1800
50214204 LLI_E_P_JI_O_K F1 Feb. 20, 2019, 3:02 a.m. OK JavaScript TESTS 57 1216 73625600 1800
50214333 LLI_E_P_JI_O_K F1 Feb. 20, 2019, 3:09 a.m. OK JavaScript TESTS 57 1247 73625600 1800
51841566 Mosyagin F1 March 25, 2019, 10:29 p.m. OK Mono C# TESTS 57 951 47820800 1800
50463021 NEvOl F1 Feb. 24, 2019, 6:43 p.m. OK Mono C# TESTS 57 1747 64716800 1800
58791803 vjudge5 F1 Aug. 14, 2019, 2:48 a.m. OK MS C++ TESTS 57 156 18022400 1800
54449991 vjudge1 F1 May 21, 2019, 1:07 p.m. OK MS C++ TESTS 57 171 15462400 1800
58643460 vjudge3 F1 Aug. 12, 2019, 4:49 a.m. OK MS C++ TESTS 57 171 15872000 1800
58643264 vjudge1 F1 Aug. 12, 2019, 4:44 a.m. OK MS C++ TESTS 57 171 15872000 1800
50705638 SUSTech-Vegetable F1 March 3, 2019, 3:36 a.m. OK MS C++ TESTS 57 171 19251200 1800
58700532 vjudge4 F1 Aug. 13, 2019, 7:40 a.m. OK MS C++ TESTS 57 171 21606400 1800
58700720 vjudge3 F1 Aug. 13, 2019, 7:44 a.m. OK MS C++ TESTS 57 171 21606400 1800
50705665 vjudge1 F1 March 3, 2019, 3:38 a.m. OK MS C++ TESTS 57 187 19251200 1800
50704989 SUSTech-Vegetable F1 March 3, 2019, 2:57 a.m. OK MS C++ TESTS 57 187 20480000 1800
58650424 vjudge4 F1 Aug. 12, 2019, 7:17 a.m. OK MS C++ TESTS 57 217 18022400 1800
57990182 pmitkov F1 July 30, 2019, 12:56 p.m. OK MS C++ 2017 TESTS 57 343 21606400 1800
53839389 makorro F1 May 7, 2019, 6:21 a.m. OK MS C++ 2017 TESTS 57 373 23142400 1800
50194639 GomBu F1 Feb. 19, 2019, 4:32 p.m. OK MS C++ 2017 TESTS 57 389 19558400 1800
50915111 OICoder_zsx F1 March 7, 2019, 5:47 a.m. OK MS C++ 2017 TESTS 57 389 21708800 1800
58641827 vjudge4 F1 Aug. 12, 2019, 4 a.m. OK MS C++ 2017 TESTS 57 389 24064000 1800
57988660 pmitkov F1 July 30, 2019, 12:21 p.m. OK MS C++ 2017 TESTS 57 420 20480000 1800
61448000 MrLolthe1st F1 Sept. 28, 2019, 10:47 p.m. OK MS C++ 2017 TESTS 57 717 30003200 1800
50284584 nomiku99 F1 Feb. 21, 2019, 2:16 p.m. OK MS C++ 2017 TESTS 57 733 20480000 1800
50194377 nonstopfor F1 Feb. 19, 2019, 4:31 p.m. OK MS C++ 2017 TESTS 57 733 28876800 1800
50288445 Mint_Dentifrice F1 Feb. 21, 2019, 4:09 p.m. OK MS C++ 2017 TESTS 57 748 22835200 1800
51297373 pajenegod F1 March 14, 2019, 12:56 p.m. OK PyPy 2 TESTS 57 826 57139200 1800
51293453 c1729 F1 March 14, 2019, 11:32 a.m. OK PyPy 2 TESTS 57 872 57036800 1800
51294979 c1729 F1 March 14, 2019, 12:07 p.m. OK PyPy 2 TESTS 57 919 59699200 1800
51320672 c1729 F1 March 15, 2019, 6:46 a.m. OK PyPy 2 TESTS 57 935 58265600 1800
51298596 pajenegod F1 March 14, 2019, 1:25 p.m. OK PyPy 2 TESTS 57 935 63897600 1800
51293245 c1729 F1 March 14, 2019, 11:27 a.m. OK PyPy 2 TESTS 57 950 57344000 1800
51320579 c1729 F1 March 15, 2019, 6:43 a.m. OK PyPy 2 TESTS 57 982 58982400 1800
51320430 c1729 F1 March 15, 2019, 6:34 a.m. OK PyPy 3 TESTS 57 888 67379200 1800
50530837 hmnid F1 Feb. 26, 2019, 1:34 p.m. OK PyPy 3 TESTS 57 1169 80281600 1800
50657639 gatsko F1 March 1, 2019, 8:27 p.m. OK PyPy 3 TESTS 57 1637 227020800 1800
68200778 gearjack F1 Jan. 4, 2020, 3:39 p.m. OK Rust TESTS 57 280 108236800 1800
50285687 yakamoto F1 Feb. 21, 2019, 2:44 p.m. OK Scala TESTS 57 857 22630400 1800

remove filters

Back to search problems