Codeforces Round 1077 (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
2187 Codeforces Round 1077 (Div. 1) FINISHED False 10800 6708323 Jan. 29, 2026, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 609 ) D Cool Problem PROGRAMMING bitmasks brute force divide and conquer dp math

There are two integer constants (x) and (y). For a binary(^{\text{∗}}) string (r) of length (n), we define its generating array as an array (c=c_0,c_1,\ldots,c_n) such that (c_0=0), and for each (1 \le i \le n): If (r_i=\mathtt{0}), then (c_i=x+c_{i-1}); If (r_i=\mathtt{1}), then (c_i=y-c_{i-1}). Additionally, we define (f(r)=\sum\limits_{i=1}^n c_i). You are given an incomplete binary string (s) of length (n), where some characters in it are missing, represented by (\mathtt{?}). An integer (k) is called cool if and only if there exists a way to replace each (\mathtt{?}) in (s) with either (\mathtt{0}) or (\mathtt{1}), such that (f(s)=k). Your task is to calculate the sum of all cool integers, modulo (998\,244\,353). (^{\text{∗}})A binary string is a string where each character is either (\mathtt{0}) or (\mathtt{1}). 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 test case contains three integers (n), (x), and (y) ((1 \le n \le 10^5), (1 \le x,y \le 10^6)) — the length of (s) and the given constants. The second line contains the incomplete binary string (s) of length (n) ((s_i \in \{\mathtt{0}, \mathtt{1}, \mathtt{?}\})). It is guaranteed that the sum of (n) over all test cases does not exceed (10^5). For each test case, output a single integer — the sum of all cool integers modulo (998\,244\,353). In the first test case, the string (s) has already been determined, and its generating array is (0, 1). Thus, (f(s)=1), and the only cool integer is (1). In the third test case, there are four ways to complete the string (s): Thus, the sum of all cool integers is (42+12+36+10=100).

Tutorials

Codeforces Round 1077 (Div. 1, Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
360553989 potato167 D Jan. 29, 2026, 3:37 p.m. OK C++17 (GCC 7-32) TESTS 24 62 0
360597198 Numbering D Jan. 29, 2026, 4:47 p.m. OK C++17 (GCC 7-32) TESTS 24 531 102400
360603916 byunjaewoo D Jan. 29, 2026, 5:03 p.m. OK C++17 (GCC 7-32) TESTS 24 562 102400
360582769 skkkh D Jan. 29, 2026, 4:19 p.m. OK C++17 (GCC 7-32) TESTS 24 1031 102400
360613310 ArturSmolenski D Jan. 29, 2026, 5:28 p.m. OK C++17 (GCC 7-32) TESTS 24 1062 102400
360647302 HugeWide D Jan. 30, 2026, 12:05 a.m. OK C++17 (GCC 7-32) TESTS 25 1265 102400
360621111 Potassium D Jan. 29, 2026, 6:22 p.m. OK C++17 (GCC 7-32) TESTS 24 1546 1331200
360600448 08kevin D Jan. 29, 2026, 4:54 p.m. OK C++17 (GCC 7-32) TESTS 24 1843 34611200
360598429 mickeyjung D Jan. 29, 2026, 4:50 p.m. OK C++17 (GCC 7-32) TESTS 24 2671 15257600
360648828 BSpioneer D Jan. 30, 2026, 12:58 a.m. OK C++17 (GCC 7-32) TESTS 25 3453 614400
360608837 Xerxes D Jan. 29, 2026, 5:16 p.m. OK C++20 (GCC 13-64) TESTS 24 234 0
360552245 WangYuanyi D Jan. 29, 2026, 3:35 p.m. OK C++20 (GCC 13-64) TESTS 24 328 1536000
360634956 Michal_1 D Jan. 29, 2026, 8:23 p.m. OK C++20 (GCC 13-64) TESTS 25 359 1536000
360658502 Survivor_winner D Jan. 30, 2026, 4:11 a.m. OK C++20 (GCC 13-64) TESTS 25 375 6348800
360574382 JDScript0117 D Jan. 29, 2026, 4:05 p.m. OK C++20 (GCC 13-64) TESTS 24 406 2969600
360626903 Genius_Star_rgw D Jan. 29, 2026, 7:04 p.m. OK C++20 (GCC 13-64) TESTS 24 421 2969600
360585766 adam01 D Jan. 29, 2026, 4:24 p.m. OK C++20 (GCC 13-64) TESTS 24 484 1536000
360633554 Michal_1 D Jan. 29, 2026, 8:08 p.m. OK C++20 (GCC 13-64) TESTS 25 500 1536000
360626099 PaperCloud D Jan. 29, 2026, 6:57 p.m. OK C++20 (GCC 13-64) TESTS 24 515 1433600
360634363 aPNJ777 D Jan. 29, 2026, 8:17 p.m. OK C++20 (GCC 13-64) TESTS 25 531 2048000
360629865 RestlessMonk D Jan. 29, 2026, 7:31 p.m. OK C++23 (GCC 14-64, msys2) TESTS 25 62 512000
360580773 ecnerwala D Jan. 29, 2026, 4:15 p.m. OK C++23 (GCC 14-64, msys2) TESTS 24 62 512000
360614119 ace5 D Jan. 29, 2026, 5:30 p.m. OK C++23 (GCC 14-64, msys2) TESTS 24 62 1740800
360571903 Golovanov399 D Jan. 29, 2026, 4:01 p.m. OK C++23 (GCC 14-64, msys2) TESTS 24 62 2662400
360626702 RockSnow D Jan. 29, 2026, 7:02 p.m. OK C++23 (GCC 14-64, msys2) TESTS 24 125 102400
360621655 ecnerwala D Jan. 29, 2026, 6:25 p.m. OK C++23 (GCC 14-64, msys2) TESTS 24 125 2969600
360598098 profesor.programiranje D Jan. 29, 2026, 4:49 p.m. OK C++23 (GCC 14-64, msys2) TESTS 24 171 102400
360567430 maspy D Jan. 29, 2026, 3:55 p.m. OK C++23 (GCC 14-64, msys2) TESTS 24 187 614400
360534694 XVIII D Jan. 29, 2026, 3:17 p.m. OK C++23 (GCC 14-64, msys2) TESTS 24 250 0
360620931 International_River D Jan. 29, 2026, 6:21 p.m. OK C++23 (GCC 14-64, msys2) TESTS 24 250 3584000
360598597 MBBN D Jan. 29, 2026, 4:50 p.m. OK Java 21 TESTS 24 2031 6144000
360593786 harurun4635 D Jan. 29, 2026, 4:40 p.m. OK PyPy 3-64 TESTS 24 265 11673600
360632739 Little_Sheep_Yawn D Jan. 29, 2026, 7:59 p.m. OK PyPy 3-64 TESTS 25 1328 17510400
360607891 Go_Goat_Goal D Jan. 29, 2026, 5:13 p.m. OK PyPy 3-64 TESTS 24 1468 16076800
360651006 smilences D Jan. 30, 2026, 1:55 a.m. OK PyPy 3-64 TESTS 25 2015 12595200
360650985 smilences D Jan. 30, 2026, 1:54 a.m. OK Python 3 TESTS 25 859 11980800
360600569 Darknef D Jan. 29, 2026, 4:55 p.m. OK Rust 2024 TESTS 24 46 11673600
360559424 drydock D Jan. 29, 2026, 3:44 p.m. OK Rust 2024 TESTS 24 203 0
360592043 Egor D Jan. 29, 2026, 4:36 p.m. OK Rust 2024 TESTS 24 375 0

remove filters

Back to search problems