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 |
|---|---|---|---|---|---|---|
| 2174 | Codeforces Round 1069 (Div. 1) | FINISHED | False | 7200 | 11396723 | Dec. 6, 2025, 8:15 a.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 990 ) | C2 | Beautiful Patterns (Hard Version) | PROGRAMMING | math probabilities |
This is the hard version of the problem. The difference between the versions is that in this version, (n \le 2 \cdot 10^5). You can hack only if you solved all versions of this problem. Upon entering the ancient palace "Palindrome-Palace", you noticed that there are peculiar patterns on its walls. The pattern is a mosaic of size (1 \times n) made of pebbles, each painted in one of (m) different colors. The correctness of an arbitrary mosaic (s) is defined as the number of non-empty subsegments of (s) that are palindromes. The beauty of the mosaic is defined as the square of its correctness . For example, for the mosaic rgrb , there are five palindromic subsegments: r , g , r , b , and rgr . Therefore, its correctness is (5), and its beauty is (25). While wandering through this palace, you wondered: what is the expected value of the beauty of the mosaic if the color of each of the (n) pebbles is chosen uniformly and independently of the colors of the other pebbles? Print the answer modulo prime (p). Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 1000)). The description of the test cases follows. The only line of each test case contains 3 integers (n), (m), and (p) ((1 \leq n \leq 2 \cdot 10^5); (1 \leq m \leq 10^7); (m < p < 10^9)) representing the length of the mosaic, the number of different colors of pebbles, and the modulus for which the answer needs to be computed. It is guaranteed that (p) is a prime number. It is also guaranteed that the sum of (n) across all test cases does not exceed (10^6). For each test case, output the expected beauty of the mosaic modulo (p). Formally, let (x = p). It can be shown that the exact answer can be expressed as an irreducible fraction (\frac{y}{z}), where (y) and (z) are integers and (z \not \equiv 0 \pmod{x}). Output the integer equal to $$$y \cdot z^{-1} |
| Codeforces Round 1069 Editorial |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 352231947 | -firefly- | C2 | Dec. 6, 2025, 9:51 a.m. | OK | C# 13 | TESTS | 43 | 187 | 11161600 | ||
| 352236879 | Sacharlemagne | C2 | Dec. 6, 2025, 10:06 a.m. | OK | C++17 (GCC 7-32) | TESTS | 43 | 78 | 1638400 | ||
| 352232026 | Kieray | C2 | Dec. 6, 2025, 9:51 a.m. | OK | C++17 (GCC 7-32) | TESTS | 43 | 78 | 1638400 | ||
| 352234646 | Anixes | C2 | Dec. 6, 2025, 9:59 a.m. | OK | C++17 (GCC 7-32) | TESTS | 43 | 78 | 96256000 | ||
| 352232875 | HaPpY1213 | C2 | Dec. 6, 2025, 9:54 a.m. | OK | C++17 (GCC 7-32) | TESTS | 43 | 93 | 102400 | ||
| 352235011 | lijunyi | C2 | Dec. 6, 2025, 10 a.m. | OK | C++17 (GCC 7-32) | TESTS | 43 | 93 | 2560000 | ||
| 352285371 | krio131 | C2 | Dec. 6, 2025, 4:12 p.m. | OK | C++17 (GCC 7-32) | TESTS | 43 | 109 | 102400 | ||
| 352281917 | QWQcoding | C2 | Dec. 6, 2025, 3:47 p.m. | OK | C++17 (GCC 7-32) | TESTS | 43 | 109 | 4915200 | ||
| 352232469 | Max_s_xaM | C2 | Dec. 6, 2025, 9:53 a.m. | OK | C++17 (GCC 7-32) | TESTS | 43 | 109 | 5324800 | ||
| 352238813 | fft_ntt | C2 | Dec. 6, 2025, 10:11 a.m. | OK | C++17 (GCC 7-32) | TESTS | 43 | 109 | 6451200 | ||
| 352233620 | luka.heric | C2 | Dec. 6, 2025, 9:56 a.m. | OK | C++17 (GCC 7-32) | TESTS | 43 | 125 | 102400 | ||
| 352261794 | yangchang | C2 | Dec. 6, 2025, 1:26 p.m. | OK | C++20 (GCC 13-64) | TESTS | 43 | 46 | 102400 | ||
| 352233643 | sunkaihuan | C2 | Dec. 6, 2025, 9:56 a.m. | OK | C++20 (GCC 13-64) | TESTS | 43 | 46 | 9625600 | ||
| 352315013 | surajchip2 | C2 | Dec. 6, 2025, 8:47 p.m. | OK | C++20 (GCC 13-64) | TESTS | 44 | 62 | 0 | ||
| 352203581 | Zhou_Yuan | C2 | Dec. 6, 2025, 8:43 a.m. | OK | C++20 (GCC 13-64) | TESTS | 43 | 62 | 102400 | ||
| 352237073 | aoliao_lovely | C2 | Dec. 6, 2025, 10:06 a.m. | OK | C++20 (GCC 13-64) | TESTS | 43 | 62 | 1638400 | ||
| 352200190 | SDSXC | C2 | Dec. 6, 2025, 8:37 a.m. | OK | C++20 (GCC 13-64) | TESTS | 43 | 62 | 4915200 | ||
| 352225903 | Kude | C2 | Dec. 6, 2025, 9:33 a.m. | OK | C++20 (GCC 13-64) | TESTS | 43 | 78 | 0 | ||
| 352211346 | DSCS2009 | C2 | Dec. 6, 2025, 8:58 a.m. | OK | C++20 (GCC 13-64) | TESTS | 43 | 78 | 0 | ||
| 352316672 | gortomi | C2 | Dec. 6, 2025, 9:16 p.m. | OK | C++20 (GCC 13-64) | TESTS | 44 | 78 | 102400 | ||
| 352281474 | BurnedChicken | C2 | Dec. 6, 2025, 3:43 p.m. | OK | C++20 (GCC 13-64) | TESTS | 43 | 78 | 102400 | ||
| 352239596 | KobicGend | C2 | Dec. 6, 2025, 10:13 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 43 | 46 | 0 | ||
| 352236678 | white_unicorn | C2 | Dec. 6, 2025, 10:05 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 43 | 46 | 102400 | ||
| 352218647 | CHATTY-Bebob | C2 | Dec. 6, 2025, 9:15 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 43 | 46 | 102400 | ||
| 352238985 | while_zeze | C2 | Dec. 6, 2025, 10:12 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 43 | 46 | 40140800 | ||
| 352224743 | ApurbaKumarShow | C2 | Dec. 6, 2025, 9:30 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 43 | 62 | 0 | ||
| 352320833 | uk639 | C2 | Dec. 6, 2025, 10:42 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 44 | 62 | 102400 | ||
| 352224530 | tkrawczy | C2 | Dec. 6, 2025, 9:30 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 43 | 62 | 102400 | ||
| 352218594 | Nyaan | C2 | Dec. 6, 2025, 9:15 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 43 | 62 | 102400 | ||
| 352225831 | Include_Z_F_R_ | C2 | Dec. 6, 2025, 9:33 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 43 | 62 | 3276800 | ||
| 352225824 | cooluo | C2 | Dec. 6, 2025, 9:33 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 43 | 62 | 6963200 | ||
| 352211420 | gua069 | C2 | Dec. 6, 2025, 8:59 a.m. | OK | Java 8 | TESTS | 43 | 265 | 0 | ||
| 352232427 | a_cedia | C2 | Dec. 6, 2025, 9:52 a.m. | OK | PyPy 3-64 | TESTS | 43 | 125 | 7065600 | ||
| 352208186 | Ayis137 | C2 | Dec. 6, 2025, 8:52 a.m. | OK | PyPy 3-64 | TESTS | 43 | 125 | 7884800 | ||
| 352319581 | ndelisle | C2 | Dec. 6, 2025, 10:14 p.m. | OK | PyPy 3-64 | TESTS | 44 | 171 | 7372800 | ||
| 352213690 | golomb | C2 | Dec. 6, 2025, 9:03 a.m. | OK | PyPy 3-64 | TESTS | 43 | 203 | 15155200 | ||
| 352291790 | smz.26 | C2 | Dec. 6, 2025, 5:04 p.m. | OK | PyPy 3-64 | TESTS | 44 | 218 | 30310400 | ||
| 352337709 | maxymien | C2 | Dec. 7, 2025, 5:03 a.m. | OK | PyPy 3-64 | TESTS | 44 | 265 | 12390400 | ||
| 352210963 | gawkmaster069 | C2 | Dec. 6, 2025, 8:58 a.m. | OK | PyPy 3-64 | TESTS | 43 | 281 | 4812800 | ||
| 352298546 | alphaGem | C2 | Dec. 6, 2025, 6:01 p.m. | OK | PyPy 3-64 | TESTS | 44 | 953 | 16179200 | ||
| 352277909 | siddhantbashisth | C2 | Dec. 6, 2025, 3:16 p.m. | OK | Python 3 | TESTS | 43 | 1234 | 4608000 | ||
| 352232488 | toomer | C2 | Dec. 6, 2025, 9:53 a.m. | OK | Rust 2021 | TESTS | 43 | 93 | 102400 | ||
| 352214764 | sansen | C2 | Dec. 6, 2025, 9:06 a.m. | OK | Rust 2021 | TESTS | 43 | 187 | 102400 | ||
| 352198724 | Monster027 | C2 | Dec. 6, 2025, 8:34 a.m. | OK | Rust 2024 | TESTS | 43 | 218 | 0 |
Back to search problems