Codeforces Round 993 (Div. 4)

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
2044 Codeforces Round 993 (Div. 4) FINISHED False 8100 42132323 Dec. 15, 2024, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 3796 ) G2 Medium Demon Problem (hard version) PROGRAMMING dfs and similar dp dsu graphs implementation trees

This is the hard version of the problem. The key difference between the two versions is highlighted in bold. A group of (n) spiders has come together to exchange plushies. Initially, each spider has (1) plushie. Every year, if spider (i) has at least one plushie, he will give exactly one plushie to spider (r_i). Otherwise, he will do nothing. Note that all plushie transfers happen at the same time. In this version, each spider is allowed to have more than 1 plushie at any point in time. The process is stable in the current year if each spider has the same number of plushies (before the current year's exchange) as he did the previous year (before the previous year's exchange). Note that year (1) can never be stable . Find the first year in which the process becomes stable . The first line contains an integer (t) ((1 \leq t \leq 10^4)) — the number of test cases. The first line of each test case contains an integer (n) ((2 \leq n \leq 2 \cdot 10^5)) — the number of spiders. The following line contains (n) integers (r_1, r_2, \ldots, r_n) ((1 \leq r_i \leq n, r_i \neq i)) — the recipient of the plushie of each spider. It is guaranteed that the sum of (n) over all test cases does not exceed (2 \cdot 10^5). For each test case, output an integer on a new line, the first year in which the process becomes stable . For the second test case: At year (1), the following array shows the number of plushies each spider has: (1, 1, 1, 1, 1). Then, year (1)'s exchange happens. At year (2), the following array shows the number of plushies each spider has: (1, 1, 1, 1, 1). Since this array is the same as the previous year, this year is stable . For the third test case: At year (1), the following array shows the number of plushies each spider has: (1, 1, 1, 1, 1). Then, year (1)'s exchange happens. At year (2), the following array shows the number of plushies each spider has: $$$

Tutorials

