Kotlin Heroes: Episode 13

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
2141 Kotlin Heroes: Episode 13 FINISHED False 9000 18717923 Sept. 12, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 255 ) E Perfect Cut PROGRAMMING *special dp greedy

You are given a string (s) consisting of characters 0 , 1 , and/or ? . Let's call a binary (consisting of 0 and/or 1 ) string perfect if you can cut the string into two non-empty parts: a prefix (a) and the suffix (b), such that (a_i \ge b_i) for each (i) from (1) to (\min(|a|, |b|)). Your task is to calculate the number of ways to replace all the question marks (independently) with zeros and ones so that the resulting string is perfect mod. Two ways are considered different if there exists at least one position that has different characters in these two ways. Since the answer can be large, print it modulo (998244353). The first line contains a single integer (t) ((1 \le t \le 10^4)) — the number of test cases. The only line of each test case contains a string (s) ((2 \le |s| \le 2 \cdot 10^5)), consisting of characters 0 , 1 , and/or ? . Additional constraint on the input: the sum of the lengths of the strings (s) over all test cases doesn't exceed (2 \cdot 10^5). For each test case, print a single integer — the number of ways to replace all the question marks (independently) with zeros and ones so that the resulting string is perfect, taken modulo (998244353). In the first test case, the string 001 can be split into a prefix of length (1) and a suffix of length (2). In the fourth test case, the following strings can be obtained: The string 11010 , which can be split into a prefix of length (2) and a suffix of length (3); The string 11000 , which can be split into a prefix of length (4) and a suffix of length (1).

Tutorials

Kotlin Heroes 13 Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
338239969 MUI1344 E Sept. 12, 2025, 4:07 p.m. OK Kotlin 1.7 TESTS 10 265 921600
338236314 potato167 E Sept. 12, 2025, 3:43 p.m. OK Kotlin 1.7 TESTS 10 265 2252800
338232854 vikranttarwatkar2003 E Sept. 12, 2025, 3:23 p.m. OK Kotlin 1.7 TESTS 10 265 2355200
338239877 yarasikavitha E Sept. 12, 2025, 4:07 p.m. OK Kotlin 1.7 TESTS 10 265 3072000
338246820 manhmkl87 E Sept. 12, 2025, 4:56 p.m. OK Kotlin 1.7 TESTS 10 280 921600
338231301 Khalid_Kamal_ E Sept. 12, 2025, 3:14 p.m. OK Kotlin 1.7 TESTS 10 281 1228800
338272050 maspy E Sept. 12, 2025, 9:06 p.m. OK Kotlin 1.7 TESTS 10 281 1331200
338244691 yadavshivam6033 E Sept. 12, 2025, 4:40 p.m. OK Kotlin 1.7 TESTS 10 296 1331200
338232102 Ra16bit E Sept. 12, 2025, 3:18 p.m. OK Kotlin 1.7 TESTS 10 296 1536000
338230904 GNU E Sept. 12, 2025, 3:12 p.m. OK Kotlin 1.7 TESTS 10 296 1945600
338243549 MagicalGirl E Sept. 12, 2025, 4:32 p.m. OK Kotlin 1.9 TESTS 10 140 0
338239023 Intellegent E Sept. 12, 2025, 4:01 p.m. OK Kotlin 1.9 TESTS 10 155 0
338236286 __jk__ E Sept. 12, 2025, 3:43 p.m. OK Kotlin 1.9 TESTS 10 156 0
338234114 MohamedSaeed E Sept. 12, 2025, 3:30 p.m. OK Kotlin 1.9 TESTS 10 156 0
338244999 shashanth2004 E Sept. 12, 2025, 4:42 p.m. OK Kotlin 1.9 TESTS 10 171 0
338240993 dpatel_108 E Sept. 12, 2025, 4:14 p.m. OK Kotlin 1.9 TESTS 10 171 0
338235984 Svyat E Sept. 12, 2025, 3:41 p.m. OK Kotlin 1.9 TESTS 10 171 0
338233325 errorgorn E Sept. 12, 2025, 3:26 p.m. OK Kotlin 1.9 TESTS 10 171 0
338229567 wxhtzdy E Sept. 12, 2025, 3:04 p.m. OK Kotlin 1.9 TESTS 10 171 0
338227893 arvindf232 E Sept. 12, 2025, 2:55 p.m. OK Kotlin 1.9 TESTS 10 171 0
338242437 sdeathft E Sept. 12, 2025, 4:24 p.m. OK Kotlin 2.2 TESTS 10 140 0
338239111 OpGm E Sept. 12, 2025, 4:01 p.m. OK Kotlin 2.2 TESTS 10 140 0
338232943 Jlyfish E Sept. 12, 2025, 3:23 p.m. OK Kotlin 2.2 TESTS 10 140 0
338288871 lto5 E Sept. 13, 2025, 3:11 a.m. OK Kotlin 2.2 TESTS 10 155 0
338288315 Hoang_Thien_De E Sept. 13, 2025, 3 a.m. OK Kotlin 2.2 TESTS 10 155 0
338247079 Seif_Shaheen E Sept. 12, 2025, 4:58 p.m. OK Kotlin 2.2 TESTS 10 155 0
338243649 abhaykumar70953 E Sept. 12, 2025, 4:32 p.m. OK Kotlin 2.2 TESTS 10 155 0
338236580 p4106650 E Sept. 12, 2025, 3:44 p.m. OK Kotlin 2.2 TESTS 10 155 0
338229110 bribritt E Sept. 12, 2025, 3:02 p.m. OK Kotlin 2.2 TESTS 10 155 0
338245078 manojthapaa E Sept. 12, 2025, 4:43 p.m. OK Kotlin 2.2 TESTS 10 156 0

remove filters

Back to search problems