Codeforces Round 1075 (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
2189 Codeforces Round 1075 (Div. 2) FINISHED False 7200 7226723 Jan. 23, 2026, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 1906 ) D2 Little String (Hard Version) PROGRAMMING binary search combinatorics dp greedy math number theory

This is the hard version of the problem. The difference between the versions is that in this version, the string (s) can contain the character ? . For the string (w_1w_2 \ldots w_n), consisting of characters 0 and 1 , we define (f(w)) as the number of permutations (p_1, p_2, \ldots, p_n) of the array (0, 1, \ldots, n-1), such that for all (i) from (1) to (n) the following holds: if (w_i = 1), then there exist such (1 \leq l \leq r \leq n) that (\operatorname{mex}(p_l, p_{l+1}, \ldots, p_r) = i);(^{\text{∗}}) if (w_i = 0), then there do not exist such (1 \leq l \leq r \leq n) that (\operatorname{mex}(p_l, p_{l+1}, \ldots, p_r) = i). Given a string (s_1s_2 \ldots s_n), consisting of characters 0 , 1 , and ? , and a positive integer (c). Consider all strings (w) that can be obtained from (s) by replacing all characters ? with characters 0 and 1 . Find the smallest value of (f(w)) among all such strings (w) that is not divisible by (c), or determine that such a string (w) does not exist. Since the answer may be large, find it modulo (10^9+7). (^{\text{∗}})The minimum excluded (MEX) of a collection of integers (c_1, c_2, \ldots, c_k) is defined as the smallest non-negative integer (x) which does not occur in the collection (c). 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 two integers (n) and (c) ((3 \leq n \leq 2 \cdot 10^5), (1 \leq c \leq 10^9)) — the length of the string and the number that limits the value of the function. The second line of each test case contains a string of length (n), consisting of characters 0 , 1 , and ? — the string (s). It is guaranteed that the sum of (n) across all test cases does not exceed $$$2 \cdot 10^5$$

Tutorials

