Codeforces Round 665 (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
1401 Codeforces Round 665 (Div. 2) FINISHED False 7200 139159463 Aug. 21, 2020, 2:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 9436 ) D Maximum Distributed Tree PROGRAMMING constructive algorithms dfs and similar greedy math number theory sortings trees

B"You are given a tree that consists of n nodes. You should label each of its n-1 edges with an integer in such way that satisfies the following conditions: Let's define f(u,v) as the sum of the numbers on the simple path from node u to node v . Also, let sum limits_{i=1}^{n-1} sum limits_{j=i+1}^n f(i,j) be a distribution index of the tree. Find the maximum possible distribution index you can get. Since answer can be too large, print it modulo 10^9 + 7 . In this problem, since the number k can be large, the result of the prime factorization of k is given instead. The first line contains one integer t ( 1 <= t <= 100 ) -- the number of test cases. The first line of each test case contains a single integer n ( 2 <= n <= 10^5 ) -- the number of nodes in the tree. Each of the next n-1 lines describes an edge: the i -th line contains two integers u_i and v_i ( 1 <= u_i, v_i <= n ; u_i ne v_i ) -- indices of vertices connected by the i -th edge. Next line contains a single integer m ( 1 <= m <= 6 cdot 10^4 ) -- the number of prime factors of k . Next line contains m prime numbers p_1, p_2, ldots, p_m ( 2 <= p_i < 6 cdot 10^4 ) such that k = p_1 cdot p_2 cdot ldots cdot p_m . It is guaranteed that the sum of n over all test cases doesn't exceed 10^5 , the sum of m over all test cases doesn't exceed 6 cdot 10^4 , and the given edges for each test cases form a tree. Print the maximum distribution index you can get. Since answer can be too large, print it modulo 10^9+7 . In the first test case, one of the optimal ways is on the following image: In this case, f(1,2)=1 , f(1,3)=3 , f(1,4)=5 , f(2,3)=2 , f(2,4)=4 , f(3,4)=2 , so the sum of these 6 numbers is 17 . In the second test case, one of the optimal ways is on the followin"...

Tutorials

