Codeforces Round 539 (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
1109 Codeforces Round 539 (Div. 1) FINISHED False 9000 186845063 Feb. 16, 2019, 4:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 1365 ) D Sasha and Interesting Fact from Graph Theory PROGRAMMING brute force combinatorics dp math trees 2600

B"Once, during a lesson, Sasha got bored and decided to talk with his friends. Suddenly, he saw Kefa. Since we can talk endlessly about Kefa, we won't even start doing that. The conversation turned to graphs. Kefa promised Sasha to tell him about one interesting fact from graph theory if Sasha helps Kefa to count the number of beautiful trees. In this task, a tree is a weighted connected graph, consisting of n vertices and n-1 edges, and weights of edges are integers from 1 to m . Kefa determines the beauty of a tree as follows: he finds in the tree his two favorite vertices -- vertices with numbers a and b , and counts the distance between them. The distance between two vertices x and y is the sum of weights of edges on the simple path from x to y . If the distance between two vertices a and b is equal to m , then the tree is beautiful. Sasha likes graph theory, and even more, Sasha likes interesting facts, that's why he agreed to help Kefa. Luckily, Sasha is familiar with you the best programmer in Byteland. Help Sasha to count the number of beautiful trees for Kefa. Two trees are considered to be distinct if there is an edge that occurs in one of them and doesn't occur in the other one. Edge's weight matters. Kefa warned Sasha, that there can be too many beautiful trees, so it will be enough to count the number modulo 10^9 + 7 . The first line contains four integers n , m , a , b ( 2 <= n <= 10^6 , 1 <= m <= 10^6 , 1 <= a, b <= n , a neq b ) -- the number of vertices in the tree, the maximum weight of an edge and two Kefa's favorite vertices. Print one integer -- the number of beautiful trees modulo 10^9+7 . There are 5 beautiful trees in the first example: In the second example the following trees are beautiful: "...

Tutorials

