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 . You can apply this operation to the string exactly once: choose index i and move character s_i to the beginning of the string (removing it at the old position). For example, if you apply the operation with index i=4 to the string "abaacd" with numbering from 1 , you get the string "aabacd". What is the lexicographically minimal ^{ dagger} string you can obtain by this operation? ^{ dagger} 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 a single integer n ( 1 <= n <= 10 ^ 5 ) -- the length of the string. 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, on a separate line print the lexicographically smallest string that can be obtained after applying the operation to the original string exactly once. In the first test case, you need to move the last character to the beginning. In the second case, you need to move the second letter "a". In the third set you need to apply the operation with i=1 , then the string will not change. '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
200488289 |
bluemegane |
B |
April 2, 2023, 11:05 p.m. |
OK |
C# 8 |
TESTS |
12 |
92 |
1740800 |
|
|
200479142 |
shakhawat2277 |
B |
April 2, 2023, 8:42 p.m. |
OK |
Clang++20 Diagnostics |
TESTS |
12 |
124 |
12595200 |
|
|
200500751 |
Tomato_bandit |
B |
April 3, 2023, 3:55 a.m. |
OK |
Clang++20 Diagnostics |
TESTS |
12 |
186 |
102400 |
|
|
200475174 |
bnurgeldiyev514 |
B |
April 2, 2023, 7:54 p.m. |
OK |
GNU C11 |
TESTS |
12 |
31 |
102400 |
|
|
200489471 |
dreus |
B |
April 2, 2023, 11:31 p.m. |
OK |
GNU C11 |
TESTS |
12 |
390 |
102400 |
|
|
200501861 |
paramparsewar |
B |
April 3, 2023, 4:15 a.m. |
OK |
GNU C11 |
TESTS |
12 |
390 |
102400 |
|
|
200472473 |
Elalawy |
B |
April 2, 2023, 7:23 p.m. |
OK |
GNU C11 |
TESTS |
12 |
405 |
102400 |
|
|
200473109 |
thunderous_reign |
B |
April 2, 2023, 7:30 p.m. |
OK |
GNU C11 |
TESTS |
12 |
405 |
102400 |
|
|
200459724 |
niloychowdhury |
B |
April 2, 2023, 5:34 p.m. |
OK |
GNU C11 |
TESTS |
12 |
405 |
102400 |
|
|
200458480 |
sanjay77 |
B |
April 2, 2023, 5:27 p.m. |
OK |
GNU C11 |
TESTS |
12 |
405 |
204800 |
|
|
200476224 |
expertaq |
B |
April 2, 2023, 8:07 p.m. |
OK |
GNU C11 |
TESTS |
12 |
421 |
102400 |
|
|
200456993 |
saif2107017 |
B |
April 2, 2023, 5:21 p.m. |
OK |
GNU C11 |
TESTS |
12 |
421 |
102400 |
|
|
200497117 |
lostintianyi |
B |
April 3, 2023, 2:43 a.m. |
OK |
GNU C++14 |
TESTS |
12 |
15 |
102400 |
|
|
200495129 |
Mondayy |
B |
April 3, 2023, 1:59 a.m. |
OK |
GNU C++14 |
TESTS |
12 |
15 |
307200 |
|
|
200485430 |
alsharif.mohamed23 |
B |
April 2, 2023, 10:09 p.m. |
OK |
GNU C++14 |
TESTS |
12 |
15 |
307200 |
|
|
200485001 |
Rzbzz |
B |
April 2, 2023, 10:02 p.m. |
OK |
GNU C++14 |
TESTS |
12 |
15 |
307200 |
|
|
200479431 |
Dima02 |
B |
April 2, 2023, 8:45 p.m. |
OK |
GNU C++14 |
TESTS |
12 |
15 |
307200 |
|
|
200468488 |
ahmedgalal98 |
B |
April 2, 2023, 6:42 p.m. |
OK |
GNU C++14 |
TESTS |
12 |
15 |
307200 |
|
|
200515541 |
rishabh.srivastava |
B |
April 3, 2023, 5:36 a.m. |
OK |
GNU C++14 |
TESTS |
12 |
15 |
307200 |
|
|
200505742 |
vamshi_75 |
B |
April 3, 2023, 5:13 a.m. |
OK |
GNU C++14 |
TESTS |
12 |
15 |
307200 |
|
|
200504961 |
rahilshah17 |
B |
April 3, 2023, 5:03 a.m. |
OK |
GNU C++14 |
TESTS |
12 |
15 |
307200 |
|
|
200502965 |
Halym2007 |
B |
April 3, 2023, 4:32 a.m. |
OK |
GNU C++14 |
TESTS |
12 |
15 |
307200 |
|
|
200462308 |
Dr.one |
B |
April 2, 2023, 5:51 p.m. |
OK |
GNU C++17 |
TESTS |
12 |
15 |
102400 |
|
|
200476397 |
expertaq |
B |
April 2, 2023, 8:09 p.m. |
OK |
GNU C++17 |
TESTS |
12 |
15 |
102400 |
|
|
200494625 |
_M.cpp_ |
B |
April 3, 2023, 1:46 a.m. |
OK |
GNU C++17 |
TESTS |
12 |
15 |
204800 |
|
|
200460674 |
jakubpw |
B |
April 2, 2023, 5:40 p.m. |
OK |
GNU C++17 |
TESTS |
12 |
15 |
204800 |
|
|
200506952 |
Akash_singh11 |
B |
April 3, 2023, 5:16 a.m. |
OK |
GNU C++17 |
TESTS |
12 |
15 |
307200 |
|
|
200521911 |
amansingh81757 |
B |
April 3, 2023, 5:53 a.m. |
OK |
GNU C++17 |
TESTS |
12 |
15 |
307200 |
|
|
200505410 |
Jahid_Hasan10 |
B |
April 3, 2023, 5:09 a.m. |
OK |
GNU C++17 |
TESTS |
12 |
15 |
307200 |
|
|
200521841 |
vinayak270603 |
B |
April 3, 2023, 5:52 a.m. |
OK |
GNU C++17 |
TESTS |
12 |
15 |
307200 |
|
|
200515364 |
vuquangduoc1234 |
B |
April 3, 2023, 5:34 a.m. |
OK |
GNU C++17 |
TESTS |
12 |
15 |
307200 |
|
|
200506969 |
Ahmad_Shamma |
B |
April 3, 2023, 5:17 a.m. |
OK |
GNU C++17 |
TESTS |
12 |
15 |
307200 |
|
|
200457986 |
GoodFella |
B |
April 2, 2023, 5:25 p.m. |
OK |
GNU C++17 (64) |
TESTS |
12 |
0 |
409600 |
|
|
200483763 |
iLLusio |
B |
April 2, 2023, 9:42 p.m. |
OK |
GNU C++17 (64) |
TESTS |
12 |
15 |
307200 |
|
|
200521864 |
OTTFF |
B |
April 3, 2023, 5:52 a.m. |
OK |
GNU C++17 (64) |
TESTS |
12 |
15 |
307200 |
|
|
200497758 |
PlayerFive |
B |
April 3, 2023, 2:56 a.m. |
OK |
GNU C++17 (64) |
TESTS |
12 |
15 |
307200 |
|
|
200488424 |
OutOfThisWorld |
B |
April 2, 2023, 11:08 p.m. |
OK |
GNU C++17 (64) |
TESTS |
12 |
15 |
307200 |
|
|
200472814 |
fakhoury |
B |
April 2, 2023, 7:26 p.m. |
OK |
GNU C++17 (64) |
TESTS |
12 |
15 |
307200 |
|
|
200472566 |
HitmanX97 |
B |
April 2, 2023, 7:24 p.m. |
OK |
GNU C++17 (64) |
TESTS |
12 |
15 |
307200 |
|
|
200464082 |
not_ahmed_hamed |
B |
April 2, 2023, 6:04 p.m. |
OK |
GNU C++17 (64) |
TESTS |
12 |
15 |
307200 |
|
|
200463069 |
rapaz |
B |
April 2, 2023, 5:56 p.m. |
OK |
GNU C++17 (64) |
TESTS |
12 |
15 |
307200 |
|
|
200460903 |
Monir |
B |
April 2, 2023, 5:41 p.m. |
OK |
GNU C++17 (64) |
TESTS |
12 |
15 |
307200 |
|
|
200495754 |
chocola_ps |
B |
April 3, 2023, 2:14 a.m. |
OK |
GNU C++20 (64) |
TESTS |
12 |
0 |
307200 |
|
|
200498493 |
AhmedZedan |
B |
April 3, 2023, 3:12 a.m. |
OK |
GNU C++20 (64) |
TESTS |
12 |
0 |
307200 |
|
|
200498918 |
Derinkuyu |
B |
April 3, 2023, 3:21 a.m. |
OK |
GNU C++20 (64) |
TESTS |
12 |
0 |
307200 |
|
|
200501524 |
shelby70 |
B |
April 3, 2023, 4:09 a.m. |
OK |
GNU C++20 (64) |
TESTS |
12 |
0 |
307200 |
|
|
200502061 |
cowgoodsheep |
B |
April 3, 2023, 4:18 a.m. |
OK |
GNU C++20 (64) |
TESTS |
12 |
0 |
307200 |
|
|
200503330 |
CodingKnight |
B |
April 3, 2023, 4:38 a.m. |
OK |
GNU C++20 (64) |
TESTS |
12 |
0 |
307200 |
|
|
200505118 |
aibark |
B |
April 3, 2023, 5:05 a.m. |
OK |
GNU C++20 (64) |
TESTS |
12 |
0 |
307200 |
|
|
200508640 |
AdiZer0 |
B |
April 3, 2023, 5:26 a.m. |
OK |
GNU C++20 (64) |
TESTS |
12 |
0 |
307200 |
|
|
200512933 |
patidarujjawal |
B |
April 3, 2023, 5:27 a.m. |
OK |
GNU C++20 (64) |
TESTS |
12 |
0 |
307200 |
|
|
200520292 |
PotremZ |
B |
April 3, 2023, 5:44 a.m. |
OK |
GNU C++20 (64) |
TESTS |
12 |
0 |
307200 |
|
|
200491810 |
katomasao |
B |
April 3, 2023, 12:32 a.m. |
OK |
Haskell |
TESTS |
12 |
62 |
15769600 |
|
|
200493921 |
yeroc |
B |
April 3, 2023, 1:28 a.m. |
OK |
Java 11 |
TESTS |
12 |
171 |
0 |
|
|
200462772 |
vijender_8601 |
B |
April 2, 2023, 5:54 p.m. |
OK |
Java 11 |
TESTS |
12 |
171 |
0 |
|
|
200466039 |
Dream-On |
B |
April 2, 2023, 6:20 p.m. |
OK |
Java 11 |
TESTS |
12 |
202 |
0 |
|
|
200472076 |
samitdas03 |
B |
April 2, 2023, 7:18 p.m. |
OK |
Java 11 |
TESTS |
12 |
202 |
0 |
|
|
200464102 |
dinosparton_013 |
B |
April 2, 2023, 6:04 p.m. |
OK |
Java 11 |
TESTS |
12 |
234 |
0 |
|
|
200473230 |
ilasiawo |
B |
April 2, 2023, 7:31 p.m. |
OK |
Java 11 |
TESTS |
12 |
249 |
0 |
|
|
200487140 |
anonyman637 |
B |
April 2, 2023, 10:39 p.m. |
OK |
Java 11 |
TESTS |
12 |
265 |
0 |
|
|
200469643 |
ashutoshchahar1250 |
B |
April 2, 2023, 6:54 p.m. |
OK |
Java 11 |
TESTS |
12 |
265 |
0 |
|
|
200497857 |
fuyou98 |
B |
April 3, 2023, 2:59 a.m. |
OK |
Java 11 |
TESTS |
12 |
280 |
0 |
|
|
200450675 |
Melanholik |
B |
April 2, 2023, 4:29 p.m. |
OK |
Java 11 |
TESTS |
12 |
280 |
0 |
|
|
200459239 |
rated21 |
B |
April 2, 2023, 5:31 p.m. |
OK |
Java 17 |
TESTS |
12 |
170 |
512000 |
|
|
200469685 |
ADust |
B |
April 2, 2023, 6:54 p.m. |
OK |
Java 17 |
TESTS |
12 |
218 |
716800 |
|
|
200468325 |
im_Yash24 |
B |
April 2, 2023, 6:41 p.m. |
OK |
Java 17 |
TESTS |
12 |
218 |
41881600 |
|
|
200494396 |
Jatinydv17 |
B |
April 3, 2023, 1:39 a.m. |
OK |
Java 17 |
TESTS |
12 |
233 |
0 |
|
|
200465428 |
gautam_st |
B |
April 2, 2023, 6:15 p.m. |
OK |
Java 17 |
TESTS |
12 |
233 |
512000 |
|
|
200502249 |
Suraj1607 |
B |
April 3, 2023, 4:21 a.m. |
OK |
Java 17 |
TESTS |
12 |
233 |
716800 |
|
|
200499907 |
HarshChourasiya |
B |
April 3, 2023, 3:40 a.m. |
OK |
Java 17 |
TESTS |
12 |
233 |
716800 |
|
|
200468501 |
Yousef_Badr |
B |
April 2, 2023, 6:43 p.m. |
OK |
Java 17 |
TESTS |
12 |
233 |
819200 |
|
|
200469212 |
aishwarykesarwani |
B |
April 2, 2023, 6:49 p.m. |
OK |
Java 17 |
TESTS |
12 |
249 |
614400 |
|
|
200476822 |
anand_mishra_ |
B |
April 2, 2023, 8:14 p.m. |
OK |
Java 17 |
TESTS |
12 |
249 |
716800 |
|
|
200459743 |
Safawt |
B |
April 2, 2023, 5:34 p.m. |
OK |
Java 8 |
TESTS |
12 |
109 |
0 |
|
|
200459184 |
Koka |
B |
April 2, 2023, 5:31 p.m. |
OK |
Java 8 |
TESTS |
12 |
109 |
0 |
|
|
200453902 |
iamdimonis |
B |
April 2, 2023, 4:34 p.m. |
OK |
Java 8 |
TESTS |
12 |
156 |
0 |
|
|
200458034 |
rozali |
B |
April 2, 2023, 5:25 p.m. |
OK |
Java 8 |
TESTS |
12 |
187 |
0 |
|
|
200461049 |
viral_124 |
B |
April 2, 2023, 5:42 p.m. |
OK |
Java 8 |
TESTS |
12 |
217 |
0 |
|
|
200457279 |
Xsif |
B |
April 2, 2023, 5:22 p.m. |
OK |
MS C++ 2017 |
TESTS |
12 |
31 |
409600 |
|
|
200495685 |
te06008 |
B |
April 3, 2023, 2:12 a.m. |
OK |
MS C++ 2017 |
TESTS |
12 |
46 |
307200 |
|
|
200457886 |
gaurav.kjain |
B |
April 2, 2023, 5:25 p.m. |
OK |
MS C++ 2017 |
TESTS |
12 |
46 |
307200 |
|
|
200508693 |
LittleSharkForest |
B |
April 3, 2023, 5:27 a.m. |
OK |
MS C++ 2017 |
TESTS |
12 |
77 |
102400 |
|
|
200457843 |
Iseeuinmyd |
B |
April 2, 2023, 5:24 p.m. |
OK |
MS C++ 2017 |
TESTS |
12 |
77 |
307200 |
|
|
200484759 |
swseverance |
B |
April 2, 2023, 9:57 p.m. |
OK |
Node.js |
TESTS |
12 |
140 |
5734400 |
|
|
200499346 |
jinzew |
B |
April 3, 2023, 3:29 a.m. |
OK |
PyPy 3 |
TESTS |
12 |
140 |
5734400 |
|
|
200461276 |
Yash_Nandwana |
B |
April 2, 2023, 5:43 p.m. |
OK |
PyPy 3 |
TESTS |
12 |
218 |
7168000 |
|
|
200458164 |
chicosena |
B |
April 2, 2023, 5:26 p.m. |
OK |
PyPy 3 |
TESTS |
12 |
327 |
8499200 |
|
|
200465086 |
GareevBulat |
B |
April 2, 2023, 6:12 p.m. |
OK |
PyPy 3 |
TESTS |
12 |
342 |
6451200 |
|
|
200478347 |
bpaT_Kapaca |
B |
April 2, 2023, 8:33 p.m. |
OK |
PyPy 3 |
TESTS |
12 |
342 |
7372800 |
|
|
200462769 |
nurzhet |
B |
April 2, 2023, 5:54 p.m. |
OK |
PyPy 3 |
TESTS |
12 |
358 |
7577600 |
|
|
200462727 |
quadra |
B |
April 2, 2023, 5:53 p.m. |
OK |
PyPy 3 |
TESTS |
12 |
358 |
7577600 |
|
|
200498471 |
udayan8 |
B |
April 3, 2023, 3:12 a.m. |
OK |
PyPy 3-64 |
TESTS |
12 |
93 |
10240000 |
|
|
200471276 |
almkdadAli |
B |
April 2, 2023, 7:11 p.m. |
OK |
PyPy 3-64 |
TESTS |
12 |
108 |
8704000 |
|
|
200450336 |
bookofsky |
B |
April 2, 2023, 4:28 p.m. |
OK |
PyPy 3-64 |
TESTS |
12 |
124 |
7065600 |
|
|
200477013 |
Kustov_Vadim_533 |
B |
April 2, 2023, 8:17 p.m. |
OK |
PyPy 3-64 |
TESTS |
12 |
124 |
8294400 |
|
|
200472023 |
flexr |
B |
April 2, 2023, 7:18 p.m. |
OK |
PyPy 3-64 |
TESTS |
12 |
124 |
8908800 |
|
|
200474849 |
RobinFromTheHood |
B |
April 2, 2023, 7:50 p.m. |
OK |
PyPy 3-64 |
TESTS |
12 |
124 |
9011200 |
|
|
200469142 |
isekun |
B |
April 2, 2023, 6:49 p.m. |
OK |
PyPy 3-64 |
TESTS |
12 |
124 |
9216000 |
|
|
200476306 |
alexwice |
B |
April 2, 2023, 8:08 p.m. |
OK |
PyPy 3-64 |
TESTS |
12 |
124 |
9420800 |
|
|
200491420 |
Yinch |
B |
April 3, 2023, 12:22 a.m. |
OK |
PyPy 3-64 |
TESTS |
12 |
124 |
9523200 |
|
|
200467498 |
AndreiZherder |
B |
April 2, 2023, 6:32 p.m. |
OK |
PyPy 3-64 |
TESTS |
12 |
124 |
9523200 |
|
|
200508670 |
adrian.riv |
B |
April 3, 2023, 5:26 a.m. |
OK |
Python 3 |
TESTS |
12 |
62 |
409600 |
|
|
200494887 |
aashrithreddypeddi |
B |
April 3, 2023, 1:53 a.m. |
OK |
Python 3 |
TESTS |
12 |
78 |
614400 |
|
|
200494853 |
p0ff |
B |
April 3, 2023, 1:52 a.m. |
OK |
Python 3 |
TESTS |
12 |
78 |
614400 |
|
|
200469438 |
Ysb04 |
B |
April 2, 2023, 6:52 p.m. |
OK |
Python 3 |
TESTS |
12 |
93 |
921600 |
|
|
200492115 |
juanbueno00k |
B |
April 3, 2023, 12:40 a.m. |
OK |
Python 3 |
TESTS |
12 |
109 |
1228800 |
|
|
200500089 |
akash20021118 |
B |
April 3, 2023, 3:43 a.m. |
OK |
Python 3 |
TESTS |
12 |
124 |
102400 |
|
|
200495850 |
gary_cba |
B |
April 3, 2023, 2:16 a.m. |
OK |
Python 3 |
TESTS |
12 |
124 |
102400 |
|
|
200494944 |
2101_czf |
B |
April 3, 2023, 1:54 a.m. |
OK |
Python 3 |
TESTS |
12 |
124 |
102400 |
|
|
200494280 |
itsadityaprakash |
B |
April 3, 2023, 1:36 a.m. |
OK |
Python 3 |
TESTS |
12 |
124 |
102400 |
|
|
200472525 |
mayank1998sharma |
B |
April 2, 2023, 7:23 p.m. |
OK |
Python 3 |
TESTS |
12 |
124 |
102400 |
|
|
200480163 |
niyaznigmatul |
B |
April 2, 2023, 8:53 p.m. |
OK |
Rust 2021 |
TESTS |
12 |
15 |
307200 |
|
|
200514190 |
booiris |
B |
April 3, 2023, 5:31 a.m. |
OK |
Rust 2021 |
TESTS |
12 |
15 |
1126400 |
|
|
remove filters
Back to search problems