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 |
|---|---|---|---|---|---|---|
| 2226 | Codeforces Round 1095 (Div. 2) | FINISHED | False | 8100 | 1178664 | April 28, 2026, 2:35 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 193 ) | F | Inversion Invasion | PROGRAMMING | math number theory |
There is an array (a) of length (n). Initially, (a_i = 0) for all (1 \le i \le n). A permutation(^{\text{∗}}) (p) is said to be valid if at least one of the following conditions is satisfied for every (1 \le i \le n): (a_i = 0). (\gcd(p_i, n) = a_i). You have to process (q) queries. In each query, you are given two integers (i) and (x), and you must update the array by setting (a_i:= x) persistently . It is guaranteed that (a_i = 0) at the time of each query, and it is guaranteed that (x) divides (n). After performing each query, output the sum of the number of inversions(^{\text{†}}) across all valid permutations. As the answers can be very large, report them modulo (998\,244\,353). (^{\text{∗}})A permutation of length (m) is an array consisting of (m) distinct integers from (1) to (m) in arbitrary order. For example, (2,3,1,5,4) is a permutation, but (1,2,2) is not a permutation ((2) appears twice in the array), and (1,3,4) is also not a permutation ((m=3) but there is a (4) in the array). (^{\text{†}})An inversion in a permutation (p) is a pair of indices ((i, j)) such that (i \lt j) and (p_i \gt p_j). For example, the permutation (4, 1, 3, 2) has (4) inversions: ((1, 2)), ((1, 3)), ((1, 4)), and ((3, 4)). Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 10^4)). The description of the test cases follows. The first line of each testcase contains two integers (n) and (q) ((1 \le n \le 2 \cdot 10^6); (1 \le q \le \min(n, 10^6))) — the length of the array (a) and the number of queries. Each of the next (q) lines contains two integers (i) and (x) ((1 \le i \le n); (1 \le x \le n)). It is guaranteed that (a_i = 0) at the time of each query, and it is guaranteed that (x) divides $$$n |
| Codeforces Round 1095 (Div. 2) Editorial |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 372870924 | caffeine2ac | F | April 28, 2026, 4:44 p.m. | OK | C# 13 | TESTS | 30 | 328 | 93286400 | ||
| 372863080 | potato167 | F | April 28, 2026, 4:15 p.m. | OK | C++17 (GCC 7-32) | TESTS | 30 | 734 | 17408000 | ||
| 372863017 | Fanboymessi | F | April 28, 2026, 4:15 p.m. | OK | C++17 (GCC 7-32) | TESTS | 30 | 875 | 50585600 | ||
| 372872283 | Iam_Ceighter | F | April 28, 2026, 4:48 p.m. | OK | C++17 (GCC 7-32) | TESTS | 30 | 906 | 47411200 | ||
| 372884931 | _.rajababu | F | April 28, 2026, 7:03 p.m. | OK | C++17 (GCC 7-32) | TESTS | 30 | 953 | 72192000 | ||
| 372892774 | Linuyin | F | April 28, 2026, 8:57 p.m. | OK | C++17 (GCC 7-32) | TESTS | 30 | 1140 | 36147200 | ||
| 372865649 | R_eeee | F | April 28, 2026, 4:24 p.m. | OK | C++17 (GCC 7-32) | TESTS | 30 | 1390 | 80281600 | ||
| 372905602 | CanadaGoose_imkdldw | F | April 29, 2026, 3:37 a.m. | OK | C++17 (GCC 7-32) | TESTS | 30 | 1671 | 92467200 | ||
| 372904851 | yxl1 | F | April 29, 2026, 3:19 a.m. | OK | C++20 (GCC 13-64) | TESTS | 30 | 187 | 40652800 | ||
| 372898725 | dfgsae | F | April 29, 2026, 12:12 a.m. | OK | C++20 (GCC 13-64) | TESTS | 30 | 203 | 36249600 | ||
| 372872174 | TYP_LongHD | F | April 28, 2026, 4:48 p.m. | OK | C++20 (GCC 13-64) | TESTS | 30 | 203 | 43827200 | ||
| 372867309 | CPluhPluh | F | April 28, 2026, 4:30 p.m. | OK | C++20 (GCC 13-64) | TESTS | 30 | 468 | 28160000 | ||
| 372908268 | FantasyNumber | F | April 29, 2026, 4:40 a.m. | OK | C++20 (GCC 13-64) | TESTS | 30 | 484 | 64204800 | ||
| 372871096 | fidan2005 | F | April 28, 2026, 4:44 p.m. | OK | C++20 (GCC 13-64) | TESTS | 30 | 500 | 32153600 | ||
| 372870880 | kotatsugame | F | April 28, 2026, 4:44 p.m. | OK | C++20 (GCC 13-64) | TESTS | 30 | 515 | 53043200 | ||
| 372864606 | rishuraj1397 | F | April 28, 2026, 4:20 p.m. | OK | C++20 (GCC 13-64) | TESTS | 30 | 531 | 28160000 | ||
| 372865182 | JPMM | F | April 28, 2026, 4:22 p.m. | OK | C++20 (GCC 13-64) | TESTS | 30 | 531 | 32768000 | ||
| 372890240 | Swammick | F | April 28, 2026, 8:11 p.m. | OK | C++20 (GCC 13-64) | TESTS | 30 | 625 | 76288000 | ||
| 372860764 | hanmantkurhade77 | F | April 28, 2026, 4:07 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 30 | 187 | 61030400 | ||
| 372892585 | 424479543 | F | April 28, 2026, 8:52 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 30 | 250 | 62156800 | ||
| 372904779 | banney | F | April 29, 2026, 3:17 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 30 | 421 | 30515200 | ||
| 372879630 | JessieQY | F | April 28, 2026, 6:06 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 30 | 484 | 28262400 | ||
| 372866473 | edmondium23 | F | April 28, 2026, 4:27 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 30 | 500 | 28262400 | ||
| 372870555 | imammadov20577 | F | April 28, 2026, 4:42 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 30 | 500 | 32153600 | ||
| 372866805 | RustyPanda | F | April 28, 2026, 4:28 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 30 | 500 | 32358400 | ||
| 372899092 | enslaved | F | April 29, 2026, 12:27 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 30 | 500 | 48332800 | ||
| 372866702 | onlyfanz | F | April 28, 2026, 4:28 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 30 | 515 | 38502400 | ||
| 372899580 | L1022 | F | April 29, 2026, 12:47 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 30 | 515 | 44339200 | ||
| 372871768 | bitplease_ | F | April 28, 2026, 4:47 p.m. | OK | Node.js | TESTS | 30 | 984 | 184524800 | ||
| 372867920 | Little_Sheep_Yawn | F | April 28, 2026, 4:32 p.m. | OK | PyPy 3-64 | TESTS | 30 | 890 | 138956800 | ||
| 372895232 | eugenechka.boyko.2_0-0 | F | April 28, 2026, 10:02 p.m. | OK | PyPy 3-64 | TESTS | 30 | 1875 | 72499200 | ||
| 372872587 | trycatchcry | F | April 28, 2026, 4:49 p.m. | OK | Rust 2024 | TESTS | 30 | 546 | 118784000 |
Back to search problems