Codeforces Round 896 (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
1868 Codeforces Round 896 (Div. 1) FINISHED False 9000 42825263 Sept. 10, 2023, 2:05 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 294 ) D Flower-like Pseudotree PROGRAMMING constructive algorithms graphs implementation trees

B'A pseudotree is a connected graph which has exactly one cycle and no self-loops. Note that a pseudotree may contain multiple-edges. It can be shown that a pseudotree with n vertices always contains n edges. After deleting all edges on the cycle in the pseudotree, a forest ^{ dagger} will be formed. It can be shown that each tree in the forest will contain exactly one vertex which is on cycle before removing the edges. If all trees in the forest have the same depth ^{ ddagger} when picking the vertex on cycle as root, we call the original pseudotree flower-like. Our friend sszcdjr, had a flower-like pseudotree with n vertices and n edges. However, he forgot all the edges in the pseudotree. Fortunately, he still remembers the degrees of vertices. Specifically, the degree of the i -th vertex is d_i . You have to help sszcdjr construct a possible flower-like pseudotree with n vertices, where the degree of the i -th vertex is exactly d_i , or tell him that it is impossible. ^{ dagger} A forest is a graph in which all connectivity components are trees. A connected graph without cycles and self-loops is called a tree. ^{ ddagger} The depth of a tree with a root is the maximum distance from the root to the vertex of this tree. The first line of the input contains a single integer t ( 1 <= q t <= q 10^5 ) -- the number of test cases. The description of test cases follows. The first line of each test case contains a single integer n ( 2 <= q n <= q 10^6 ) -- the number of vertices. The second line of each test case contains n integers d_1,d_2, ldots,d_n ( 1 <= q d_i <= q n ) -- the degree of each vertex. It is guaranteed that the sum of n over all test cases does not exceed 10^6 . For each test case, if there exist a possible flower-like pseudotree: If there are multiple answers, you may output any of them. Otherwise, print "No" (without quotes) in the'...

Tutorials

Codeforces Round 896 (Div. 1, Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
222844022 Harry27182 D Sept. 11, 2023, 2:11 a.m. OK GNU C++14 TESTS 78 639 11980800
222843595 ITworker_Z D Sept. 11, 2023, 2:03 a.m. OK GNU C++17 TESTS 78 140 28057600
222844124 Licha06 D Sept. 11, 2023, 2:13 a.m. OK GNU C++17 TESTS 78 530 54988800
222809414 tzc_wk D Sept. 10, 2023, 5:26 p.m. OK GNU C++17 TESTS 78 545 24780800
222845344 Misono_Mika D Sept. 11, 2023, 2:38 a.m. OK GNU C++17 TESTS 78 561 23961600
222808444 Nachia D Sept. 10, 2023, 5:20 p.m. OK GNU C++17 TESTS 78 577 35532800
222838265 patou D Sept. 11, 2023, 12:02 a.m. OK GNU C++17 TESTS 78 592 16076800
222780261 Farhod_Farmon D Sept. 10, 2023, 3:42 p.m. OK GNU C++17 TESTS 78 607 20480000
222819512 potato167 D Sept. 10, 2023, 6:44 p.m. OK GNU C++17 TESTS 78 607 28979200
222833017 km_zakaria_alam D Sept. 10, 2023, 9:41 p.m. OK GNU C++17 TESTS 78 608 20480000
222829407 null_awe D Sept. 10, 2023, 8:39 p.m. OK GNU C++17 TESTS 78 623 17920000
222841263 Alex_Wei D Sept. 11, 2023, 1:13 a.m. OK GNU C++17 (64) TESTS 78 389 20377600
222844332 wsyear D Sept. 11, 2023, 2:17 a.m. OK GNU C++17 (64) TESTS 78 404 50995200
222795823 hitonanode D Sept. 10, 2023, 4:14 p.m. OK GNU C++17 (64) TESTS 78 421 24473600
222808982 triple__a D Sept. 10, 2023, 5:23 p.m. OK GNU C++17 (64) TESTS 78 452 32665600
222782980 YamadaRyo D Sept. 10, 2023, 3:49 p.m. OK GNU C++17 (64) TESTS 78 483 46899200
222793420 heno239 D Sept. 10, 2023, 4:08 p.m. OK GNU C++17 (64) TESTS 78 514 53145600
222810780 kotatsugame D Sept. 10, 2023, 5:35 p.m. OK GNU C++17 (64) TESTS 78 529 18944000
222800103 Geothermal D Sept. 10, 2023, 4:24 p.m. OK GNU C++17 (64) TESTS 78 561 11980800
222799384 353cerega D Sept. 10, 2023, 4:23 p.m. OK GNU C++17 (64) TESTS 78 592 72192000
222793980 noimi D Sept. 10, 2023, 4:09 p.m. OK GNU C++17 (64) TESTS 78 670 61644800
222840273 cmk666 D Sept. 11, 2023, 12:50 a.m. OK GNU C++20 (64) TESTS 78 140 21196800
222811099 shiomusubi496 D Sept. 10, 2023, 5:37 p.m. OK GNU C++20 (64) TESTS 78 187 18022400
222844861 ClHg2 D Sept. 11, 2023, 2:28 a.m. OK GNU C++20 (64) TESTS 78 296 7987200
222837925 Lynkcat D Sept. 10, 2023, 11:51 p.m. OK GNU C++20 (64) TESTS 78 327 23449600
222826023 BalintR D Sept. 10, 2023, 7:55 p.m. OK GNU C++20 (64) TESTS 78 327 25702400
222848643 feeder1 D Sept. 11, 2023, 3:45 a.m. OK GNU C++20 (64) TESTS 78 327 25804800
222822047 Snow-Flower D Sept. 10, 2023, 7:10 p.m. OK GNU C++20 (64) TESTS 78 327 27852800
222822487 KevinWan D Sept. 10, 2023, 7:15 p.m. OK GNU C++20 (64) TESTS 78 327 45977600
222808858 dl720125 D Sept. 10, 2023, 5:22 p.m. OK GNU C++20 (64) TESTS 78 342 42188800
222807970 sjc061031 D Sept. 10, 2023, 5:18 p.m. OK GNU C++20 (64) TESTS 78 342 42188800
222795503 FastFreeTask D Sept. 10, 2023, 4:13 p.m. OK Kotlin 1.6 TESTS 78 1092 151756800

remove filters

Back to search problems