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'There was a string s which was supposed to be encrypted. For this reason, all 26 lowercase English letters were arranged in a circle in some order, afterwards, each letter in s was replaced with the one that follows in clockwise order, in that way the string t was obtained. You are given a string t . Determine the lexicographically smallest string s that could be a prototype of the given string t . A string a is lexicographically smaller than a string b of the same length if and only if: The first line of the input contains a single integer t ( 1 <= t <= 3 cdot 10^4 ) -- the number of test cases. The description of test cases follows. The first line of each test case contains one integer n ( 1 <= n <= 10^5 ) -- the length of the string t . The next line contains the string t of the length n , containing lowercase English letters. It is guaranteed that the sum of n over all test cases doesn 't exceed 2 cdot 10^5 . For each test case, output a single line containing the lexicographically smallest string s which could be a prototype of t . In the first test case, we couldn 't have the string "a", since the letter a would transit to itself. Lexicographically the second string "b" is suitable as an answer. In the second test case, the string "aa" is not suitable, since a would transit to itself. "ab" is not suitable, since the circle would be closed with 2 letters, but it must contain all 26 . The next string "ac" is suitable. Below you can see the schemes for the first three test cases. The non-involved letters are skipped, they can be arbitrary placed in the gaps. '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
174460625 |
chrisfcoder |
C |
Oct. 3, 2022, 2:34 a.m. |
OK |
C# 10 |
TESTS |
21 |
171 |
3276800 |
|
|
174435206 |
FatalityNT |
C |
Oct. 2, 2022, 5:55 p.m. |
OK |
C# 8 |
TESTS |
21 |
872 |
4300800 |
|
|
174443653 |
NenadDapic |
C |
Oct. 2, 2022, 7:35 p.m. |
OK |
FPC |
TESTS |
21 |
716 |
204800 |
|
|
174444725 |
NenadDapic |
C |
Oct. 2, 2022, 7:51 p.m. |
OK |
FPC |
TESTS |
21 |
717 |
204800 |
|
|
174418750 |
langminjie |
C |
Oct. 2, 2022, 4:13 p.m. |
OK |
GNU C++14 |
TESTS |
21 |
15 |
102400 |
|
|
174420284 |
karan984 |
C |
Oct. 2, 2022, 4:19 p.m. |
OK |
GNU C++14 |
TESTS |
21 |
15 |
409600 |
|
|
174417891 |
DiruiXiao |
C |
Oct. 2, 2022, 4:10 p.m. |
OK |
GNU C++14 |
TESTS |
21 |
15 |
2048000 |
|
|
174463392 |
SamNguyen05 |
C |
Oct. 3, 2022, 3:26 a.m. |
OK |
GNU C++14 |
TESTS |
21 |
31 |
102400 |
|
|
174462692 |
TanJI |
C |
Oct. 3, 2022, 3:13 a.m. |
OK |
GNU C++14 |
TESTS |
21 |
31 |
102400 |
|
|
174460928 |
yyyyxh |
C |
Oct. 3, 2022, 2:39 a.m. |
OK |
GNU C++14 |
TESTS |
21 |
31 |
102400 |
|
|
174435236 |
ScottSuperb |
C |
Oct. 2, 2022, 5:55 p.m. |
OK |
GNU C++14 |
TESTS |
21 |
31 |
102400 |
|
|
174434185 |
KXG |
C |
Oct. 2, 2022, 5:45 p.m. |
OK |
GNU C++14 |
TESTS |
21 |
31 |
102400 |
|
|
174420641 |
TMJYH09 |
C |
Oct. 2, 2022, 4:21 p.m. |
OK |
GNU C++14 |
TESTS |
21 |
31 |
102400 |
|
|
174463264 |
Xanadu13 |
C |
Oct. 3, 2022, 3:24 a.m. |
OK |
GNU C++14 |
TESTS |
21 |
31 |
204800 |
|
|
remove filters
Back to search problems