Codeforces Round 395 (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
763 Codeforces Round 395 (Div. 1) FINISHED False 7200 245780699 Feb. 2, 2017, 1:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 10621 ) A Timofey and a tree PROGRAMMING dfs and similar dp ds graphs implementation trees 1600

B'Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci. Now it 's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes some vertex in hands, while all the other vertices move down so that the tree becomes rooted at the chosen vertex. After that Timofey brings the tree to a trash can. Timofey doesn 't like it when many colors are mixing together. A subtree annoys him if there are vertices of different color in it. Timofey wants to find a vertex which he should take in hands so that there are no subtrees that annoy him. He doesn 't consider the whole tree as a subtree since he can 't see the color of the root vertex. A subtree of some vertex is a subgraph containing that vertex and all its descendants. Your task is to determine if there is a vertex, taking which in hands Timofey wouldn 't be annoyed. The first line contains single integer n (2 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89105) -- the number of vertices in the tree. Each of the next n xe2 x80 x89- xe2 x80 x891 lines contains two integers u and v (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89u, xe2 x80 x89v xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n, u xe2 x80 x89 xe2 x89 xa0 xe2 x80 x89v), denoting there is an edge between vertices u and v. It is guaranteed that the given graph is a tree. The next line contains n integers c1, xe2 x80 x89c2, xe2 x80 x89..., xe2 x80 x89cn (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89ci xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89105), denoting the colors of the vertices. Print "NO" in a single line, if Timofey can 't take the tree in such a way that it doesn 't annoy him. Otherwise print "YES" in the first line. In the second line print the index of the vertex which Timofey should take in hands. If there are multiple answers, print any of them. '...

Tutorials

