Codeforces Round 1049 (Div. 2)

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
2140 Codeforces Round 1049 (Div. 2) FINISHED False 7200 18977123 Sept. 9, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 1225 ) E2 Prime Gaming (Hard Version) PROGRAMMING bitmasks combinatorics dp probabilities

This is the hard version of the problem. The difference between the versions is that in this version, (m \le 10^6). You can hack only if you solved all versions of this problem. A valid configuration is defined as an arrangement of (n) piles of stones such that: The number of stones in each pile is an integer between (1) and (m) (both inclusive). Given a valid configuration of (n) piles of stones, some indices from (1) to (n) are marked as good . Alice and Bob start playing a game taking (n-1) turns alternately with Alice going first. In each turn, they have to perform the following operation: Choose any integer (i) such that (1 \le i \le p) (where (p) is the number of piles left) and (i) is good , and remove the (i)-th pile completely. Note that after performing the operation once, the number of piles decreases by (1) and the remaining piles are re-indexed. The game will end when there is only one pile left. It is guaranteed that the index (1) is always good. Let (x) denote the number of stones in the final remaining pile. Alice wants to maximize (x), whereas Bob wants to minimize it. Both Alice and Bob play optimally. Find the sum of (x) over all the possible valid configurations modulo (10 ^ 9 + 7). 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) ((1 \le n \le 20)) and (m) ((1 \le m \le 10^6)) — the number of piles and the upper bound on the number of stones in a pile. The second line of each testcase contains a single integer (k) ((1 \le k \le n)) — the number of indices marked as good. The third line of each testcase contains (k) integers (c_1,c_2,\ldots,c_k) ((1=c_1<c_2<\ldots<c_k\le n)) — the good indices. It is guaranteed that (1) is always a good index (i.e. $$

Tutorials

Codeforces Round 1049 (Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
337863603 -firefly- E2 Sept. 9, 2025, 6:47 p.m. OK C# 13 TESTS 64 1202 9216000
337864109 -firefly- E2 Sept. 9, 2025, 6:53 p.m. OK C# 13 TESTS 64 1702 9318400
337863950 -firefly- E2 Sept. 9, 2025, 6:51 p.m. OK C# 13 TESTS 64 2687 9216000
337863883 -firefly- E2 Sept. 9, 2025, 6:51 p.m. OK C# 13 TESTS 64 2968 9216000
337843001 ayushpandeyv1976 E2 Sept. 9, 2025, 4:25 p.m. OK C++17 (GCC 7-32) TESTS 64 109 0
337846190 RyenX7 E2 Sept. 9, 2025, 4:31 p.m. OK C++17 (GCC 7-32) TESTS 64 109 102400
337844789 Khushi_agr E2 Sept. 9, 2025, 4:28 p.m. OK C++17 (GCC 7-32) TESTS 64 124 102400
337842165 KhanAwais E2 Sept. 9, 2025, 4:23 p.m. OK C++17 (GCC 7-32) TESTS 64 124 102400
337848023 supriyo177013..228922.. E2 Sept. 9, 2025, 4:34 p.m. OK C++17 (GCC 7-32) TESTS 64 125 0
337856199 VaHiX E2 Sept. 9, 2025, 5:42 p.m. OK C++17 (GCC 7-32) TESTS 64 139 102400
337850606 hackerrrrr E2 Sept. 9, 2025, 5:04 p.m. OK C++17 (GCC 7-32) TESTS 64 140 0
337842204 meem1307 E2 Sept. 9, 2025, 4:23 p.m. OK C++17 (GCC 7-32) TESTS 64 140 102400
337841458 Kupa_Shamsu E2 Sept. 9, 2025, 4:21 p.m. OK C++17 (GCC 7-32) TESTS 64 140 102400
337845926 AnuragYADAV_10 E2 Sept. 9, 2025, 4:31 p.m. OK C++17 (GCC 7-32) TESTS 64 280 0
337846331 prashanthit8074 E2 Sept. 9, 2025, 4:31 p.m. OK C++20 (GCC 13-64) TESTS 64 93 102400
337845472 Aryaman13 E2 Sept. 9, 2025, 4:30 p.m. OK C++20 (GCC 13-64) TESTS 64 93 102400
337844256 aryaman69 E2 Sept. 9, 2025, 4:27 p.m. OK C++20 (GCC 13-64) TESTS 64 93 102400
337846763 cody_mig E2 Sept. 9, 2025, 4:32 p.m. OK C++20 (GCC 13-64) TESTS 64 108 0
337844067 SardorbekDev E2 Sept. 9, 2025, 4:27 p.m. OK C++20 (GCC 13-64) TESTS 64 108 102400
337843350 who-are-you E2 Sept. 9, 2025, 4:25 p.m. OK C++20 (GCC 13-64) TESTS 64 109 0
337846971 giaosu E2 Sept. 9, 2025, 4:32 p.m. OK C++20 (GCC 13-64) TESTS 64 109 102400
337846069 Trying_To_Be_Banned E2 Sept. 9, 2025, 4:31 p.m. OK C++20 (GCC 13-64) TESTS 64 109 102400
337844142 SudarshanCoder E2 Sept. 9, 2025, 4:27 p.m. OK C++20 (GCC 13-64) TESTS 64 109 102400
337885758 thecold E2 Sept. 10, 2025, 1:28 a.m. OK C++20 (GCC 13-64) TESTS 64 202 272588800
337901636 424479543 E2 Sept. 10, 2025, 5:33 a.m. OK C++23 (GCC 14-64, msys2) TESTS 64 77 512000
337899881 424479543 E2 Sept. 10, 2025, 5:10 a.m. OK C++23 (GCC 14-64, msys2) TESTS 64 77 512000
337903174 424479543 E2 Sept. 10, 2025, 5:50 a.m. OK C++23 (GCC 14-64, msys2) TESTS 64 78 512000
337901777 424479543 E2 Sept. 10, 2025, 5:34 a.m. OK C++23 (GCC 14-64, msys2) TESTS 64 78 512000
337900450 424479543 E2 Sept. 10, 2025, 5:17 a.m. OK C++23 (GCC 14-64, msys2) TESTS 64 78 4300800
337843824 durgeshpatel E2 Sept. 9, 2025, 4:26 p.m. OK C++23 (GCC 14-64, msys2) TESTS 64 93 102400
337842339 isaliabc0 E2 Sept. 9, 2025, 4:23 p.m. OK C++23 (GCC 14-64, msys2) TESTS 64 93 102400
337901967 424479543 E2 Sept. 10, 2025, 5:37 a.m. OK C++23 (GCC 14-64, msys2) TESTS 64 93 512000
337900819 424479543 E2 Sept. 10, 2025, 5:22 a.m. OK C++23 (GCC 14-64, msys2) TESTS 64 93 4300800
337842130 blewron E2 Sept. 9, 2025, 4:23 p.m. OK C++23 (GCC 14-64, msys2) TESTS 64 108 0
337845113 k.saijaswanth E2 Sept. 9, 2025, 4:29 p.m. OK Go TESTS 64 155 5324800
337844284 bharadwaj_manu E2 Sept. 9, 2025, 4:27 p.m. OK Java 21 TESTS 64 374 1433600
337846170 finalboss_20 E2 Sept. 9, 2025, 4:31 p.m. OK Java 21 TESTS 64 1139 1740800
337841099 Anichesschamp1008 E2 Sept. 9, 2025, 4:21 p.m. OK Java 21 TESTS 64 1312 7577600
337838554 adityav170920 E2 Sept. 9, 2025, 4:15 p.m. OK Java 8 TESTS 64 1577 0
337870470 ikrpprppp E2 Sept. 9, 2025, 8:07 p.m. OK Kotlin 1.7 TESTS 64 2014 239206400
337855085 zouyu9631 E2 Sept. 9, 2025, 5:34 p.m. OK PyPy 3 TESTS 64 1077 16998400
337854583 zouyu9631 E2 Sept. 9, 2025, 5:30 p.m. OK PyPy 3 TESTS 64 1311 11878400
337840112 Afif001Original E2 Sept. 9, 2025, 4:18 p.m. OK PyPy 3-64 TESTS 64 389 15564800
337850694 smz.26 E2 Sept. 9, 2025, 5:04 p.m. OK PyPy 3-64 TESTS 64 624 15360000
337838108 Sangram225 E2 Sept. 9, 2025, 4:14 p.m. OK PyPy 3-64 TESTS 64 702 9830400
337888226 kamio-misuzu E2 Sept. 10, 2025, 2:13 a.m. OK PyPy 3-64 TESTS 64 1202 205824000
337892504 smilences E2 Sept. 10, 2025, 3:25 a.m. OK PyPy 3-64 TESTS 64 1218 35942400
337887978 kamio-misuzu E2 Sept. 10, 2025, 2:08 a.m. OK PyPy 3-64 TESTS 64 1281 205721600
337894130 Little_Sheep_Yawn E2 Sept. 10, 2025, 3:49 a.m. OK PyPy 3-64 TESTS 64 1405 358912000
337865850 Nikrien E2 Sept. 9, 2025, 7:11 p.m. OK PyPy 3-64 TESTS 64 2186 21811200
337845465 Pulkit_gupta E2 Sept. 9, 2025, 4:30 p.m. OK PyPy 3-64 TESTS 64 2281 21708800
337841798 InO4 E2 Sept. 9, 2025, 4:22 p.m. OK Rust 2024 TESTS 64 609 102400

remove filters

Back to search problems