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 |
|---|---|---|---|---|---|---|
| 869 | Codeforces Round 439 (Div. 2) | FINISHED | False | 7200 | 269108723 | Oct. 6, 2017, 1:35 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 278 ) | D | The Overdosing Ubiquity | PROGRAMMING | brute force dfs and similar graphs | 2800 |
The fundamental prerequisite for justice is not to be correct, but to be strong. That's why justice is always the victor. The Cinderswarm Bee. Koyomi knows it. The bees, according to their nature, live in a tree. To be more specific, a complete binary tree with n nodes numbered from 1 to n . The node numbered 1 is the root, and the parent of the i -th ( 2 ≤ i ≤ n ) node is . Note that, however, all edges in the tree are undirected. Koyomi adds m extra undirected edges to the tree, creating more complication to trick the bees. And you're here to count the number of simple paths in the resulting graph, modulo 10 9 + 7 . A simple path is an alternating sequence of adjacent nodes and undirected edges, which begins and ends with nodes and does not contain any node more than once. Do note that a single node is also considered a valid simple path under this definition. Please refer to the examples and notes below for instances. The first line of input contains two space-separated integers n and m ( 1 ≤ n ≤ 10 9 , 0 ≤ m ≤ 4 ) — the number of nodes in the tree and the number of extra edges respectively. The following m lines each contains two space-separated integers u and v ( 1 ≤ u , v ≤ n , u ≠ v ) — describing an undirected extra edge whose endpoints are u and v . Note that there may be multiple edges between nodes in the resulting graph. Output one integer — the number of simple paths in the resulting graph, modulo 10 9 + 7 . In the first example, the paths are: (1) ; (2) ; (3) ; (1, 2) ; (2, 1) ; (1, 3) ; (3, 1) ; (2, 1, 3) ; (3, 1, 2) . (For the sake of clarity, the edges between nodes are omitted since there are no multiple edges in this case.) In the second example, the paths are: (1) ; (1, 2) ; (1, 2, 3) ; (1, 3) ; (1, 3, 2) ; and similarly for paths starting with 2 and 3 . ( 5 × 3 = 15 paths in total.) In the third example, the paths are: (1) ; (2) ; any undirected edge connecting the two nodes travelled in either direction. ( 2 + 5 × 2 = 12 paths in tota |
| Tutorial |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 35590715 | yukuai26 | D | Feb. 23, 2018, 7:45 a.m. | OK | GNU C++ | TESTS | 100 | 15 | 30105600 | 2800 | |
| 34949969 | vjudge4 | D | Feb. 5, 2018, 4:44 p.m. | OK | GNU C++ | TESTS | 100 | 15 | 134348800 | 2800 | |
| 34005353 | vjudge2 | D | Jan. 8, 2018, 2:15 p.m. | OK | GNU C++ | TESTS | 100 | 15 | 134348800 | 2800 | |
| 31219327 | Unreal | D | Oct. 11, 2017, 2:37 p.m. | OK | GNU C++ | TESTS | 100 | 30 | 716800 | 2800 | |
| 31952906 | vjudge2 | D | Nov. 1, 2017, 2:13 p.m. | OK | GNU C++ | TESTS | 100 | 31 | 0 | 2800 | |
| 31848081 | vjudge2 | D | Oct. 28, 2017, 6:39 p.m. | OK | GNU C++ | TESTS | 100 | 31 | 0 | 2800 | |
| 32775055 | vjudge2 | D | Nov. 29, 2017, 8:22 a.m. | OK | GNU C++ | TESTS | 100 | 31 | 2252800 | 2800 | |
| 37286763 | Trisolaris | D | April 13, 2018, 1:44 p.m. | OK | GNU C++ | TESTS | 100 | 31 | 3481600 | 2800 | |
| 38059655 | itsinuse | D | May 9, 2018, 3:31 a.m. | OK | GNU C++ | TESTS | 100 | 31 | 3584000 | 2800 | |
| 35590737 | vjudge3 | D | Feb. 23, 2018, 7:46 a.m. | OK | GNU C++ | TESTS | 100 | 31 | 30105600 | 2800 | |
| 31808697 | vjudge4 | D | Oct. 27, 2017, 3:33 p.m. | OK | GNU C++11 | TESTS | 100 | 15 | 0 | 2800 | |
| 31193588 | yezq3 | D | Oct. 10, 2017, 3:17 p.m. | OK | GNU C++11 | TESTS | 100 | 15 | 0 | 2800 | |
| 31117407 | Maniac_Wallnut | D | Oct. 7, 2017, 1:58 p.m. | OK | GNU C++11 | TESTS | 100 | 15 | 0 | 2800 | |
| 33976971 | zhouyuyang | D | Jan. 7, 2018, 6 a.m. | OK | GNU C++11 | TESTS | 100 | 15 | 2048000 | 2800 | |
| 31473424 | sjtsjt | D | Oct. 18, 2017, 8:21 a.m. | OK | GNU C++11 | TESTS | 100 | 15 | 2048000 | 2800 | |
| 35590131 | emoairx | D | Feb. 23, 2018, 7:05 a.m. | OK | GNU C++11 | TESTS | 100 | 15 | 2150400 | 2800 | |
| 35588955 | nn020701 | D | Feb. 23, 2018, 5:41 a.m. | OK | GNU C++11 | TESTS | 100 | 15 | 2150400 | 2800 | |
| 31415346 | vjudge1 | D | Oct. 16, 2017, 2:52 p.m. | OK | GNU C++11 | TESTS | 100 | 15 | 2150400 | 2800 | |
| 31267543 | Never_See | D | Oct. 13, 2017, 7:28 a.m. | OK | GNU C++11 | TESTS | 100 | 15 | 4096000 | 2800 | |
| 33804202 | jslijin | D | Dec. 30, 2017, 8:19 a.m. | OK | GNU C++11 | TESTS | 100 | 15 | 5529600 | 2800 | |
| 31135123 | mishobaxa1234 | D | Oct. 8, 2017, 6:49 a.m. | OK | GNU C++14 | TESTS | 100 | 15 | 204800 | 2800 | |
| 31112113 | MasterLuke | D | Oct. 7, 2017, 11:25 a.m. | OK | GNU C++14 | TESTS | 100 | 15 | 204800 | 2800 | |
| 34623982 | otrecnoc | D | Jan. 28, 2018, 5:27 a.m. | OK | GNU C++14 | TESTS | 100 | 15 | 2048000 | 2800 | |
| 35611812 | fangbo | D | Feb. 23, 2018, 11:43 p.m. | OK | GNU C++14 | TESTS | 100 | 15 | 2150400 | 2800 | |
| 35590799 | jzqjzq | D | Feb. 23, 2018, 7:51 a.m. | OK | GNU C++14 | TESTS | 100 | 15 | 7680000 | 2800 | |
| 31269125 | I_Love_Umirzhanova_Amina | D | Oct. 13, 2017, 8:47 a.m. | OK | GNU C++14 | TESTS | 100 | 30 | 204800 | 2800 | |
| 32740171 | Rejur | D | Nov. 28, 2017, 4:45 a.m. | OK | GNU C++14 | TESTS | 100 | 30 | 2150400 | 2800 | |
| 34253428 | vjudge5 | D | Jan. 17, 2018, 1:51 p.m. | OK | GNU C++14 | TESTS | 100 | 30 | 3276800 | 2800 | |
| 44008113 | xsc | D | Oct. 8, 2018, 4:52 p.m. | OK | GNU C++14 | TESTS | 100 | 31 | 204800 | 2800 | |
| 40979557 | ReaLNero1 | D | July 30, 2018, 5:08 p.m. | OK | GNU C++14 | TESTS | 100 | 31 | 204800 | 2800 | |
| 35293885 | comevaha | D | Feb. 15, 2018, 1:57 p.m. | OK | GNU C++17 | TESTS | 100 | 15 | 2048000 | 2800 | |
| 52233722 | Trisolaris | D | April 2, 2019, 12:57 p.m. | OK | GNU C++17 | TESTS | 100 | 31 | 102400 | 2800 | |
| 53733510 | zhongyuwei | D | May 4, 2019, 8:20 a.m. | OK | GNU C++17 | TESTS | 100 | 31 | 204800 | 2800 | |
| 53732169 | JZmster | D | May 4, 2019, 7:44 a.m. | OK | GNU C++17 | TESTS | 100 | 31 | 204800 | 2800 | |
| 39409134 | Ali_Pi | D | June 19, 2018, 11:41 a.m. | OK | GNU C++17 | TESTS | 100 | 31 | 204800 | 2800 | |
| 69427909 | hjk1030 | D | Jan. 23, 2020, 4:23 p.m. | OK | GNU C++17 | TESTS | 100 | 46 | 307200 | 2800 | |
| 54277840 | Night | D | May 17, 2019, noon | OK | GNU C++17 | TESTS | 100 | 62 | 204800 | 2800 | |
| 52807462 | Jester | D | April 16, 2019, 6:08 a.m. | OK | GNU C++17 | TESTS | 100 | 109 | 204800 | 2800 | |
| 48547138 | Shayan.P | D | Jan. 18, 2019, 8:23 p.m. | OK | GNU C++17 | TESTS | 100 | 265 | 409600 | 2800 | |
| 48547174 | Shayan.P | D | Jan. 18, 2019, 8:24 p.m. | OK | GNU C++17 | TESTS | 100 | 296 | 409600 | 2800 | |
| 31164308 | donli | D | Oct. 9, 2017, 10:21 a.m. | OK | Java 8 | TESTS | 100 | 124 | 0 | 2800 | |
| 31092166 | uwi | D | Oct. 6, 2017, 7:50 p.m. | OK | Java 8 | TESTS | 100 | 124 | 0 | 2800 | |
| 34064857 | tmwilliamlin168 | D | Jan. 10, 2018, 8:27 a.m. | OK | Java 8 | TESTS | 100 | 171 | 20787200 | 2800 | |
| 33528610 | JialinOuyang | D | Dec. 23, 2017, 7:17 a.m. | OK | Java 8 | TESTS | 100 | 187 | 21401600 | 2800 |
Back to search problems