Codeforces Round #539 Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
50497986 rainboy D Feb. 25, 2019, 3:58 p.m. OK GNU C11 TESTS 30 639 32051200 2600
52007950 code_struck D March 30, 2019, 8:15 a.m. OK GNU C++11 TESTS 30 93 24064000 2600
51896190 luogu_bot4 D March 27, 2019, 11:40 a.m. OK GNU C++11 TESTS 30 108 16076800 2600
50662480 Siyuan D March 2, 2019, 12:57 a.m. OK GNU C++11 TESTS 30 109 15872000 2600
51896178 Mirach D March 27, 2019, 11:39 a.m. OK GNU C++11 TESTS 30 109 16076800 2600
50047701 JKLover D Feb. 17, 2019, 6:49 a.m. OK GNU C++11 TESTS 30 109 16076800 2600
57715441 fancycoser D July 25, 2019, 2:28 a.m. OK GNU C++11 TESTS 30 109 16076800 2600
68915153 geneanlyz D Jan. 16, 2020, 8:21 a.m. OK GNU C++11 TESTS 30 109 17408000 2600
52372425 Minamoto D April 6, 2019, 6:49 a.m. OK GNU C++11 TESTS 30 124 7987200 2600
52374948 Minamoto D April 6, 2019, 7:52 a.m. OK GNU C++11 TESTS 30 124 8089600 2600
50306236 Scut82 D Feb. 22, 2019, 6:20 a.m. OK GNU C++11 TESTS 30 124 12185600 2600
50409708 hometop D Feb. 24, 2019, 1:06 a.m. OK GNU C++14 TESTS 30 93 20070400 2600
52226545 RNS_CUS D April 2, 2019, 9:48 a.m. OK GNU C++14 TESTS 30 108 7987200 2600
50015308 Madball D Feb. 16, 2019, 5:24 p.m. OK GNU C++14 TESTS 30 109 16076800 2600
50145584 mobu233 D Feb. 19, 2019, 3:41 a.m. OK GNU C++14 TESTS 30 109 16076800 2600
50583337 Dreamless_Dreams D Feb. 28, 2019, 12:16 a.m. OK GNU C++14 TESTS 30 124 7987200 2600
50420150 apiadu D Feb. 24, 2019, 8:36 a.m. OK GNU C++14 TESTS 30 124 16076800 2600
50015554 kdh9949 D Feb. 16, 2019, 5:25 p.m. OK GNU C++14 TESTS 30 124 32051200 2600
50102317 Szki D Feb. 18, 2019, 3:31 p.m. OK GNU C++14 TESTS 30 124 32051200 2600
50063930 zhou888 D Feb. 17, 2019, 1:55 p.m. OK GNU C++14 TESTS 30 139 16076800 2600
50062768 smtcoder D Feb. 17, 2019, 1:26 p.m. OK GNU C++14 TESTS 30 139 16076800 2600
50305140 Trisolaris D Feb. 22, 2019, 5:39 a.m. OK GNU C++17 TESTS 30 93 3993600 2600
50036394 neal D Feb. 16, 2019, 9:03 p.m. OK GNU C++17 TESTS 30 108 20070400 2600
51120238 ialakhtin D March 10, 2019, 8:54 a.m. OK GNU C++17 TESTS 30 109 12083200 2600
50229466 Dance_Of_Faith D Feb. 20, 2019, 8:35 a.m. OK GNU C++17 TESTS 30 109 16076800 2600
50026360 maximumSHOT D Feb. 16, 2019, 6:18 p.m. OK GNU C++17 TESTS 30 109 16076800 2600
51065511 luogu_bot5 D March 9, 2019, 5:41 a.m. OK GNU C++17 TESTS 30 124 15974400 2600
65773055 Hikori D Nov. 26, 2019, 7:47 p.m. OK GNU C++17 TESTS 30 124 16076800 2600
58660855 huangyaxuan D Aug. 12, 2019, 10:52 a.m. OK GNU C++17 TESTS 30 124 16076800 2600
50703629 bert30702 D March 3, 2019, 1:25 a.m. OK GNU C++17 TESTS 30 124 32051200 2600
50032496 mareksom D Feb. 16, 2019, 6:59 p.m. OK GNU C++17 TESTS 30 139 16076800 2600
50039932 flyman3046 D Feb. 17, 2019, 12:39 a.m. OK Java 8 TESTS 30 296 38400000 2600
50016355 niyaznigmatul D Feb. 16, 2019, 5:28 p.m. OK Java 8 TESTS 30 1169 22323200 2600
50497985 Dukkha D Feb. 25, 2019, 3:58 p.m. OK Java 8 TESTS 30 1294 38297600 2600
66446588 dalt D Dec. 7, 2019, 9:53 a.m. OK Java 8 TESTS 30 1575 40652800 2600
50049436 darnley D Feb. 17, 2019, 7:28 a.m. OK Java 8 TESTS 30 1653 0 2600
55848805 darnley D June 21, 2019, 1:26 a.m. OK Java 8 TESTS 30 1669 0 2600
50031698 darnley D Feb. 16, 2019, 6:54 p.m. OK Java 8 TESTS 30 1855 0 2600
50043087 hieutrungle D Feb. 17, 2019, 3:45 a.m. OK Java 8 TESTS 30 1949 15360000 2600
50037968 PrakharJain D Feb. 16, 2019, 10:17 p.m. OK Java 8 TESTS 30 2074 54272000 2600
57721698 vjudge4 D July 25, 2019, 5:41 a.m. OK MS C++ TESTS 30 202 32051200 2600
57724187 vjudge4 D July 25, 2019, 6:38 a.m. OK MS C++ TESTS 30 935 16076800 2600
61347532 vjudge4 D Sept. 27, 2019, 6:02 a.m. OK MS C++ TESTS 30 1138 7987200 2600
50020493 aeremin D Feb. 16, 2019, 5:47 p.m. OK MS C++ 2017 TESTS 30 264 48128000 2600

remove filters

Back to search problems