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'378QAQ has a string s of length n . Define the core of a string as the substring ^ dagger with maximum lexicographic ^ ddagger order. For example, the core of " mathtt{bazoka} " is " mathtt{zoka} ", and the core of " mathtt{aaa} " is " mathtt{aaa} ". 378QAQ wants to rearrange the string s so that the core is lexicographically minimum. Find the lexicographically minimum possible core over all rearrangements of s . ^ dagger A substring of string s is a continuous segment of letters from s . For example, " mathtt{defor} ", " mathtt{code} " and " mathtt{o} " are all substrings of " mathtt{codeforces} " while " mathtt{codes} " and " mathtt{aaa} " are not. ^ ddagger A string p is lexicographically smaller than a string q if and only if one of the following holds: For example, " mathtt{code} " and " mathtt{coda} " are both lexicographically smaller than " mathtt{codeforces} " while " mathtt{codeforceston} " and " mathtt{z} " are not. Each test contains multiple test cases. The first line contains the number of test cases t ( 1 <= q t <= q 10^5 ). The description of the test cases follows. The first line of each test case contains a single integer n ( 1 <= q n <= q 10^6 ) -- the length of string s . The next line of each test case contains the string s of length n . The string s consists of lowercase English letters. It is guaranteed that the sum of n over all test cases does not exceed 10^6 . For each test case, output the lexicographically minimum possible core over all rearrangements of s . In the first test case, all possible rearrangements and their corresponding cores are as follows: So the core with the minimum lexicographic order in all rearrangement plans is " mathtt{qaq} ". '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
263603848 |
xuanxuan001 |
H |
June 1, 2024, 9:08 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
54 |
125 |
3072000 |
|
3500 |
263559003 |
Chenly |
H |
June 1, 2024, 12:36 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
54 |
171 |
49152000 |
|
3500 |
263416492 |
Crystally |
H |
May 31, 2024, 5:45 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
54 |
296 |
26112000 |
|
3500 |
262885256 |
schrodingerstom |
H |
May 27, 2024, 1:12 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
54 |
327 |
51507200 |
|
3500 |
263047606 |
devisaisri_veeranki |
H |
May 28, 2024, 5:38 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
54 |
468 |
127488000 |
|
3500 |
262713592 |
saidulih_20 |
H |
May 26, 2024, 1:59 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
54 |
140 |
14028800 |
|
3500 |
262838982 |
Ramo7fsw |
H |
May 27, 2024, 6:58 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
54 |
171 |
14028800 |
|
3500 |
263165138 |
Crystally |
H |
May 29, 2024, 3:52 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
54 |
312 |
26112000 |
|
3500 |
263151388 |
SoiMae |
H |
May 29, 2024, 1:52 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
54 |
358 |
152473600 |
|
3500 |
263057105 |
Mohamedtarekfayez |
H |
May 28, 2024, 7:11 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
54 |
374 |
32153600 |
|
3500 |
263528849 |
Atikur_Rahaman |
H |
May 31, 2024, 4:51 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
54 |
483 |
127488000 |
|
3500 |
263260021 |
xiao_lang |
H |
May 30, 2024, 2:02 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
54 |
593 |
57753600 |
|
3500 |
263151641 |
Revived_xryjr233 |
H |
May 29, 2024, 1:54 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
54 |
108 |
9830400 |
|
3500 |
262831144 |
RDDCCD |
H |
May 27, 2024, 5:42 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
54 |
140 |
5120000 |
|
3500 |
262929407 |
princedyrus |
H |
May 27, 2024, 7:52 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
54 |
155 |
54988800 |
|
3500 |
262867769 |
zjy2008 |
H |
May 27, 2024, 10:57 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
54 |
155 |
54988800 |
|
3500 |
262865076 |
Wuyanru |
H |
May 27, 2024, 10:36 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
54 |
171 |
8908800 |
|
3500 |
263431525 |
EJIC_B_KEDAX |
H |
May 31, 2024, 7:46 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
54 |
186 |
28979200 |
|
3500 |
262864935 |
Wuyanru |
H |
May 27, 2024, 10:35 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
54 |
202 |
8908800 |
|
3500 |
263019382 |
Flamire |
H |
May 28, 2024, 1:42 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
54 |
202 |
37068800 |
|
3500 |
263019302 |
Flamire |
H |
May 28, 2024, 1:42 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
54 |
202 |
37068800 |
|
3500 |
263387803 |
EJIC_B_KEDAX |
H |
May 30, 2024, 9:20 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
54 |
203 |
28979200 |
|
3500 |
263192853 |
dzhi |
H |
May 30, 2024, 12:32 a.m. |
OK |
Java 21 |
TESTS |
54 |
1015 |
124518400 |
|
3500 |
remove filters
Back to search problems