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 |
---|---|---|---|---|---|---|
1762 | Codeforces Round 838 (Div. 2) | FINISHED | False | 9000 | 66151463 | Dec. 15, 2022, 2:35 p.m. |
Solved$ |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
---|---|---|---|---|---|---|
( 698 ) | E | Tree Sum | PROGRAMMING | combinatorics trees |
B"Let us call an edge-weighted tree with n vertices numbered from 1 to n good if the weight of each edge is either 1 or -1 and for each vertex i , the product of the edge weights of all edges having i as one endpoint is -1 . You are given a positive integer n . There are n^{n-2} cdot 2^{n-1} distinct ^ dagger edge-weighted trees with n vertices numbered from 1 to n such that each edge is either 1 or -1 . Your task is to find the sum of d(1,n)^ ddagger of all such trees that are good. Since the answer can be quite large, you only need to find it modulo 998 ,244 ,353 . ^ dagger Two trees are considered to be distinct if either: Note that by Cayley's formula, the number of trees on n labeled vertices is n^{n-2} . Since we have n-1 edges, there are 2^{n-1} possible assignment of weights(weight can either be 1 or -1 ). That is why total number of distinct edge-weighted tree is n^{n-2} cdot 2^{n-1} . ^ ddagger d(u,v) denotes the sum of the weight of all edges on the unique simple path from u to v . The first and only line of input contains a single integer n ( 1 <= q n <= q 5 cdot 10^5 ). The only line of output should contain a single integer, the required answer, modulo 998 ,244 ,353 . In the first test case, there is only 1 distinct good tree. The value of d(1,2) for that tree is -1 , which is 998 ,244 ,352 under modulo 998 ,244 ,353 . In the second test case, the value of d(1,1) for any tree is 0 , so the answer is 0 . In the third test case, there are 16 distinct good trees. The value of d(1,4) is: The sum of d(1,4) over all trees is 2 cdot (-2) + 8 cdot (-1) + 4 cdot (0) + 2 cdot (1) = -10 , which is 998 ,244 ,343 under modulo 998 ,244 ,353 . "... |
Codeforces Round #838 (Div. 2) Editorial |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
---|---|---|---|---|---|---|---|---|---|---|---|
185407824 | YeahPotato | E | Dec. 16, 2022, 3:10 a.m. | OK | GNU C++14 | TESTS | 25 | 265 | 2048000 | ||
185410977 | Yzm007 | E | Dec. 16, 2022, 4:16 a.m. | OK | GNU C++14 | TESTS | 25 | 265 | 3993600 | ||
185410179 | The-Fourth-Pole | E | Dec. 16, 2022, 4:03 a.m. | OK | GNU C++14 | TESTS | 25 | 265 | 3993600 | ||
185372433 | Wangxueyi | E | Dec. 15, 2022, 5:29 p.m. | OK | GNU C++14 | TESTS | 25 | 296 | 3993600 | ||
185361566 | zhaotiensn | E | Dec. 15, 2022, 4:41 p.m. | OK | GNU C++14 | TESTS | 25 | 296 | 3993600 | ||
185408258 | zhaohaikun | E | Dec. 16, 2022, 3:20 a.m. | OK | GNU C++14 | TESTS | 25 | 296 | 6041600 | ||
185404755 | mirror233 | E | Dec. 16, 2022, 1:52 a.m. | OK | GNU C++14 | TESTS | 25 | 296 | 7987200 | ||
185407529 | Pointy | E | Dec. 16, 2022, 3:02 a.m. | OK | GNU C++14 | TESTS | 25 | 296 | 10035200 | ||
185406887 | wsday | E | Dec. 16, 2022, 2:46 a.m. | OK | GNU C++14 | TESTS | 25 | 296 | 11980800 | ||
185372109 | gubeiqg | E | Dec. 15, 2022, 5:28 p.m. | OK | GNU C++14 | TESTS | 25 | 342 | 16076800 | ||
185367555 | whker_kzc | E | Dec. 15, 2022, 4:59 p.m. | OK | GNU C++17 | TESTS | 25 | 156 | 11980800 | ||
185387370 | tick | E | Dec. 15, 2022, 7:34 p.m. | OK | GNU C++17 | TESTS | 25 | 171 | 6041600 | ||
185372926 | Cxny | E | Dec. 15, 2022, 5:31 p.m. | OK | GNU C++17 | TESTS | 25 | 187 | 11980800 | ||
185374381 | toooooosimple | E | Dec. 15, 2022, 5:40 p.m. | OK | GNU C++17 | TESTS | 25 | 280 | 3993600 | ||
185393781 | Peti | E | Dec. 15, 2022, 8:58 p.m. | OK | GNU C++17 | TESTS | 25 | 295 | 8396800 | ||
185409862 | walk_alone | E | Dec. 16, 2022, 3:56 a.m. | OK | GNU C++17 | TESTS | 25 | 296 | 7987200 | ||
185402860 | im.priyansh | E | Dec. 16, 2022, 12:57 a.m. | OK | GNU C++17 | TESTS | 25 | 405 | 7987200 | ||
185402731 | im.priyansh | E | Dec. 16, 2022, 12:53 a.m. | OK | GNU C++17 | TESTS | 25 | 405 | 7987200 | ||
185392670 | KrK | E | Dec. 15, 2022, 8:42 p.m. | OK | GNU C++17 | TESTS | 25 | 436 | 3993600 | ||
185385214 | Dhruvil_Kakadiya | E | Dec. 15, 2022, 7:09 p.m. | OK | GNU C++17 | TESTS | 25 | 483 | 7987200 | ||
185404684 | yzc2005 | E | Dec. 16, 2022, 1:50 a.m. | OK | GNU C++17 (64) | TESTS | 25 | 46 | 3993600 | ||
185403774 | JoesSR | E | Dec. 16, 2022, 1:24 a.m. | OK | GNU C++17 (64) | TESTS | 25 | 61 | 24064000 | ||
185372552 | nweeks | E | Dec. 15, 2022, 5:30 p.m. | OK | GNU C++17 (64) | TESTS | 25 | 62 | 10035200 | ||
185405611 | VegeDog | E | Dec. 16, 2022, 2:15 a.m. | OK | GNU C++17 (64) | TESTS | 25 | 62 | 11980800 | ||
185390581 | Origenes | E | Dec. 15, 2022, 8:13 p.m. | OK | GNU C++17 (64) | TESTS | 25 | 78 | 4096000 | ||
185378109 | Kude | E | Dec. 15, 2022, 6:07 p.m. | OK | GNU C++17 (64) | TESTS | 25 | 78 | 7987200 | ||
185362175 | ttttan | E | Dec. 15, 2022, 4:43 p.m. | OK | GNU C++17 (64) | TESTS | 25 | 78 | 18022400 | ||
185371716 | foreverlasting | E | Dec. 15, 2022, 5:26 p.m. | OK | GNU C++17 (64) | TESTS | 25 | 93 | 2048000 | ||
185414535 | propane | E | Dec. 16, 2022, 5:13 a.m. | OK | GNU C++17 (64) | TESTS | 25 | 93 | 3993600 | ||
185406946 | Alex_Wei | E | Dec. 16, 2022, 2:47 a.m. | OK | GNU C++17 (64) | TESTS | 25 | 93 | 3993600 | ||
185412570 | erray | E | Dec. 16, 2022, 4:43 a.m. | OK | GNU C++20 (64) | TESTS | 25 | 46 | 6041600 | ||
185383384 | AndreyPavlov | E | Dec. 15, 2022, 6:50 p.m. | OK | GNU C++20 (64) | TESTS | 25 | 46 | 12083200 | ||
185401239 | cmk666 | E | Dec. 16, 2022, 12:05 a.m. | OK | GNU C++20 (64) | TESTS | 25 | 61 | 6041600 | ||
185403210 | Zesty_Fox | E | Dec. 16, 2022, 1:07 a.m. | OK | GNU C++20 (64) | TESTS | 25 | 62 | 11980800 | ||
185362970 | Fysty | E | Dec. 15, 2022, 4:46 p.m. | OK | GNU C++20 (64) | TESTS | 25 | 62 | 12083200 | ||
185380671 | pakhandi98 | E | Dec. 15, 2022, 6:26 p.m. | OK | GNU C++20 (64) | TESTS | 25 | 62 | 20070400 | ||
185377348 | Gorgo | E | Dec. 15, 2022, 6:01 p.m. | OK | GNU C++20 (64) | TESTS | 25 | 62 | 21606400 | ||
185407480 | wsyear | E | Dec. 16, 2022, 3:01 a.m. | OK | GNU C++20 (64) | TESTS | 25 | 78 | 3993600 | ||
185374891 | dmenezes | E | Dec. 15, 2022, 5:43 p.m. | OK | GNU C++20 (64) | TESTS | 25 | 78 | 3993600 | ||
185405057 | zqyyy | E | Dec. 16, 2022, 2 a.m. | OK | GNU C++20 (64) | TESTS | 25 | 78 | 5017600 | ||
185412616 | toam | E | Dec. 16, 2022, 4:43 a.m. | OK | PyPy 3-64 | TESTS | 25 | 233 | 16076800 |
Back to search problems