Codeforces Round #395 [Editorial]

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
24573853 ilyakanyshev A Feb. 10, 2017, 4:41 p.m. OK FPC TESTS 67 61 3276800 1600
64907376 luogu_bot2 A Nov. 14, 2019, 11:27 p.m. OK FPC TESTS 67 62 3174400 1600
24453498 0lkeh A Feb. 5, 2017, 2:39 p.m. OK FPC TESTS 67 62 4915200 1600
25639767 nikih.10 A March 19, 2017, 8:09 a.m. OK FPC TESTS 67 62 6758400 1600
42222462 TShT A Aug. 28, 2018, 10:14 p.m. OK FPC TESTS 67 62 16076800 1600
24467526 Sanja A Feb. 6, 2017, 11:40 a.m. OK FPC TESTS 67 77 5529600 1600
24404469 Vakhan A Feb. 3, 2017, 7:37 a.m. OK FPC TESTS 67 109 6451200 1600
26098209 ice_tea A April 3, 2017, 11:38 a.m. OK FPC TESTS 67 109 18329600 1600
24370049 Tebak_Siapa_Aku A Feb. 2, 2017, 1:48 p.m. OK GNU C TESTS 67 62 3686400 1600
27940165 vjudge3 A June 21, 2017, 7:58 a.m. OK GNU C TESTS 67 62 3891200 1600
32967750 NoSoul A Dec. 6, 2017, 6:58 a.m. OK GNU C TESTS 67 62 6041600 1600
24371015 TsReaper A Feb. 2, 2017, 1:51 p.m. OK GNU C TESTS 67 62 6860800 1600
41573064 Scut82 A Aug. 14, 2018, 1:19 a.m. OK GNU C++ TESTS 67 31 1638400 1600
41573109 Scut82 A Aug. 14, 2018, 1:24 a.m. OK GNU C++ TESTS 67 31 1740800 1600
27730927 rqgao2014 A June 12, 2017, 4:51 a.m. OK GNU C++ TESTS 67 31 3276800 1600
39461445 Siyuan A June 21, 2018, 12:11 p.m. OK GNU C++ TESTS 67 31 3481600 1600
24717275 Hermera A Feb. 16, 2017, 12:11 p.m. OK GNU C++ TESTS 67 31 3481600 1600
24400824 zhanglexing A Feb. 3, 2017, 3:37 a.m. OK GNU C++ TESTS 67 31 3481600 1600
31705554 mengbierr A Oct. 25, 2017, 10:34 a.m. OK GNU C++ TESTS 67 31 3584000 1600
24734968 lichang A Feb. 17, 2017, 9:14 a.m. OK GNU C++ TESTS 67 31 3686400 1600
24372089 Xiejiadong A Feb. 2, 2017, 1:54 p.m. OK GNU C++ TESTS 67 31 3788800 1600
39436947 L__A A June 20, 2018, 1:20 p.m. OK GNU C++ TESTS 67 31 3891200 1600
30316234 f2lk6wf90d A Sept. 13, 2017, 8:32 p.m. OK GNU C11 TESTS 67 78 4403200 1600
24414216 ditoly A Feb. 3, 2017, 3:31 p.m. OK GNU C++11 TESTS 67 15 3481600 1600
28815842 dhuacm11 A July 24, 2017, 6:13 a.m. OK GNU C++11 TESTS 67 15 4505600 1600
28815830 corn_w A July 24, 2017, 6:13 a.m. OK GNU C++11 TESTS 67 15 4505600 1600
28803310 Nusratbek A July 23, 2017, 2:40 p.m. OK GNU C++11 TESTS 67 30 5529600 1600
28303421 zykzhenshuai A July 5, 2017, 12:12 p.m. OK GNU C++11 TESTS 67 30 6144000 1600
61780824 FlyingDreams A Oct. 3, 2019, 1:07 p.m. OK GNU C++11 TESTS 67 31 1638400 1600
51895186 mintCHILL A March 27, 2019, 11:15 a.m. OK GNU C++11 TESTS 67 31 1638400 1600
41992448 Axcosin A Aug. 23, 2018, 9:44 a.m. OK GNU C++11 TESTS 67 31 3072000 1600
24443690 TerenceLiu A Feb. 5, 2017, 1:43 a.m. OK GNU C++11 TESTS 67 31 3481600 1600
61685929 nico123 A Oct. 2, 2019, 3:48 a.m. OK GNU C++11 TESTS 67 31 3993600 1600
24396962 hellmakis2 A Feb. 2, 2017, 9:42 p.m. OK GNU C++14 TESTS 67 46 3481600 1600
26924095 vist0r A May 7, 2017, 1:13 p.m. OK GNU C++14 TESTS 67 46 4812800 1600
24377496 Egor.Lifar A Feb. 2, 2017, 2:22 p.m. OK GNU C++14 TESTS 67 46 7782400 1600
24371323 natsugiri A Feb. 2, 2017, 1:52 p.m. OK GNU C++14 TESTS 67 61 4710400 1600
24372659 .o. A Feb. 2, 2017, 1:56 p.m. OK GNU C++14 TESTS 67 61 5120000 1600
24382330 Xin-Jie A Feb. 2, 2017, 2:59 p.m. OK GNU C++14 TESTS 67 61 6451200 1600
30355814 HaiDang2001VN A Sept. 15, 2017, 2:50 a.m. OK GNU C++14 TESTS 67 62 1638400 1600
48037460 AMIT9019 A Jan. 6, 2019, 4:35 p.m. OK GNU C++14 TESTS 67 62 1843200 1600
61954713 Scut82 A Oct. 6, 2019, 5:26 a.m. OK GNU C++14 TESTS 67 62 2457600 1600
24481853 after A Feb. 7, 2017, 5:59 a.m. OK GNU C++14 TESTS 67 62 3072000 1600
66435781 thtsshz_bgwrswh A Dec. 7, 2019, 6:06 a.m. OK GNU C++17 TESTS 67 62 5222400 1600
66075005 diana.ghita.gd A Nov. 30, 2019, 10:22 p.m. OK GNU C++17 TESTS 67 62 12390400 1600
56700336 hjk1030 A July 8, 2019, 8:49 a.m. OK GNU C++17 TESTS 67 77 1228800 1600
52158954 Anunay1605 A April 1, 2019, 2:27 p.m. OK GNU C++17 TESTS 67 77 1536000 1600
44680765 vjudge4 A Oct. 22, 2018, 6:14 a.m. OK GNU C++17 TESTS 67 77 1638400 1600
49041114 vjudge1 A Jan. 27, 2019, 6:31 a.m. OK GNU C++17 TESTS 67 77 3072000 1600
59117645 vjudge1 A Aug. 20, 2019, 2:46 a.m. OK GNU C++17 TESTS 67 77 3584000 1600
47547834 vjudge1 A Dec. 27, 2018, 11:17 a.m. OK GNU C++17 TESTS 67 77 3993600 1600
47547823 vjudge1 A Dec. 27, 2018, 11:17 a.m. OK GNU C++17 TESTS 67 77 3993600 1600
54025233 SoGood A May 12, 2019, 12:11 p.m. OK GNU C++17 TESTS 67 77 5324800 1600
24584240 ichirin.2501 A Feb. 11, 2017, 7:23 a.m. OK Go TESTS 67 171 35737600 1600
66281922 shubh_jha98 A Dec. 4, 2019, 5:36 p.m. OK Java 11 TESTS 67 280 18329600 1600
45563019 ShowStopper728 A Nov. 11, 2018, 12:49 p.m. OK Java 8 TESTS 67 124 0 1600
65922870 pehchan_kaun A Nov. 28, 2019, 5:01 p.m. OK Java 8 TESTS 67 124 0 1600
40211261 tsumit023 A July 11, 2018, 7:53 p.m. OK Java 8 TESTS 67 124 0 1600
31730621 jay321 A Oct. 26, 2017, 6:58 a.m. OK Java 8 TESTS 67 124 0 1600
30244079 lm010 A Sept. 10, 2017, 11:38 a.m. OK Java 8 TESTS 67 140 0 1600
39540356 aman28rwt A June 23, 2018, 11:45 a.m. OK Java 8 TESTS 67 140 0 1600
31457718 prabhat236218 A Oct. 17, 2017, 6:43 p.m. OK Java 8 TESTS 67 140 60825600 1600
62411600 prem_cse A Oct. 12, 2019, 10:34 a.m. OK Java 8 TESTS 67 155 0 1600
48367264 Leendertz A Jan. 13, 2019, 11:57 p.m. OK Java 8 TESTS 67 155 0 1600
25223691 _Sergey_ A March 4, 2017, 6:11 p.m. OK Java 8 TESTS 67 155 20684800 1600
34035714 Detuned_radio A Jan. 8, 2018, 8:48 p.m. OK Kotlin TESTS 67 420 34201600 1600
63927917 hibatibati A Oct. 31, 2019, 1:32 p.m. OK Mono C# TESTS 67 202 24780800 1600
51158482 nemars A March 11, 2019, 11:15 a.m. OK Mono C# TESTS 67 218 27033600 1600
24421661 freepvps A Feb. 3, 2017, 10:52 p.m. OK MS C# TESTS 67 249 22732800 1600
24408319 pomjuice A Feb. 3, 2017, 11:15 a.m. OK MS C# TESTS 67 249 29593600 1600
24412940 pomjuice A Feb. 3, 2017, 2:29 p.m. OK MS C# TESTS 67 280 30208000 1600
46790541 vjudge4 A Dec. 9, 2018, 8:15 a.m. OK MS C++ TESTS 67 61 1638400 1600
44536533 vjudge2 A Oct. 19, 2018, 9:11 a.m. OK MS C++ TESTS 67 61 1843200 1600
54064685 WocBug A May 13, 2019, 12:51 p.m. OK MS C++ TESTS 67 62 1638400 1600
54179951 vjudge5 A May 15, 2019, 2:40 p.m. OK MS C++ TESTS 67 62 1638400 1600
49037621 vjudge3 A Jan. 27, 2019, 4:41 a.m. OK MS C++ TESTS 67 62 1843200 1600
24375697 Madball A Feb. 2, 2017, 2:12 p.m. OK MS C++ TESTS 67 62 3276800 1600
49036619 vjudge1 A Jan. 27, 2019, 3:48 a.m. OK MS C++ TESTS 67 62 3584000 1600
25341044 waterD A March 8, 2017, 12:32 p.m. OK MS C++ TESTS 67 62 4812800 1600
24370347 Perforator A Feb. 2, 2017, 1:49 p.m. OK MS C++ TESTS 67 62 5632000 1600
46686140 vjudge3 A Dec. 6, 2018, 2:06 p.m. OK MS C++ TESTS 67 62 7987200 1600
61118744 CtrlAlt A Sept. 23, 2019, 1:44 p.m. OK MS C++ 2017 TESTS 67 234 3174400 1600
65330820 yuanyuan2048 A Nov. 19, 2019, 5:56 a.m. OK MS C++ 2017 TESTS 67 249 3993600 1600
69602608 sergestus A Jan. 27, 2020, 8:23 a.m. OK MS C++ 2017 TESTS 67 265 4300800 1600
24395516 mayakin A Feb. 2, 2017, 8:15 p.m. OK PHP TESTS 67 202 34918400 1600
24369230 alexwice A Feb. 2, 2017, 1:46 p.m. OK PyPy 2 TESTS 67 482 57139200 1600
41648984 pavankatta A Aug. 16, 2018, 10:34 a.m. OK PyPy 2 TESTS 67 530 13619200 1600
27176282 bigobigo A May 17, 2017, 9:40 a.m. OK PyPy 2 TESTS 67 530 31641600 1600
30204979 iit2014101 A Sept. 8, 2017, 2:53 p.m. OK PyPy 2 TESTS 67 561 18432000 1600
49628869 soumyasarkar1998 A Feb. 8, 2019, 1:18 p.m. OK PyPy 2 TESTS 67 686 17510400 1600
38611955 Patiala_Peg A May 25, 2018, 2:33 p.m. OK PyPy 2 TESTS 67 717 18022400 1600
54917092 anshuman16423 A June 1, 2019, 2:27 p.m. OK PyPy 2 TESTS 67 873 15257600 1600
60145069 beched A Sept. 5, 2019, 11:05 p.m. OK PyPy 2 TESTS 67 873 33996800 1600
24389828 har_vi A Feb. 2, 2017, 4:55 p.m. OK PyPy 2 TESTS 67 1060 62054400 1600
46431618 homoeconomicus A Dec. 1, 2018, 6:04 a.m. OK PyPy 3 TESTS 67 966 18636800 1600
24372322 arknave A Feb. 2, 2017, 1:55 p.m. OK PyPy 3 TESTS 67 1029 39014400 1600
59812490 Hapsidra A Aug. 31, 2019, 2:05 p.m. OK PyPy 3 TESTS 67 1045 19660800 1600
60515101 kshitij_sodani A Sept. 14, 2019, 6:07 a.m. OK PyPy 3 TESTS 67 1092 24166400 1600
56451398 pfft A July 2, 2019, 10:55 p.m. OK PyPy 3 TESTS 67 1200 31539200 1600
27684552 mithi100 A June 9, 2017, 7:41 a.m. OK Python 2 TESTS 67 373 15052800 1600
24394187 andrevs A Feb. 2, 2017, 7:12 p.m. OK Python 2 TESTS 67 420 32358400 1600
25113775 whn6325689 A March 1, 2017, 2:50 a.m. OK Python 2 TESTS 67 436 16793600 1600
40929395 romil797 A July 29, 2018, 10:01 p.m. OK Python 2 TESTS 67 748 23552000 1600
24517483 nealzane A Feb. 8, 2017, 4:08 a.m. OK Python 2 TESTS 67 779 22630400 1600
28057417 FrontLever A June 26, 2017, 12:32 p.m. OK Python 2 TESTS 67 826 24166400 1600
26719181 almasip A April 28, 2017, 12:40 p.m. OK Python 3 TESTS 67 436 15872000 1600
40852304 orailly A July 27, 2018, 3:19 p.m. OK Python 3 TESTS 67 467 16998400 1600
26569080 merolish A April 21, 2017, 9:05 p.m. OK Python 3 TESTS 67 529 22323200 1600
42118946 Mk_Python_v1 A Aug. 26, 2018, 11:27 a.m. OK Python 3 TESTS 67 530 17203200 1600
24630744 wiwitrifai A Feb. 13, 2017, 3:21 p.m. OK Python 3 TESTS 67 592 21913600 1600
38974605 Paixao A June 5, 2018, 4:54 p.m. OK Python 3 TESTS 67 639 23244800 1600
24425661 shangtai A Feb. 4, 2017, 5:56 a.m. OK Python 3 TESTS 67 841 25190400 1600
24527906 ichirin.2501 A Feb. 8, 2017, 1:39 p.m. OK Python 3 TESTS 67 1279 28364800 1600

remove filters

Back to search problems