Codeforces Round #665 (Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
90913373 yuanyuxuan D Aug. 25, 2020, 2:41 p.m. OK GNU C++11 TESTS 46 46 7987200
91095494 cwb_sb D Aug. 27, 2020, 12:21 a.m. OK GNU C++11 TESTS 46 46 8499200
91471790 Rayment D Aug. 31, 2020, 8:13 a.m. OK GNU C++11 TESTS 46 46 10240000
90889796 AC_yulou D Aug. 25, 2020, 10:18 a.m. OK GNU C++11 TESTS 46 46 10956800
91193085 coldiceh D Aug. 28, 2020, 8:47 a.m. OK GNU C++11 TESTS 46 46 11264000
91340111 Pan_H D Aug. 30, 2020, 12:02 p.m. OK GNU C++11 TESTS 46 46 18124800
91097550 LaiAng8086 D Aug. 27, 2020, 2:03 a.m. OK GNU C++11 TESTS 46 46 31948800
90892153 luogu_bot3 D Aug. 25, 2020, 10:53 a.m. OK GNU C++11 TESTS 46 46 40755200
91605868 hjh D Sept. 2, 2020, 2:06 a.m. OK GNU C++11 TESTS 46 46 68505600
91605861 luogu_bot2 D Sept. 2, 2020, 2:06 a.m. OK GNU C++11 TESTS 46 46 68505600
90867099 nitvjudge1 D Aug. 25, 2020, 4:25 a.m. OK GNU C++14 TESTS 46 77 15872000
90888856 ZUOG D Aug. 25, 2020, 10:05 a.m. OK GNU C++14 TESTS 46 93 6553600
91135697 ajinkya1p3 D Aug. 27, 2020, 1:15 p.m. OK GNU C++14 TESTS 46 93 9011200
91504315 ik_e D Aug. 31, 2020, 3:23 p.m. OK GNU C++14 TESTS 46 93 9318400
91107025 jinhb5518 D Aug. 27, 2020, 6:06 a.m. OK GNU C++14 TESTS 46 93 9728000
90873468 rohit7s D Aug. 25, 2020, 6:25 a.m. OK GNU C++14 TESTS 46 93 9728000
90880968 LM10_Piyush D Aug. 25, 2020, 8:11 a.m. OK GNU C++14 TESTS 46 93 10137600
91113228 EstebanOlmedo D Aug. 27, 2020, 7:42 a.m. OK GNU C++14 TESTS 46 93 10240000
91108695 Paradox512 D Aug. 27, 2020, 6:32 a.m. OK GNU C++14 TESTS 46 93 10342400
91523783 abhi2402 D Aug. 31, 2020, 8:51 p.m. OK GNU C++14 TESTS 46 93 10649600
91018304 ncu_HCS D Aug. 26, 2020, 5:10 a.m. OK GNU C++17 TESTS 46 62 11776000
91017688 ncu_HCS D Aug. 26, 2020, 4:58 a.m. OK GNU C++17 TESTS 46 62 11776000
90864093 eyesofgod123 D Aug. 25, 2020, 3:08 a.m. OK GNU C++17 TESTS 46 62 15872000
90990705 201831990439 D Aug. 25, 2020, 5:26 p.m. OK GNU C++17 TESTS 46 62 38707200
91015838 wir D Aug. 26, 2020, 4:21 a.m. OK GNU C++17 TESTS 46 78 7065600
91264649 DaoTa D Aug. 29, 2020, 7:27 a.m. OK GNU C++17 TESTS 46 78 8806400
91011107 Libra_Glow D Aug. 26, 2020, 2:32 a.m. OK GNU C++17 TESTS 46 78 10240000
91480913 _Clouder D Aug. 31, 2020, 10:20 a.m. OK GNU C++17 TESTS 46 78 13107200
91552704 sancpp D Sept. 1, 2020, 9:29 a.m. OK GNU C++17 TESTS 46 92 13209600
91192734 ACWING D Aug. 28, 2020, 8:42 a.m. OK GNU C++17 TESTS 46 93 7987200
91287394 caeious D Aug. 29, 2020, 1:24 p.m. OK GNU C++17 (64) TESTS 46 46 17305600
90905458 ivan100sic D Aug. 25, 2020, 2 p.m. OK GNU C++17 (64) TESTS 46 77 13516800
91274043 WiwiHo D Aug. 29, 2020, 9:53 a.m. OK GNU C++17 (64) TESTS 46 77 16281600
90825408 sherlock0502 D Aug. 24, 2020, 12:33 p.m. OK GNU C++17 (64) TESTS 46 78 19353600
90840430 knayan D Aug. 24, 2020, 3:39 p.m. OK GNU C++17 (64) TESTS 46 93 12390400
91603659 2sozx D Sept. 2, 2020, 12:14 a.m. OK GNU C++17 (64) TESTS 46 93 14540800
91075956 Bekh D Aug. 26, 2020, 4:39 p.m. OK GNU C++17 (64) TESTS 46 93 15257600
91542047 aiai_suki D Sept. 1, 2020, 6:47 a.m. OK GNU C++17 (64) TESTS 46 93 15360000
90903641 ksun48 D Aug. 25, 2020, 1:35 p.m. OK GNU C++17 (64) TESTS 46 93 17100800
91148485 Golden D Aug. 27, 2020, 3:49 p.m. OK GNU C++17 (64) TESTS 46 93 17612800
91078186 glebsamsonov D Aug. 26, 2020, 5:02 p.m. OK Go TESTS 46 156 40550400
90850450 kwangg D Aug. 24, 2020, 5:54 p.m. OK Go TESTS 46 234 56934400
91104970 enraged D Aug. 27, 2020, 5:29 a.m. OK Java 11 TESTS 46 358 25395200
91105530 enraged D Aug. 27, 2020, 5:40 a.m. OK Java 11 TESTS 46 374 31129600
90888199 yashkundu D Aug. 25, 2020, 9:54 a.m. OK Java 11 TESTS 46 374 44441600
91094219 mohitn D Aug. 26, 2020, 11:13 p.m. OK Java 11 TESTS 46 389 44646400
90903532 chris_11 D Aug. 25, 2020, 1:34 p.m. OK Java 11 TESTS 46 390 23961600
90854810 Kimo_Fathy D Aug. 24, 2020, 7:15 p.m. OK Java 11 TESTS 46 404 26214400
90847530 Apfeloxid D Aug. 24, 2020, 5:10 p.m. OK Java 11 TESTS 46 483 95641600
91256829 dubai03nsr D Aug. 29, 2020, 5:08 a.m. OK Java 11 TESTS 46 530 48025600
91279763 zorinermakov D Aug. 29, 2020, 11:20 a.m. OK Java 11 TESTS 46 545 37478400
90868641 Magikarp1 D Aug. 25, 2020, 4:58 a.m. OK Java 11 TESTS 46 561 48128000
91496292 JCKG D Aug. 31, 2020, 1:47 p.m. OK Java 8 TESTS 46 202 8499200
91002221 Okhair D Aug. 25, 2020, 8:35 p.m. OK Java 8 TESTS 46 311 22016000
91288853 icpc_loser D Aug. 29, 2020, 1:44 p.m. OK Java 8 TESTS 46 327 30515200
90814402 himmi_221 D Aug. 24, 2020, 9:58 a.m. OK Java 8 TESTS 46 343 51302400
91045750 shubho96 D Aug. 26, 2020, 11:31 a.m. OK Java 8 TESTS 46 358 27340800
91064304 lazypanda D Aug. 26, 2020, 2:45 p.m. OK Java 8 TESTS 46 358 28569600
90867511 punit1999 D Aug. 25, 2020, 4:35 a.m. OK Java 8 TESTS 46 358 29081600
91159200 coder_freak D Aug. 27, 2020, 6:04 p.m. OK Java 8 TESTS 46 358 29286400
91518291 mayankarora21 D Aug. 31, 2020, 6:47 p.m. OK Java 8 TESTS 46 358 29491200
91473818 Annvv D Aug. 31, 2020, 8:41 a.m. OK Java 8 TESTS 46 374 64409600
91010736 Spheniscine D Aug. 26, 2020, 2:20 a.m. OK Kotlin TESTS 46 249 14540800
90830610 tvvister D Aug. 24, 2020, 1:41 p.m. OK Mono C# TESTS 46 248 29491200
90826296 tvvister D Aug. 24, 2020, 12:45 p.m. OK Mono C# TESTS 46 265 29491200
91150259 MiuraMiuMiu D Aug. 27, 2020, 4:07 p.m. OK Mono C# TESTS 46 1435 23859200
91495778 scorpiowf D Aug. 31, 2020, 1:40 p.m. OK MS C++ 2017 TESTS 46 124 8396800
90882787 masterwater D Aug. 25, 2020, 8:36 a.m. OK MS C++ 2017 TESTS 46 249 12288000
91200550 dixmw34 D Aug. 28, 2020, 10:48 a.m. OK MS C++ 2017 TESTS 46 264 10649600
91203120 GreedyCoder999 D Aug. 28, 2020, 11:28 a.m. OK MS C++ 2017 TESTS 46 265 8396800
91200423 dixmw34 D Aug. 28, 2020, 10:46 a.m. OK MS C++ 2017 TESTS 46 1403 10649600
90904737 beethoven97 D Aug. 25, 2020, 1:51 p.m. OK PyPy 2 TESTS 46 514 25702400
90902951 marcus.aure D Aug. 25, 2020, 1:25 p.m. OK PyPy 3 TESTS 46 467 21708800
91271789 manikjain4 D Aug. 29, 2020, 9:19 a.m. OK PyPy 3 TESTS 46 467 27852800
91644039 meNoob D Sept. 2, 2020, 1:22 p.m. OK PyPy 3 TESTS 46 468 20684800
91591976 awasthishubh D Sept. 1, 2020, 6:17 p.m. OK PyPy 3 TESTS 46 545 20684800
90901828 forforfor D Aug. 25, 2020, 1:10 p.m. OK PyPy 3 TESTS 46 592 44953600
90841816 ibalram D Aug. 24, 2020, 3:56 p.m. OK PyPy 3 TESTS 46 608 101478400
91646280 slijk D Sept. 2, 2020, 1:50 p.m. OK PyPy 3 TESTS 46 623 32768000
91056321 mth1908 D Aug. 26, 2020, 1:28 p.m. OK PyPy 3 TESTS 46 763 53248000
91286939 YMSeah D Aug. 29, 2020, 1:17 p.m. OK PyPy 3 TESTS 46 841 45875200
91104654 enraged D Aug. 27, 2020, 5:22 a.m. OK PyPy 3 TESTS 46 842 51200000
91233730 Anvit D Aug. 28, 2020, 5:43 p.m. OK Python 3 TESTS 46 483 151552000
91064573 simran145 D Aug. 26, 2020, 2:48 p.m. OK Python 3 TESTS 46 498 151347200
91253238 h20191030154 D Aug. 29, 2020, 3:32 a.m. OK Python 3 TESTS 46 498 154112000
90880801 tycyd D Aug. 25, 2020, 8:09 a.m. OK Python 3 TESTS 46 607 130764800
91347738 hritik3878 D Aug. 30, 2020, 1:55 p.m. OK Python 3 TESTS 46 607 157286400
90822465 jaglike_makkar D Aug. 24, 2020, 11:53 a.m. OK Python 3 TESTS 46 608 154214400
90867508 kfm D Aug. 25, 2020, 4:34 a.m. OK Python 3 TESTS 46 732 19763200
90841848 ibalram D Aug. 24, 2020, 3:56 p.m. OK Python 3 TESTS 46 904 56320000
91141045 Strorkis D Aug. 27, 2020, 2:26 p.m. OK Rust TESTS 46 93 12800000
91114119 Chipe1 D Aug. 27, 2020, 7:54 a.m. OK Rust TESTS 46 109 10547200
91242653 pandrei D Aug. 28, 2020, 8:24 p.m. OK Rust TESTS 46 109 12492800
91112138 Chipe1 D Aug. 27, 2020, 7:26 a.m. OK Rust TESTS 46 124 11059200

remove filters

Back to search problems