Codeforces Round 993 (Div. 4) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
296777216 complexorigin G2 Dec. 15, 2024, 11:12 p.m. OK C++17 (GCC 7-32) TESTS 11 93 0
296758603 Raju_3 G2 Dec. 15, 2024, 6:18 p.m. OK C++17 (GCC 7-32) TESTS 11 93 2662400
296785990 cmdgbb G2 Dec. 16, 2024, 3:32 a.m. OK C++17 (GCC 7-32) TESTS 11 93 4096000
296768119 Rupam_09 G2 Dec. 15, 2024, 8:05 p.m. OK C++17 (GCC 7-32) TESTS 11 93 4608000
296760918 zero.xzp G2 Dec. 15, 2024, 6:39 p.m. OK C++17 (GCC 7-32) TESTS 11 93 8089600
296784532 hxano G2 Dec. 16, 2024, 3:03 a.m. OK C++17 (GCC 7-32) TESTS 11 93 15462400
296792481 faishal_052 G2 Dec. 16, 2024, 5:14 a.m. OK C++17 (GCC 7-32) TESTS 11 93 21708800
296772078 Masalmah G2 Dec. 15, 2024, 9:10 p.m. OK C++17 (GCC 7-32) TESTS 11 109 614400
296764151 Manglik G2 Dec. 15, 2024, 7:15 p.m. OK C++17 (GCC 7-32) TESTS 11 109 1331200
296787941 cheng-jian G2 Dec. 16, 2024, 4:06 a.m. OK C++17 (GCC 7-32) TESTS 11 109 2867200
296789816 FangYifan G2 Dec. 16, 2024, 4:36 a.m. OK C++20 (GCC 13-64) TESTS 11 62 614400
296776733 fbabic ToniB vito1036 G2 Dec. 15, 2024, 10:55 p.m. OK C++20 (GCC 13-64) TESTS 11 62 1024000
296785870 UP84 G2 Dec. 16, 2024, 3:29 a.m. OK C++20 (GCC 13-64) TESTS 11 77 0
296749987 dryeab G2 Dec. 15, 2024, 5:13 p.m. OK C++20 (GCC 13-64) TESTS 11 77 0
296776568 3R1C G2 Dec. 15, 2024, 10:51 p.m. OK C++20 (GCC 13-64) TESTS 11 77 102400
296775340 greenbinjack G2 Dec. 15, 2024, 10:20 p.m. OK C++20 (GCC 13-64) TESTS 11 77 102400
296777957 aash8a9 G2 Dec. 15, 2024, 11:40 p.m. OK C++20 (GCC 13-64) TESTS 11 77 2867200
296750324 hotcocoa G2 Dec. 15, 2024, 5:15 p.m. OK C++20 (GCC 13-64) TESTS 11 77 4915200
296772326 amr_abdelazim G2 Dec. 15, 2024, 9:16 p.m. OK C++20 (GCC 13-64) TESTS 11 78 102400
296772439 aniketabhiraj2004 G2 Dec. 15, 2024, 9:18 p.m. OK C++20 (GCC 13-64) TESTS 11 78 6656000
296781699 qidao G2 Dec. 16, 2024, 1:55 a.m. OK C++23 (GCC 14-64, msys2) TESTS 11 77 0
296781335 tilenn G2 Dec. 16, 2024, 1:43 a.m. OK C++23 (GCC 14-64, msys2) TESTS 11 77 0
296791730 sskumarcp G2 Dec. 16, 2024, 5:04 a.m. OK C++23 (GCC 14-64, msys2) TESTS 11 77 102400
296786785 The-homeless G2 Dec. 16, 2024, 3:46 a.m. OK C++23 (GCC 14-64, msys2) TESTS 11 77 102400
296796560 widsnoy G2 Dec. 16, 2024, 6:01 a.m. OK C++23 (GCC 14-64, msys2) TESTS 11 77 2457600
296763614 ISMAILSHADOW G2 Dec. 15, 2024, 7:08 p.m. OK C++23 (GCC 14-64, msys2) TESTS 11 77 2662400
296778442 maybeAayan G2 Dec. 16, 2024, midnight OK C++23 (GCC 14-64, msys2) TESTS 11 77 2764800
296778404 NegativeElo G2 Dec. 15, 2024, 11:58 p.m. OK C++23 (GCC 14-64, msys2) TESTS 11 77 2764800
296776003 harshkankhar1 G2 Dec. 15, 2024, 10:36 p.m. OK C++23 (GCC 14-64, msys2) TESTS 11 77 2764800
296751055 _little_dog G2 Dec. 15, 2024, 5:20 p.m. OK C++23 (GCC 14-64, msys2) TESTS 11 77 3481600
296780056 PyIsTheBestLang G2 Dec. 16, 2024, 12:58 a.m. OK PyPy 3-64 TESTS 11 155 26112000
296768078 x3mka G2 Dec. 15, 2024, 8:04 p.m. OK PyPy 3-64 TESTS 11 155 29593600
296773129 jeroenodb G2 Dec. 15, 2024, 9:33 p.m. OK PyPy 3-64 TESTS 11 171 24576000
296774900 gardengnome G2 Dec. 15, 2024, 10:10 p.m. OK PyPy 3-64 TESTS 11 171 26419200
296748229 Sandeep_P G2 Dec. 15, 2024, 5:03 p.m. OK PyPy 3-64 TESTS 11 202 28364800
296776429 scyyyyyyyyyy G2 Dec. 15, 2024, 10:47 p.m. OK PyPy 3-64 TESTS 11 264 39526400
296773000 jeroenodb G2 Dec. 15, 2024, 9:30 p.m. OK PyPy 3-64 TESTS 11 265 25907200
296760889 Jrke G2 Dec. 15, 2024, 6:39 p.m. OK PyPy 3-64 TESTS 11 764 41574400
296767505 DeadMan69 G2 Dec. 15, 2024, 7:57 p.m. OK PyPy 3-64 TESTS 11 921 195379200
296767374 DeadMan69 G2 Dec. 15, 2024, 7:55 p.m. OK PyPy 3-64 TESTS 11 952 195788800

remove filters

Back to search problems