Codeforces Round 1069 (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
2174 Codeforces Round 1069 (Div. 1) FINISHED False 7200 11396723 Dec. 6, 2025, 8:15 a.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 1136 ) C1 Beautiful Patterns (Easy Version) PROGRAMMING math probabilities

This is the easy version of the problem. The difference between the versions is that in this version, (n \le 2 \cdot 10^3). 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 three integers (n), (m), and (p) ((1 \leq n \leq 2 \cdot 10^3); (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 (2 \cdot 10^3). 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

Tutorials

Codeforces Round 1069 Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
352225867 -firefly- C1 Dec. 6, 2025, 9:33 a.m. OK C# 13 TESTS 6 109 1843200
352233535 luka.heric C1 Dec. 6, 2025, 9:56 a.m. OK C++17 (GCC 7-32) TESTS 6 31 0
352195798 Ali_Adelkhah C1 Dec. 6, 2025, 8:28 a.m. OK C++17 (GCC 7-32) TESTS 6 31 0
352285428 krio131 C1 Dec. 6, 2025, 4:13 p.m. OK C++17 (GCC 7-32) TESTS 6 31 102400
352209268 Sept C1 Dec. 6, 2025, 8:54 a.m. OK C++17 (GCC 7-32) TESTS 6 31 102400
352264924 08kevin2 C1 Dec. 6, 2025, 1:46 p.m. OK C++17 (GCC 7-32) TESTS 6 31 1638400
352235074 Sacharlemagne C1 Dec. 6, 2025, 10:01 a.m. OK C++17 (GCC 7-32) TESTS 6 31 1638400
352281946 QWQcoding C1 Dec. 6, 2025, 3:47 p.m. OK C++17 (GCC 7-32) TESTS 6 31 4915200
352232393 Max_s_xaM C1 Dec. 6, 2025, 9:52 a.m. OK C++17 (GCC 7-32) TESTS 6 31 5324800
352266922 Ekamer C1 Dec. 6, 2025, 2 p.m. OK C++17 (GCC 7-32) TESTS 6 31 20070400
352236870 SpinSpen C1 Dec. 6, 2025, 10:06 a.m. OK C++17 (GCC 7-32) TESTS 6 46 0
352267690 zlxFTH C1 Dec. 6, 2025, 2:05 p.m. OK C++20 (GCC 13-64) TESTS 6 15 0
352208147 PEIMUDA C1 Dec. 6, 2025, 8:52 a.m. OK C++20 (GCC 13-64) TESTS 6 15 3276800
352314242 invertedwinger C1 Dec. 6, 2025, 8:35 p.m. OK C++20 (GCC 13-64) TESTS 6 31 0
352279621 Dark__Seith C1 Dec. 6, 2025, 3:29 p.m. OK C++20 (GCC 13-64) TESTS 6 31 0
352275046 Petroleumus C1 Dec. 6, 2025, 2:55 p.m. OK C++20 (GCC 13-64) TESTS 6 31 0
352262925 tch1cherin C1 Dec. 6, 2025, 1:33 p.m. OK C++20 (GCC 13-64) TESTS 6 31 0
352236123 _PHO3N1X_ C1 Dec. 6, 2025, 10:04 a.m. OK C++20 (GCC 13-64) TESTS 6 31 0
352226087 Kude C1 Dec. 6, 2025, 9:34 a.m. OK C++20 (GCC 13-64) TESTS 6 31 0
352223520 Xerxes C1 Dec. 6, 2025, 9:27 a.m. OK C++20 (GCC 13-64) TESTS 6 31 0
352221200 nldr C1 Dec. 6, 2025, 9:21 a.m. OK C++20 (GCC 13-64) TESTS 6 31 0
352211449 qixuanwei C1 Dec. 6, 2025, 8:59 a.m. OK C++23 (GCC 14-64, msys2) TESTS 6 15 102400
352225709 Include_Z_F_R_ C1 Dec. 6, 2025, 9:33 a.m. OK C++23 (GCC 14-64, msys2) TESTS 6 15 3174400
352213954 Scean_Tong C1 Dec. 6, 2025, 9:04 a.m. OK C++23 (GCC 14-64, msys2) TESTS 6 15 32051200
352323936 Boboge C1 Dec. 7, 2025, 12:17 a.m. OK C++23 (GCC 14-64, msys2) TESTS 6 31 0
352313780 amsraman C1 Dec. 6, 2025, 8:28 p.m. OK C++23 (GCC 14-64, msys2) TESTS 6 31 0
352295514 -1e11 C1 Dec. 6, 2025, 5:36 p.m. OK C++23 (GCC 14-64, msys2) TESTS 6 31 0
352288093 Auchenai01 C1 Dec. 6, 2025, 4:34 p.m. OK C++23 (GCC 14-64, msys2) TESTS 6 31 0
352283757 BurnedChicken C1 Dec. 6, 2025, 4 p.m. OK C++23 (GCC 14-64, msys2) TESTS 6 31 0
352260084 I.Gleb C1 Dec. 6, 2025, 1:15 p.m. OK C++23 (GCC 14-64, msys2) TESTS 6 31 0
352234383 white_unicorn C1 Dec. 6, 2025, 9:58 a.m. OK C++23 (GCC 14-64, msys2) TESTS 6 31 0
352208926 gua069 C1 Dec. 6, 2025, 8:53 a.m. OK Java 8 TESTS 6 109 0
352319558 ndelisle C1 Dec. 6, 2025, 10:13 p.m. OK PyPy 3-64 TESTS 6 62 2150400
352337404 maxymien C1 Dec. 7, 2025, 4:58 a.m. OK PyPy 3-64 TESTS 6 62 2252800
352213495 golomb C1 Dec. 6, 2025, 9:03 a.m. OK PyPy 3-64 TESTS 6 78 2867200
352208024 Ayis137 C1 Dec. 6, 2025, 8:52 a.m. OK PyPy 3-64 TESTS 6 93 2048000
352231863 Pulkit_gupta C1 Dec. 6, 2025, 9:51 a.m. OK PyPy 3-64 TESTS 6 93 2457600
352216274 a_cedia C1 Dec. 6, 2025, 9:09 a.m. OK PyPy 3-64 TESTS 6 125 2867200
352206253 gawkmaster069 C1 Dec. 6, 2025, 8:48 a.m. OK PyPy 3-64 TESTS 6 125 3993600
352235494 sfiisf C1 Dec. 6, 2025, 10:02 a.m. OK PyPy 3-64 TESTS 6 156 3584000
352291900 smz.26 C1 Dec. 6, 2025, 5:05 p.m. OK PyPy 3-64 TESTS 6 156 9625600
352235649 alphaGem C1 Dec. 6, 2025, 10:02 a.m. OK PyPy 3-64 TESTS 6 1968 7987200
352277546 siddhantbashisth C1 Dec. 6, 2025, 3:13 p.m. OK Python 3 TESTS 6 984 409600
352215130 sansen C1 Dec. 6, 2025, 9:07 a.m. OK Rust 2021 TESTS 6 31 0
352232324 toomer C1 Dec. 6, 2025, 9:52 a.m. OK Rust 2021 TESTS 6 93 0
352192350 Monster027 C1 Dec. 6, 2025, 8:23 a.m. OK Rust 2024 TESTS 6 109 0
352216704 Egor C1 Dec. 6, 2025, 9:11 a.m. OK Rust 2024 TESTS 6 156 0

remove filters

Back to search problems