Codeforces Round 1050 (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
2148 Codeforces Round 1050 (Div. 4) FINISHED False 8100 18631523 Sept. 13, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 4158 ) G Farmer John's Last Wish PROGRAMMING data structures math number theory

Bessie has found an array (a) of length (n) on the floor. There appears to be a handwritten note lying next to the array, seemingly written by Farmer John. The note reads: Help me, dear Bessie! Let (f(a)) denote the maximum integer (k) in the range ([1,n)) such that (\gcd(a_1, a_2, \ldots, a_k) > \gcd(a_1, a_2, \ldots, a_{k+1})), or (0) if no such (k) exists. Bessie decides to help FJ. She defines (g(a)) to represent the maximum value of (f(a)) over all possible reorderings of (a). Bessie decides to not only find (g(a)), but also the value of (g(p)) for all prefixes (p) of (a). Output (n) integers, the (i)'th of which is (g(a_1, a_2, \ldots, a_i)). 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) ((1 \leq n \leq 2 \cdot 10^5)). The following line contains (n) space-separated integers (a_1, a_2, \ldots, a_n) ((1 \leq a_i \leq n)). It is guaranteed that the sum of (n) over all test cases does not exceed (2 \cdot 10^5). For each test case, output (n) integers on a new line: the (i)'th of which should be (g(a_1, a_2, \ldots, a_i)).

Tutorials

