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.
Problems
B'You are given a string s of length n . Each character is either one of the first k lowercase Latin letters or a question mark. You are asked to replace every question mark with one of the first k lowercase Latin letters in such a way that the following value is maximized. Let f_i be the maximum length substring of string s , which consists entirely of the i -th Latin letter. A substring of a string is a contiguous subsequence of that string. If the i -th letter doesn 't appear in a string, then f_i is equal to 0 . The value of a string s is the minimum value among f_i for all i from 1 to k . What is the maximum value the string can have? The first line contains two integers n and k ( 1 <= n <= 2 cdot 10^5 ; 1 <= k <= 17 ) -- the length of the string and the number of first Latin letters used. The second line contains a string s , consisting of n characters. Each character is either one of the first k lowercase Latin letters or a question mark. Print a single integer -- the maximum value of the string after every question mark is replaced with one of the first k lowercase Latin letters. In the first example the question marks can be replaced in the following way: "aaaababbbb". f_1 = 4 , f_2 = 4 , thus the answer is 4 . Replacing it like this is also possible: "aaaabbbbbb". That way f_1 = 4 , f_2 = 6 , however, the minimum of them is still 4 . In the second example one of the possible strings is "aabbccdda". In the third example at least one letter won 't appear in the string, thus, the minimum of values f_i is always 0 . '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
122514044 |
zech |
E |
July 14, 2021, 5:19 p.m. |
OK |
GNU C++11 |
TESTS |
38 |
218 |
45875200 |
|
|
122509736 |
nudun001 |
E |
July 14, 2021, 4:42 p.m. |
OK |
GNU C++11 |
TESTS |
38 |
296 |
20992000 |
|
|
122507814 |
CeloriaQuQ |
E |
July 14, 2021, 4:33 p.m. |
OK |
GNU C++11 |
TESTS |
38 |
311 |
18227200 |
|
|
122526924 |
Maystern |
E |
July 14, 2021, 8:28 p.m. |
OK |
GNU C++11 |
TESTS |
38 |
327 |
26009600 |
|
|
122520271 |
pulsatio |
E |
July 14, 2021, 6:33 p.m. |
OK |
GNU C++11 |
TESTS |
38 |
342 |
46489600 |
|
|
122538342 |
--HY-- |
E |
July 15, 2021, 2:10 a.m. |
OK |
GNU C++11 |
TESTS |
38 |
390 |
19558400 |
|
|
122545907 |
ddh |
E |
July 15, 2021, 4:27 a.m. |
OK |
GNU C++11 |
TESTS |
38 |
390 |
40345600 |
|
|
122545668 |
ddh |
E |
July 15, 2021, 4:23 a.m. |
OK |
GNU C++11 |
TESTS |
38 |
452 |
40345600 |
|
|
122509729 |
sean617 |
E |
July 14, 2021, 4:42 p.m. |
OK |
GNU C++11 |
TESTS |
38 |
467 |
26112000 |
|
|
122514598 |
Talentkkggg |
E |
July 14, 2021, 5:24 p.m. |
OK |
GNU C++11 |
TESTS |
38 |
483 |
20684800 |
|
|
122550395 |
coder_gvma_2019_2023 |
E |
July 15, 2021, 5:32 a.m. |
OK |
GNU C++14 |
TESTS |
38 |
171 |
4300800 |
|
|
122502416 |
MooNight |
E |
July 14, 2021, 4:15 p.m. |
OK |
GNU C++14 |
TESTS |
38 |
186 |
21606400 |
|
|
122537961 |
Saacoota |
E |
July 15, 2021, 2:02 a.m. |
OK |
GNU C++14 |
TESTS |
38 |
218 |
37990400 |
|
|
122529108 |
Bedo_Sayed |
E |
July 14, 2021, 9:17 p.m. |
OK |
GNU C++14 |
TESTS |
38 |
264 |
40550400 |
|
|
122508202 |
Hollowed |
E |
July 14, 2021, 4:34 p.m. |
OK |
GNU C++14 |
TESTS |
38 |
265 |
36864000 |
|
|
122503653 |
Redpojoe |
E |
July 14, 2021, 4:19 p.m. |
OK |
GNU C++14 |
TESTS |
38 |
312 |
40857600 |
|
|
122539936 |
miao22 |
E |
July 15, 2021, 2:41 a.m. |
OK |
GNU C++14 |
TESTS |
38 |
420 |
32051200 |
|
|
122503160 |
playf |
E |
July 14, 2021, 4:18 p.m. |
OK |
GNU C++14 |
TESTS |
38 |
436 |
33894400 |
|
|
122499660 |
AhmedEzzatG |
E |
July 14, 2021, 4:06 p.m. |
OK |
GNU C++14 |
TESTS |
38 |
499 |
18432000 |
|
|
122537385 |
Kael_1 |
E |
July 15, 2021, 1:50 a.m. |
OK |
GNU C++14 |
TESTS |
38 |
545 |
63078400 |
|
|
122547198 |
Yc_edu |
E |
July 15, 2021, 4:48 a.m. |
OK |
GNU C++17 |
TESTS |
38 |
156 |
4403200 |
|
|
122547045 |
thu_yc |
E |
July 15, 2021, 4:45 a.m. |
OK |
GNU C++17 |
TESTS |
38 |
156 |
4403200 |
|
|
122546887 |
Ye_Che |
E |
July 15, 2021, 4:43 a.m. |
OK |
GNU C++17 |
TESTS |
38 |
156 |
4505600 |
|
|
122513203 |
ZXyang |
E |
July 14, 2021, 5:11 p.m. |
OK |
GNU C++17 |
TESTS |
38 |
171 |
45772800 |
|
|
122539825 |
Daowuu |
E |
July 15, 2021, 2:39 a.m. |
OK |
GNU C++17 |
TESTS |
38 |
186 |
19251200 |
|
|
122523667 |
kolina |
E |
July 14, 2021, 7:27 p.m. |
OK |
GNU C++17 |
TESTS |
38 |
187 |
8396800 |
|
|
122535135 |
Yzm007 |
E |
July 15, 2021, 12:53 a.m. |
OK |
GNU C++17 |
TESTS |
38 |
202 |
18124800 |
|
|
122535154 |
Yzm007 |
E |
July 15, 2021, 12:54 a.m. |
OK |
GNU C++17 |
TESTS |
38 |
202 |
18124800 |
|
|
122517640 |
Coding_boy |
E |
July 14, 2021, 6 p.m. |
OK |
GNU C++17 |
TESTS |
38 |
218 |
32051200 |
|
|
122506050 |
dXqwq |
E |
July 14, 2021, 4:28 p.m. |
OK |
GNU C++17 |
TESTS |
38 |
233 |
71782400 |
|
|
122537741 |
idontreallyknow |
E |
July 15, 2021, 1:57 a.m. |
OK |
GNU C++17 (64) |
TESTS |
38 |
187 |
19251200 |
|
|
122524672 |
Bungmint |
E |
July 14, 2021, 7:43 p.m. |
OK |
GNU C++17 (64) |
TESTS |
38 |
233 |
32563200 |
|
|
122499733 |
dnshgyl21 |
E |
July 14, 2021, 4:06 p.m. |
OK |
GNU C++17 (64) |
TESTS |
38 |
249 |
32563200 |
|
|
122509677 |
keijak |
E |
July 14, 2021, 4:42 p.m. |
OK |
GNU C++17 (64) |
TESTS |
38 |
280 |
42700800 |
|
|
122500057 |
hitonanode |
E |
July 14, 2021, 4:07 p.m. |
OK |
GNU C++17 (64) |
TESTS |
38 |
296 |
32972800 |
|
|
122513251 |
moo. |
E |
July 14, 2021, 5:11 p.m. |
OK |
GNU C++17 (64) |
TESTS |
38 |
312 |
32665600 |
|
|
122537506 |
hang2021 |
E |
July 15, 2021, 1:52 a.m. |
OK |
GNU C++17 (64) |
TESTS |
38 |
342 |
18944000 |
|
|
122505010 |
magnified |
E |
July 14, 2021, 4:24 p.m. |
OK |
GNU C++17 (64) |
TESTS |
38 |
342 |
33075200 |
|
|
122526236 |
Fortin |
E |
July 14, 2021, 8:14 p.m. |
OK |
GNU C++17 (64) |
TESTS |
38 |
343 |
19353600 |
|
|
122503017 |
kmjp |
E |
July 14, 2021, 4:17 p.m. |
OK |
GNU C++17 (64) |
TESTS |
38 |
343 |
32870400 |
|
|
122517428 |
bobib |
E |
July 14, 2021, 5:57 p.m. |
OK |
Java 11 |
TESTS |
38 |
904 |
46694400 |
|
|
122499636 |
Tolob |
E |
July 14, 2021, 4:06 p.m. |
OK |
Java 11 |
TESTS |
38 |
1903 |
101376000 |
|
|
122510963 |
Tlatoani |
E |
July 14, 2021, 4:51 p.m. |
OK |
Kotlin |
TESTS |
38 |
1762 |
96665600 |
|
|
122502443 |
Friska |
E |
July 14, 2021, 4:15 p.m. |
OK |
MS C++ 2017 |
TESTS |
38 |
483 |
19046400 |
|
|
122511440 |
azukun |
E |
July 14, 2021, 4:55 p.m. |
OK |
.NET Core C# |
TESTS |
38 |
452 |
79052800 |
|
|
122507687 |
azukun |
E |
July 14, 2021, 4:33 p.m. |
OK |
.NET Core C# |
TESTS |
38 |
1341 |
105267200 |
|
|
122508745 |
Kiri8128 |
E |
July 14, 2021, 4:36 p.m. |
OK |
PyPy 3 |
TESTS |
38 |
1107 |
51507200 |
|
|
122545357 |
hxu10 |
E |
July 15, 2021, 4:17 a.m. |
OK |
PyPy 3 |
TESTS |
38 |
1153 |
51507200 |
|
|
122543239 |
hxu10 |
E |
July 15, 2021, 3:39 a.m. |
OK |
PyPy 3 |
TESTS |
38 |
1184 |
51302400 |
|
|
122543351 |
hxu10 |
E |
July 15, 2021, 3:41 a.m. |
OK |
PyPy 3 |
TESTS |
38 |
1325 |
51302400 |
|
|
122545264 |
hxu10 |
E |
July 15, 2021, 4:16 a.m. |
OK |
PyPy 3 |
TESTS |
38 |
1419 |
51404800 |
|
|
122543680 |
hxu10 |
E |
July 15, 2021, 3:47 a.m. |
OK |
PyPy 3 |
TESTS |
38 |
1450 |
51712000 |
|
|
122519585 |
silvertint |
E |
July 14, 2021, 6:25 p.m. |
OK |
PyPy 3 |
TESTS |
38 |
1528 |
130867200 |
|
|
122545212 |
hxu10 |
E |
July 15, 2021, 4:15 a.m. |
OK |
PyPy 3 |
TESTS |
38 |
2215 |
51609600 |
|
|
122542122 |
hxu10 |
E |
July 15, 2021, 3:20 a.m. |
OK |
PyPy 3 |
TESTS |
38 |
2402 |
111820800 |
|
|
122500684 |
chinerist |
E |
July 14, 2021, 4:09 p.m. |
OK |
PyPy 3 |
TESTS |
38 |
2900 |
67481600 |
|
|
122536851 |
ngtkana |
E |
July 15, 2021, 1:37 a.m. |
OK |
Rust |
TESTS |
38 |
935 |
24985600 |
|
|
122536732 |
ngtkana |
E |
July 15, 2021, 1:34 a.m. |
OK |
Rust |
TESTS |
38 |
1122 |
37888000 |
|
|
122536504 |
ngtkana |
E |
July 15, 2021, 1:28 a.m. |
OK |
Rust |
TESTS |
38 |
2340 |
37888000 |
|
|
remove filters
Back to search problems