Codeforces Round 1075 (Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
359454421 cp_first D2 Jan. 23, 2026, 5:35 p.m. OK C++17 (GCC 7-32) TESTS 30 46 0
359489981 Sungl D2 Jan. 24, 2026, 3:19 a.m. OK C++17 (GCC 7-32) TESTS 30 46 102400
359488195 HuChengFeng D2 Jan. 24, 2026, 2:47 a.m. OK C++17 (GCC 7-32) TESTS 30 46 102400
359487700 ghc7hHx D2 Jan. 24, 2026, 2:37 a.m. OK C++17 (GCC 7-32) TESTS 30 46 102400
359480478 amitak17 D2 Jan. 23, 2026, 11:03 p.m. OK C++17 (GCC 7-32) TESTS 30 46 102400
359480452 depoo. D2 Jan. 23, 2026, 11:02 p.m. OK C++17 (GCC 7-32) TESTS 30 46 102400
359478326 kuttakhan1928 D2 Jan. 23, 2026, 10:04 p.m. OK C++17 (GCC 7-32) TESTS 30 46 102400
359466931 Namine D2 Jan. 23, 2026, 7:17 p.m. OK C++17 (GCC 7-32) TESTS 30 46 102400
359462067 mateuszmj D2 Jan. 23, 2026, 6:30 p.m. OK C++17 (GCC 7-32) TESTS 30 46 102400
359456809 csk2005 D2 Jan. 23, 2026, 5:52 p.m. OK C++17 (GCC 7-32) TESTS 30 46 102400
359493810 Pigsyy D2 Jan. 24, 2026, 4:26 a.m. OK C++20 (GCC 13-64) TESTS 30 46 0
359493307 xionghui D2 Jan. 24, 2026, 4:17 a.m. OK C++20 (GCC 13-64) TESTS 30 46 0
359484673 Joel_Uwu D2 Jan. 24, 2026, 1:20 a.m. OK C++20 (GCC 13-64) TESTS 30 46 0
359482696 FelipeHanada D2 Jan. 24, 2026, 12:18 a.m. OK C++20 (GCC 13-64) TESTS 30 46 0
359478377 thisislike_fan D2 Jan. 23, 2026, 10:04 p.m. OK C++20 (GCC 13-64) TESTS 30 46 0
359478067 E49869826 D2 Jan. 23, 2026, 9:58 p.m. OK C++20 (GCC 13-64) TESTS 30 46 0
359459218 pnlong2706 D2 Jan. 23, 2026, 6:10 p.m. OK C++20 (GCC 13-64) TESTS 30 46 0
359458278 beiyuli D2 Jan. 23, 2026, 6:03 p.m. OK C++20 (GCC 13-64) TESTS 30 46 0
359457124 flying_saucer D2 Jan. 23, 2026, 5:55 p.m. OK C++20 (GCC 13-64) TESTS 30 46 0
359455569 flying_saucer D2 Jan. 23, 2026, 5:43 p.m. OK C++20 (GCC 13-64) TESTS 30 46 0
359491421 fzjsx D2 Jan. 24, 2026, 3:46 a.m. OK C++23 (GCC 14-64, msys2) TESTS 30 31 0
359501523 -zura- D2 Jan. 24, 2026, 5:41 a.m. OK C++23 (GCC 14-64, msys2) TESTS 30 46 0
359500755 Redial D2 Jan. 24, 2026, 5:35 a.m. OK C++23 (GCC 14-64, msys2) TESTS 30 46 0
359496599 xiaogan881 D2 Jan. 24, 2026, 4:59 a.m. OK C++23 (GCC 14-64, msys2) TESTS 30 46 0
359492662 Cjx D2 Jan. 24, 2026, 4:07 a.m. OK C++23 (GCC 14-64, msys2) TESTS 30 46 0
359492331 Happiness_3 D2 Jan. 24, 2026, 4:02 a.m. OK C++23 (GCC 14-64, msys2) TESTS 30 46 0
359491564 fzjsx D2 Jan. 24, 2026, 3:49 a.m. OK C++23 (GCC 14-64, msys2) TESTS 30 46 0
359487966 Jose_17 D2 Jan. 24, 2026, 2:43 a.m. OK C++23 (GCC 14-64, msys2) TESTS 30 46 0
359485061 EndpoInt D2 Jan. 24, 2026, 1:32 a.m. OK C++23 (GCC 14-64, msys2) TESTS 30 46 0
359483828 Krritin D2 Jan. 24, 2026, 12:56 a.m. OK C++23 (GCC 14-64, msys2) TESTS 30 46 0
359451054 pengin_2000 D2 Jan. 23, 2026, 5:15 p.m. OK GNU C11 TESTS 30 31 307200
359443367 rainboy D2 Jan. 23, 2026, 4:30 p.m. OK GNU C11 TESTS 30 78 307200
359466512 hg_2005 D2 Jan. 23, 2026, 7:13 p.m. OK Java 21 TESTS 30 250 614400
359444812 kuch_bhi_random D2 Jan. 23, 2026, 4:32 p.m. OK Java 21 TESTS 30 265 512000
359456992 BurnerAce D2 Jan. 23, 2026, 5:54 p.m. OK Java 21 TESTS 30 328 10752000
359442973 KomalParmar D2 Jan. 23, 2026, 4:29 p.m. OK Java 21 TESTS 30 1328 716800
359481683 tin.le2 D2 Jan. 23, 2026, 11:43 p.m. OK Kotlin 1.7 TESTS 30 609 32460800
359441383 Coder_Area D2 Jan. 23, 2026, 4:27 p.m. OK Kotlin 2.2 TESTS 30 250 24678400
359488308 kaushik.atla D2 Jan. 24, 2026, 2:49 a.m. OK PyPy 3-64 TESTS 30 125 20070400
359439407 Sacred_Conqurer D2 Jan. 23, 2026, 4:23 p.m. OK PyPy 3-64 TESTS 30 125 267571200
359438936 Coder_Sabbir D2 Jan. 23, 2026, 4:22 p.m. OK PyPy 3-64 TESTS 30 140 7065600
359440681 GKarthik26 D2 Jan. 23, 2026, 4:25 p.m. OK PyPy 3-64 TESTS 30 140 7372800
359461539 fatalerror D2 Jan. 23, 2026, 6:26 p.m. OK PyPy 3-64 TESTS 30 140 19763200
359465321 monocrap D2 Jan. 23, 2026, 7 p.m. OK PyPy 3-64 TESTS 30 156 21504000
359488828 Little_Sheep_Yawn D2 Jan. 24, 2026, 2:57 a.m. OK PyPy 3-64 TESTS 30 171 19968000
359439449 smilences D2 Jan. 23, 2026, 4:23 p.m. OK PyPy 3-64 TESTS 30 218 8601600
359450936 Mentholzzz D2 Jan. 23, 2026, 5:14 p.m. OK PyPy 3-64 TESTS 30 234 8499200
359468930 DeadMan69 D2 Jan. 23, 2026, 7:38 p.m. OK PyPy 3-64 TESTS 30 234 20480000
359461180 shade34 D2 Jan. 23, 2026, 6:24 p.m. OK Python 3 TESTS 30 546 5427200

remove filters

Back to search problems