Codeforces Round 1050 (Div. 4) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
338630648 og.kostya G Sept. 14, 2025, 4:27 p.m. OK C# 10 TESTS 20 405 6860800
338630676 og.kostya G Sept. 14, 2025, 4:28 p.m. OK C# 13 TESTS 20 624 8192000
338628703 og.kostya G Sept. 14, 2025, 4:07 p.m. OK C# 13 TESTS 20 2702 9318400
338579500 lazyhazard03 G Sept. 14, 2025, 9:36 a.m. OK C++17 (GCC 7-32) TESTS 20 187 0
338636641 haha1324 G Sept. 14, 2025, 5:30 p.m. OK C++17 (GCC 7-32) TESTS 20 218 10137600
338610163 mateuszmj G Sept. 14, 2025, 1:31 p.m. OK C++17 (GCC 7-32) TESTS 20 311 16281600
338609726 mateuszmj G Sept. 14, 2025, 1:28 p.m. OK C++17 (GCC 7-32) TESTS 20 312 17920000
338665327 lzzzzzzzzzz G Sept. 15, 2025, 3:31 a.m. OK C++17 (GCC 7-32) TESTS 20 327 17305600
338651481 GhOsT16790 G Sept. 14, 2025, 9 p.m. OK C++17 (GCC 7-32) TESTS 20 327 18124800
338609392 mateuszmj G Sept. 14, 2025, 1:26 p.m. OK C++17 (GCC 7-32) TESTS 20 328 16179200
338673883 guywholovesrandomness G Sept. 15, 2025, 5:27 a.m. OK C++17 (GCC 7-32) TESTS 20 342 16179200
338556175 ClosetNarcissist G Sept. 14, 2025, 4:57 a.m. OK C++17 (GCC 7-32) TESTS 20 358 15360000
338539835 albatross1811 G Sept. 13, 2025, 11:18 p.m. OK C++17 (GCC 7-32) TESTS 20 358 16588800
338583417 adam.jq.xu G Sept. 14, 2025, 10:08 a.m. OK C++20 (GCC 13-64) TESTS 20 202 14438400
338591133 Nika. G Sept. 14, 2025, 11:10 a.m. OK C++20 (GCC 13-64) TESTS 20 202 15155200
338652112 trdrag G Sept. 14, 2025, 9:17 p.m. OK C++20 (GCC 13-64) TESTS 20 280 819200
338640548 DarkSun G Sept. 14, 2025, 6:13 p.m. OK C++20 (GCC 13-64) TESTS 20 281 819200
338647230 mathworker21 G Sept. 14, 2025, 7:42 p.m. OK C++20 (GCC 13-64) TESTS 20 281 10956800
338551828 molywyp G Sept. 14, 2025, 3:43 a.m. OK C++20 (GCC 13-64) TESTS 20 296 11571200
338639077 fizaaaaaaaa G Sept. 14, 2025, 5:56 p.m. OK C++20 (GCC 13-64) TESTS 20 312 23449600
338644441 fizaaaaaaaa G Sept. 14, 2025, 7 p.m. OK C++20 (GCC 13-64) TESTS 20 327 102400
338667265 Maxro G Sept. 15, 2025, 3:54 a.m. OK C++20 (GCC 13-64) TESTS 20 327 2560000
338670205 you-jin-plus G Sept. 15, 2025, 4:29 a.m. OK C++20 (GCC 13-64) TESTS 20 327 20480000
338537115 NikoBaotic G Sept. 13, 2025, 10:03 p.m. OK C++23 (GCC 14-64, msys2) TESTS 20 108 4096000
338537174 NikoBaotic G Sept. 13, 2025, 10:04 p.m. OK C++23 (GCC 14-64, msys2) TESTS 20 109 4096000
338537027 NikoBaotic G Sept. 13, 2025, 10 p.m. OK C++23 (GCC 14-64, msys2) TESTS 20 109 4096000
338654850 1egend G Sept. 14, 2025, 10:49 p.m. OK C++23 (GCC 14-64, msys2) TESTS 20 109 6860800
338634200 Sorinel G Sept. 14, 2025, 5:04 p.m. OK C++23 (GCC 14-64, msys2) TESTS 20 140 2048000
338537047 NikoBaotic G Sept. 13, 2025, 10:01 p.m. OK C++23 (GCC 14-64, msys2) TESTS 20 140 4096000
338629887 ihgazi G Sept. 14, 2025, 4:19 p.m. OK C++23 (GCC 14-64, msys2) TESTS 20 156 204800
338537140 NikoBaotic G Sept. 13, 2025, 10:03 p.m. OK C++23 (GCC 14-64, msys2) TESTS 20 171 4096000
338593874 I_love_maxaxaxaxa G Sept. 14, 2025, 11:32 a.m. OK C++23 (GCC 14-64, msys2) TESTS 20 186 1024000
338579082 ibrm G Sept. 14, 2025, 9:33 a.m. OK C++23 (GCC 14-64, msys2) TESTS 20 187 10649600
338632913 ruban G Sept. 14, 2025, 4:52 p.m. OK FPC TESTS 20 796 115712000
338575586 vineetiwari G Sept. 14, 2025, 9:04 a.m. OK Java 21 TESTS 20 624 40243200
338555514 nabina1395 G Sept. 14, 2025, 4:46 a.m. OK Java 21 TESTS 20 2796 1843200
338591612 kasiru_69 G Sept. 14, 2025, 11:14 a.m. OK Java 8 TESTS 20 2561 114585600
338619845 chinesedfan G Sept. 14, 2025, 2:51 p.m. OK Node.js TESTS 20 1874 114892800
338661680 Kaslanla G Sept. 15, 2025, 2:24 a.m. OK PyPy 3-64 TESTS 20 937 97689600
338641786 TNTNTN G Sept. 14, 2025, 6:27 p.m. OK PyPy 3-64 TESTS 20 984 93081600
338548649 eugenechka.boyko.2_0-0 G Sept. 14, 2025, 2:44 a.m. OK PyPy 3-64 TESTS 20 999 30412800
338674006 wyzl G Sept. 15, 2025, 5:28 a.m. OK PyPy 3-64 TESTS 20 1139 96051200
338550430 paneerrrrrr G Sept. 14, 2025, 3:17 a.m. OK PyPy 3-64 TESTS 20 1155 107827200
338631680 titia G Sept. 14, 2025, 4:39 p.m. OK PyPy 3-64 TESTS 20 1296 28876800
338640366 nbhavsar G Sept. 14, 2025, 6:11 p.m. OK PyPy 3-64 TESTS 20 1405 83148800
338546581 linhua G Sept. 14, 2025, 2:02 a.m. OK PyPy 3-64 TESTS 20 1406 94310400
338586948 0mar_ G Sept. 14, 2025, 10:38 a.m. OK PyPy 3-64 TESTS 20 1421 81920000
338650812 IC_Br0ken G Sept. 14, 2025, 8:46 p.m. OK PyPy 3-64 TESTS 20 1468 102400000
338534700 0x81 G Sept. 13, 2025, 9:05 p.m. OK Rust 2024 TESTS 20 264 3481600
338630284 bin1st090104 G Sept. 14, 2025, 4:24 p.m. OK Rust 2024 TESTS 20 296 18227200

remove filters

Back to search problems