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 consisting of lowercase English letters, and an integer k . In one step you can perform any one of the two operations below: You can make as many steps as you want (possibly, zero). Your task is to find the lexicographically smallest string you can obtain after some number of steps. A string a is lexicographically smaller than a string b of the same length if and only if the following holds: Each test contains multiple test cases. The first line contains the number of test cases t ( 1 <= t <= 10^4 ). The description of the test cases follows. The first line of each test case contains two integers n and k ( 1 <= k < n <= 10^5 ). The second line of each test case contains the string s of length n consisting of lowercase English letters. It is guaranteed that the sum of n over all test cases does not exceed 10^5 . For each test case, print the lexicographically smallest string after doing some (possibly, zero) steps. In the first test case, we can obtain the string "aimn" using the following operations: It can be proven that we cannot obtain any string lexicographically smaller than "aimn". Therefore, "aimn" is the answer. In the second test case, we can obtain the string "aandp" using the following operations: It can be proven that we cannot obtain any string lexicographically smaller than "aandp". Therefore, "aandp" is the answer. '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
220596785 |
Avinvini |
B |
Aug. 26, 2023, 5:32 p.m. |
OK |
C# 10 |
TESTS |
16 |
342 |
3584000 |
|
|
220606787 |
Gassa |
B |
Aug. 26, 2023, 7:48 p.m. |
OK |
D |
TESTS |
16 |
62 |
4403200 |
|
|
220631173 |
zhouyuzi0113 |
B |
Aug. 27, 2023, 3:32 a.m. |
OK |
GNU C++14 |
TESTS |
17 |
15 |
307200 |
|
|
220629741 |
When_C |
B |
Aug. 27, 2023, 3:05 a.m. |
OK |
GNU C++14 |
TESTS |
17 |
15 |
307200 |
|
|
220621627 |
xkaxingz |
B |
Aug. 26, 2023, 11:43 p.m. |
OK |
GNU C++14 |
TESTS |
16 |
15 |
307200 |
|
|
220627959 |
dream7 |
B |
Aug. 27, 2023, 2:27 a.m. |
OK |
GNU C++14 |
TESTS |
17 |
15 |
409600 |
|
|
220622019 |
slenbol |
B |
Aug. 26, 2023, 11:56 p.m. |
OK |
GNU C++14 |
TESTS |
16 |
15 |
409600 |
|
|
220594393 |
MysteryGuy2 |
B |
Aug. 26, 2023, 5:23 p.m. |
OK |
GNU C++14 |
TESTS |
16 |
15 |
409600 |
|
|
220593693 |
usernameson |
B |
Aug. 26, 2023, 5:20 p.m. |
OK |
GNU C++14 |
TESTS |
16 |
15 |
409600 |
|
|
220639166 |
prosanskar |
B |
Aug. 27, 2023, 5:38 a.m. |
OK |
GNU C++14 |
TESTS |
17 |
15 |
512000 |
|
|
220584725 |
sr00 |
B |
Aug. 26, 2023, 4:46 p.m. |
OK |
GNU C++14 |
TESTS |
16 |
15 |
512000 |
|
|
220583483 |
rohit2593 |
B |
Aug. 26, 2023, 4:42 p.m. |
OK |
GNU C++14 |
TESTS |
16 |
15 |
512000 |
|
|
220584865 |
MohamedSameh |
B |
Aug. 26, 2023, 4:47 p.m. |
OK |
GNU C++17 |
TESTS |
16 |
15 |
102400 |
|
|
220589962 |
mmi404 |
B |
Aug. 26, 2023, 5:06 p.m. |
OK |
GNU C++17 |
TESTS |
16 |
15 |
204800 |
|
|
220611553 |
mayank.official |
B |
Aug. 26, 2023, 8:35 p.m. |
OK |
GNU C++17 |
TESTS |
16 |
15 |
307200 |
|
|
220608733 |
iffatul_anon |
B |
Aug. 26, 2023, 8:04 p.m. |
OK |
GNU C++17 |
TESTS |
16 |
15 |
307200 |
|
|
220586285 |
UnSolvedBug_Farhan |
B |
Aug. 26, 2023, 4:52 p.m. |
OK |
GNU C++17 |
TESTS |
16 |
15 |
307200 |
|
|
220634396 |
mazo0n |
B |
Aug. 27, 2023, 4:33 a.m. |
OK |
GNU C++17 |
TESTS |
17 |
15 |
409600 |
|
|
220632790 |
Hhl8924 |
B |
Aug. 27, 2023, 4:04 a.m. |
OK |
GNU C++17 |
TESTS |
17 |
15 |
409600 |
|
|
220631841 |
Subhash_fl55 |
B |
Aug. 27, 2023, 3:45 a.m. |
OK |
GNU C++17 |
TESTS |
17 |
15 |
409600 |
|
|
220631353 |
YangJackie |
B |
Aug. 27, 2023, 3:36 a.m. |
OK |
GNU C++17 |
TESTS |
17 |
15 |
409600 |
|
|
220627091 |
NoLove |
B |
Aug. 27, 2023, 2:07 a.m. |
OK |
GNU C++17 |
TESTS |
17 |
15 |
409600 |
|
|
220638754 |
zhangxiaogao |
B |
Aug. 27, 2023, 5:33 a.m. |
OK |
GNU C++17 (64) |
TESTS |
17 |
15 |
307200 |
|
|
220628554 |
privatehsy |
B |
Aug. 27, 2023, 2:40 a.m. |
OK |
GNU C++17 (64) |
TESTS |
17 |
15 |
307200 |
|
|
220582928 |
awesomeguy856 |
B |
Aug. 26, 2023, 4:40 p.m. |
OK |
GNU C++17 (64) |
TESTS |
16 |
15 |
307200 |
|
|
220636173 |
Owmicron |
B |
Aug. 27, 2023, 4:58 a.m. |
OK |
GNU C++17 (64) |
TESTS |
17 |
15 |
409600 |
|
|
220635480 |
_okay_ |
B |
Aug. 27, 2023, 4:49 a.m. |
OK |
GNU C++17 (64) |
TESTS |
17 |
15 |
409600 |
|
|
220635280 |
Oinng |
B |
Aug. 27, 2023, 4:46 a.m. |
OK |
GNU C++17 (64) |
TESTS |
17 |
15 |
409600 |
|
|
220631172 |
hskyr- |
B |
Aug. 27, 2023, 3:32 a.m. |
OK |
GNU C++17 (64) |
TESTS |
17 |
15 |
409600 |
|
|
220625213 |
orzdevinwang |
B |
Aug. 27, 2023, 1:21 a.m. |
OK |
GNU C++17 (64) |
TESTS |
17 |
15 |
409600 |
|
|
220624155 |
Poseidon. |
B |
Aug. 27, 2023, 12:54 a.m. |
OK |
GNU C++17 (64) |
TESTS |
17 |
15 |
409600 |
|
|
220624087 |
joshboi |
B |
Aug. 27, 2023, 12:52 a.m. |
OK |
GNU C++17 (64) |
TESTS |
17 |
15 |
409600 |
|
|
220595887 |
dpixter |
B |
Aug. 26, 2023, 5:29 p.m. |
OK |
GNU C++20 (64) |
TESTS |
16 |
15 |
204800 |
|
|
220641127 |
sudharshan281 |
B |
Aug. 27, 2023, 6 a.m. |
OK |
GNU C++20 (64) |
TESTS |
17 |
15 |
307200 |
|
|
220640507 |
IwiG |
B |
Aug. 27, 2023, 5:53 a.m. |
OK |
GNU C++20 (64) |
TESTS |
17 |
15 |
307200 |
|
|
220640018 |
amirrrr |
B |
Aug. 27, 2023, 5:47 a.m. |
OK |
GNU C++20 (64) |
TESTS |
17 |
15 |
307200 |
|
|
220639503 |
chfychin |
B |
Aug. 27, 2023, 5:41 a.m. |
OK |
GNU C++20 (64) |
TESTS |
17 |
15 |
307200 |
|
|
220639015 |
ThunderXGod |
B |
Aug. 27, 2023, 5:36 a.m. |
OK |
GNU C++20 (64) |
TESTS |
17 |
15 |
307200 |
|
|
220638985 |
LovelyLife |
B |
Aug. 27, 2023, 5:36 a.m. |
OK |
GNU C++20 (64) |
TESTS |
17 |
15 |
307200 |
|
|
220638485 |
wakaka |
B |
Aug. 27, 2023, 5:29 a.m. |
OK |
GNU C++20 (64) |
TESTS |
17 |
15 |
307200 |
|
|
220638308 |
amanxjha_ |
B |
Aug. 27, 2023, 5:27 a.m. |
OK |
GNU C++20 (64) |
TESTS |
17 |
15 |
307200 |
|
|
220638057 |
Mark2012 |
B |
Aug. 27, 2023, 5:24 a.m. |
OK |
GNU C++20 (64) |
TESTS |
17 |
15 |
307200 |
|
|
220596896 |
SDUFE_ACM |
B |
Aug. 26, 2023, 5:32 p.m. |
OK |
Go |
TESTS |
16 |
841 |
7270400 |
|
|
220622727 |
Harwinvanak |
B |
Aug. 27, 2023, 12:15 a.m. |
OK |
Java 11 |
TESTS |
16 |
186 |
0 |
|
|
220617182 |
mohamedhassan_c |
B |
Aug. 26, 2023, 9:58 p.m. |
OK |
Java 11 |
TESTS |
16 |
218 |
8601600 |
|
|
220617103 |
polsage |
B |
Aug. 26, 2023, 9:56 p.m. |
OK |
Java 11 |
TESTS |
16 |
233 |
0 |
|
|
220585281 |
shivanshu_100 |
B |
Aug. 26, 2023, 4:48 p.m. |
OK |
Java 11 |
TESTS |
16 |
265 |
0 |
|
|
220632232 |
believe18 |
B |
Aug. 27, 2023, 3:53 a.m. |
OK |
Java 11 |
TESTS |
17 |
280 |
0 |
|
|
220620150 |
biu_biu_biu |
B |
Aug. 26, 2023, 11:03 p.m. |
OK |
Java 11 |
TESTS |
16 |
311 |
0 |
|
|
220629648 |
12th_Fail |
B |
Aug. 27, 2023, 3:03 a.m. |
OK |
Java 11 |
TESTS |
17 |
312 |
0 |
|
|
220593502 |
vvishal_05 |
B |
Aug. 26, 2023, 5:19 p.m. |
OK |
Java 11 |
TESTS |
16 |
342 |
0 |
|
|
220628215 |
wizardleen |
B |
Aug. 27, 2023, 2:33 a.m. |
OK |
Java 17 |
TESTS |
17 |
202 |
9011200 |
|
|
220582015 |
faresbadr316 |
B |
Aug. 26, 2023, 4:37 p.m. |
OK |
Java 17 |
TESTS |
16 |
218 |
409600 |
|
|
220609021 |
swatishivam23 |
B |
Aug. 26, 2023, 8:07 p.m. |
OK |
Java 17 |
TESTS |
16 |
218 |
614400 |
|
|
220630890 |
Gladery |
B |
Aug. 27, 2023, 3:27 a.m. |
OK |
Java 17 |
TESTS |
17 |
233 |
512000 |
|
|
220622518 |
mcrash12 |
B |
Aug. 27, 2023, 12:10 a.m. |
OK |
Java 17 |
TESTS |
16 |
249 |
921600 |
|
|
220634685 |
Yousef_Badr |
B |
Aug. 27, 2023, 4:38 a.m. |
OK |
Java 17 |
TESTS |
17 |
264 |
409600 |
|
|
220594396 |
d4rkbug |
B |
Aug. 26, 2023, 5:23 p.m. |
OK |
Java 17 |
TESTS |
16 |
280 |
1126400 |
|
|
220585941 |
AKhacks |
B |
Aug. 26, 2023, 4:51 p.m. |
OK |
Java 17 |
TESTS |
16 |
295 |
409600 |
|
|
220633511 |
puretiasha2004 |
B |
Aug. 27, 2023, 4:18 a.m. |
OK |
Java 17 |
TESTS |
17 |
311 |
819200 |
|
|
220590336 |
rohilkadam36 |
B |
Aug. 26, 2023, 5:07 p.m. |
OK |
Java 17 |
TESTS |
16 |
514 |
716800 |
|
|
220616844 |
leonlian |
B |
Aug. 26, 2023, 9:51 p.m. |
OK |
Java 8 |
TESTS |
16 |
124 |
0 |
|
|
220606254 |
vijay_panwar12 |
B |
Aug. 26, 2023, 7:45 p.m. |
OK |
Java 8 |
TESTS |
16 |
139 |
0 |
|
|
220619917 |
Akarsh2810 |
B |
Aug. 26, 2023, 10:58 p.m. |
OK |
Java 8 |
TESTS |
16 |
155 |
0 |
|
|
220587232 |
This_is_Rish |
B |
Aug. 26, 2023, 4:55 p.m. |
OK |
Java 8 |
TESTS |
16 |
171 |
0 |
|
|
220607142 |
Sir_Isaac |
B |
Aug. 26, 2023, 7:50 p.m. |
OK |
Java 8 |
TESTS |
16 |
186 |
0 |
|
|
220641157 |
too_depressed |
B |
Aug. 27, 2023, 6 a.m. |
OK |
Java 8 |
TESTS |
17 |
202 |
0 |
|
|
220635536 |
codechefpurpose2023 |
B |
Aug. 27, 2023, 4:49 a.m. |
OK |
Java 8 |
TESTS |
17 |
234 |
0 |
|
|
220582821 |
mickeyarora6250 |
B |
Aug. 26, 2023, 4:40 p.m. |
OK |
Java 8 |
TESTS |
16 |
248 |
0 |
|
|
220625883 |
lemma_Forever |
B |
Aug. 27, 2023, 1:38 a.m. |
OK |
Java 8 |
TESTS |
17 |
420 |
0 |
|
|
220633992 |
Sumitsingh7 |
B |
Aug. 27, 2023, 4:26 a.m. |
OK |
Java 8 |
TESTS |
17 |
420 |
7680000 |
|
|
220608897 |
tatianyi |
B |
Aug. 26, 2023, 8:06 p.m. |
OK |
MS C++ 2017 |
TESTS |
16 |
15 |
409600 |
|
|
220586229 |
shushukl |
B |
Aug. 26, 2023, 4:52 p.m. |
OK |
MS C++ 2017 |
TESTS |
16 |
31 |
512000 |
|
|
220635987 |
shamugupta8259 |
B |
Aug. 27, 2023, 4:56 a.m. |
OK |
MS C++ 2017 |
TESTS |
17 |
764 |
716800 |
|
|
220621422 |
MenaceJn |
B |
Aug. 26, 2023, 11:38 p.m. |
OK |
PyPy 3 |
TESTS |
16 |
202 |
7987200 |
|
|
220594046 |
rasheed_ashen_one |
B |
Aug. 26, 2023, 5:22 p.m. |
OK |
PyPy 3 |
TESTS |
16 |
217 |
8601600 |
|
|
220607958 |
iinaamasum |
B |
Aug. 26, 2023, 7:56 p.m. |
OK |
PyPy 3 |
TESTS |
16 |
280 |
12288000 |
|
|
220639661 |
jvatsal0709 |
B |
Aug. 27, 2023, 5:43 a.m. |
OK |
PyPy 3 |
TESTS |
17 |
374 |
8089600 |
|
|
220595596 |
2momo2 |
B |
Aug. 26, 2023, 5:28 p.m. |
OK |
PyPy 3 |
TESTS |
16 |
436 |
9830400 |
|
|
220583071 |
justin_g_20 |
B |
Aug. 26, 2023, 4:41 p.m. |
OK |
PyPy 3 |
TESTS |
16 |
452 |
9113600 |
|
|
220609042 |
WalrusRamen21 |
B |
Aug. 26, 2023, 8:07 p.m. |
OK |
PyPy 3 |
TESTS |
16 |
483 |
9420800 |
|
|
220596311 |
mathsworm |
B |
Aug. 26, 2023, 5:30 p.m. |
OK |
PyPy 3 |
TESTS |
16 |
483 |
9728000 |
|
|
220583209 |
PrakharGupta21 |
B |
Aug. 26, 2023, 4:41 p.m. |
OK |
PyPy 3 |
TESTS |
16 |
529 |
11571200 |
|
|
220597030 |
helen_strakhal |
B |
Aug. 26, 2023, 5:33 p.m. |
OK |
PyPy 3 |
TESTS |
16 |
545 |
10240000 |
|
|
220625198 |
gardengnome |
B |
Aug. 27, 2023, 1:20 a.m. |
OK |
PyPy 3-64 |
TESTS |
17 |
140 |
13107200 |
|
|
220632981 |
Ana_naS |
B |
Aug. 27, 2023, 4:07 a.m. |
OK |
PyPy 3-64 |
TESTS |
17 |
140 |
13926400 |
|
|
220626177 |
sorcerer_21 |
B |
Aug. 27, 2023, 1:45 a.m. |
OK |
PyPy 3-64 |
TESTS |
17 |
155 |
8499200 |
|
|
220622728 |
rmr |
B |
Aug. 27, 2023, 12:15 a.m. |
OK |
PyPy 3-64 |
TESTS |
16 |
155 |
13516800 |
|
|
220614409 |
alexwice |
B |
Aug. 26, 2023, 9:11 p.m. |
OK |
PyPy 3-64 |
TESTS |
16 |
155 |
21401600 |
|
|
220625727 |
sorcerer_21 |
B |
Aug. 27, 2023, 1:35 a.m. |
OK |
PyPy 3-64 |
TESTS |
17 |
202 |
23449600 |
|
|
220630807 |
sukaya |
B |
Aug. 27, 2023, 3:25 a.m. |
OK |
PyPy 3-64 |
TESTS |
17 |
233 |
22528000 |
|
|
220630765 |
sukaya |
B |
Aug. 27, 2023, 3:24 a.m. |
OK |
PyPy 3-64 |
TESTS |
17 |
295 |
17510400 |
|
|
220634729 |
sumitsharmaiitd |
B |
Aug. 27, 2023, 4:38 a.m. |
OK |
PyPy 3-64 |
TESTS |
17 |
327 |
12492800 |
|
|
220611987 |
MistaFlash |
B |
Aug. 26, 2023, 8:40 p.m. |
OK |
PyPy 3-64 |
TESTS |
16 |
358 |
12288000 |
|
|
220588140 |
rinsane |
B |
Aug. 26, 2023, 4:59 p.m. |
OK |
Python 3 |
TESTS |
16 |
77 |
2764800 |
|
|
220610293 |
Aravind |
B |
Aug. 26, 2023, 8:21 p.m. |
OK |
Python 3 |
TESTS |
16 |
78 |
3379200 |
|
|
220625656 |
pennymagic156 |
B |
Aug. 27, 2023, 1:32 a.m. |
OK |
Python 3 |
TESTS |
17 |
78 |
8601600 |
|
|
220636870 |
AKKAN |
B |
Aug. 27, 2023, 5:09 a.m. |
OK |
Python 3 |
TESTS |
17 |
93 |
2252800 |
|
|
220618157 |
momenelmesady4803 |
B |
Aug. 26, 2023, 10:17 p.m. |
OK |
Python 3 |
TESTS |
16 |
93 |
2969600 |
|
|
220618139 |
momenashraf482003 |
B |
Aug. 26, 2023, 10:17 p.m. |
OK |
Python 3 |
TESTS |
16 |
93 |
2969600 |
|
|
220629588 |
sukaya |
B |
Aug. 27, 2023, 3:02 a.m. |
OK |
Python 3 |
TESTS |
17 |
108 |
4812800 |
|
|
220606323 |
VioletVal |
B |
Aug. 26, 2023, 7:45 p.m. |
OK |
Python 3 |
TESTS |
16 |
124 |
1740800 |
|
|
220636551 |
BeanBurrito |
B |
Aug. 27, 2023, 5:05 a.m. |
OK |
Python 3 |
TESTS |
17 |
124 |
1843200 |
|
|
220633482 |
rinsane |
B |
Aug. 27, 2023, 4:17 a.m. |
OK |
Python 3 |
TESTS |
17 |
124 |
2355200 |
|
|
220634125 |
KumbKaran |
B |
Aug. 27, 2023, 4:29 a.m. |
OK |
Rust 2021 |
TESTS |
17 |
15 |
1740800 |
|
|
220634848 |
KumbKaran |
B |
Aug. 27, 2023, 4:40 a.m. |
OK |
Rust 2021 |
TESTS |
17 |
31 |
1740800 |
|
|
220634670 |
KumbKaran |
B |
Aug. 27, 2023, 4:38 a.m. |
OK |
Rust 2021 |
TESTS |
17 |
31 |
1740800 |
|
|
220634416 |
KumbKaran |
B |
Aug. 27, 2023, 4:34 a.m. |
OK |
Rust 2021 |
TESTS |
17 |
31 |
1740800 |
|
|
220624726 |
AkagiYuu |
B |
Aug. 27, 2023, 1:10 a.m. |
OK |
Rust 2021 |
TESTS |
17 |
124 |
409600 |
|
|
remove filters
Back to search problems