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'This is a hard version of the problem. The actual problems are different, but the easy version is almost a subtask of the hard version. Note that the constraints and the output format are different. You are given a string s consisting of n lowercase Latin letters. You have to color all its characters the minimum number of colors (each character to exactly one color, the same letters can be colored the same or different colors, i.e. you can choose exactly one color for each index in s ). After coloring, you can swap any two neighboring characters of the string that are colored different colors. You can perform such an operation arbitrary (possibly, zero) number of times. The goal is to make the string sorted, i.e. all characters should be in alphabetical order. Your task is to find the minimum number of colors which you have to color the given string in so that after coloring it can become sorted by some sequence of swaps. Note that you have to restore only coloring, not the sequence of swaps. The first line of the input contains one integer n ( 1 <= n <= 2 cdot 10^5 ) -- the length of s . The second line of the input contains the string s consisting of exactly n lowercase Latin letters. In the first line print one integer res ( 1 <= res <= n ) -- the minimum number of colors in which you have to color the given string so that after coloring it can become sorted by some sequence of swaps. In the second line print any possible coloring that can be used to sort the string using some sequence of swaps described in the problem statement. The coloring is the array c of length n , where 1 <= c_i <= res and c_i means the color of the i -th character. '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
70418331 |
Aks303sri |
E2 |
Feb. 6, 2020, 7:51 a.m. |
OK |
Clang++17 Diagnostics |
TESTS |
67 |
966 |
15974400 |
|
2100 |
70386589 |
ftiasch |
E2 |
Feb. 5, 2020, 5:58 p.m. |
OK |
D |
TESTS |
67 |
93 |
4198400 |
|
2100 |
70339878 |
Hanakiko |
E2 |
Feb. 5, 2020, 8:09 a.m. |
OK |
GNU C++11 |
TESTS |
67 |
31 |
2457600 |
|
2100 |
70846629 |
jintiandun |
E2 |
Feb. 12, 2020, 1:39 p.m. |
OK |
GNU C++11 |
TESTS |
67 |
46 |
819200 |
|
2100 |
70724098 |
rures |
E2 |
Feb. 10, 2020, 11:20 a.m. |
OK |
GNU C++11 |
TESTS |
67 |
46 |
819200 |
|
2100 |
70569147 |
Superbia-zyb |
E2 |
Feb. 8, 2020, 1:57 p.m. |
OK |
GNU C++11 |
TESTS |
67 |
46 |
819200 |
|
2100 |
70476166 |
yuzhechuan |
E2 |
Feb. 7, 2020, 3:52 a.m. |
OK |
GNU C++11 |
TESTS |
67 |
46 |
819200 |
|
2100 |
70954701 |
Sempr |
E2 |
Feb. 13, 2020, 12:28 p.m. |
OK |
GNU C++11 |
TESTS |
67 |
46 |
921600 |
|
2100 |
71048518 |
Riccccchard |
E2 |
Feb. 14, 2020, 9:12 a.m. |
OK |
GNU C++11 |
TESTS |
67 |
46 |
1024000 |
|
2100 |
70907091 |
V4yne |
E2 |
Feb. 12, 2020, 5:21 p.m. |
OK |
GNU C++11 |
TESTS |
67 |
46 |
1024000 |
|
2100 |
70783386 |
lgwza |
E2 |
Feb. 11, 2020, 11:31 a.m. |
OK |
GNU C++11 |
TESTS |
67 |
46 |
1024000 |
|
2100 |
70754760 |
sakib_muhit |
E2 |
Feb. 10, 2020, 8:31 p.m. |
OK |
GNU C++11 |
TESTS |
67 |
46 |
1024000 |
|
2100 |
70330896 |
NNewbie |
E2 |
Feb. 5, 2020, 5:54 a.m. |
OK |
GNU C++14 |
TESTS |
67 |
31 |
1024000 |
|
2100 |
70450859 |
Arturoku |
E2 |
Feb. 6, 2020, 4:20 p.m. |
OK |
GNU C++14 |
TESTS |
67 |
31 |
1331200 |
|
2100 |
70376194 |
xacotasamata |
E2 |
Feb. 5, 2020, 4:24 p.m. |
OK |
GNU C++14 |
TESTS |
67 |
31 |
1331200 |
|
2100 |
70526669 |
Bazigar |
E2 |
Feb. 7, 2020, 7:55 p.m. |
OK |
GNU C++14 |
TESTS |
67 |
31 |
2560000 |
|
2100 |
70349810 |
Nero |
E2 |
Feb. 5, 2020, 10:35 a.m. |
OK |
GNU C++14 |
TESTS |
67 |
46 |
307200 |
|
2100 |
70823366 |
juggernaut |
E2 |
Feb. 12, 2020, 5:13 a.m. |
OK |
GNU C++14 |
TESTS |
67 |
46 |
819200 |
|
2100 |
70368514 |
lincolnx |
E2 |
Feb. 5, 2020, 2:41 p.m. |
OK |
GNU C++14 |
TESTS |
67 |
46 |
819200 |
|
2100 |
70335770 |
rfpermen |
E2 |
Feb. 5, 2020, 7:10 a.m. |
OK |
GNU C++14 |
TESTS |
67 |
46 |
819200 |
|
2100 |
70911939 |
patmi |
E2 |
Feb. 12, 2020, 6:32 p.m. |
OK |
GNU C++14 |
TESTS |
67 |
46 |
1024000 |
|
2100 |
70848722 |
gkftndlTek |
E2 |
Feb. 12, 2020, 2:14 p.m. |
OK |
GNU C++14 |
TESTS |
67 |
46 |
1024000 |
|
2100 |
70780267 |
kamilka.agliev |
E2 |
Feb. 11, 2020, 10:24 a.m. |
OK |
GNU C++17 |
TESTS |
67 |
31 |
1331200 |
|
2100 |
70335737 |
YoJaHuang |
E2 |
Feb. 5, 2020, 7:10 a.m. |
OK |
GNU C++17 |
TESTS |
67 |
31 |
1331200 |
|
2100 |
70327296 |
tanimania |
E2 |
Feb. 5, 2020, 4:07 a.m. |
OK |
GNU C++17 |
TESTS |
67 |
31 |
1331200 |
|
2100 |
70310680 |
shaurya_singh |
E2 |
Feb. 4, 2020, 7:07 p.m. |
OK |
GNU C++17 |
TESTS |
67 |
31 |
1331200 |
|
2100 |
70501007 |
Harshit3211 |
E2 |
Feb. 7, 2020, 12:08 p.m. |
OK |
GNU C++17 |
TESTS |
67 |
31 |
2457600 |
|
2100 |
70539786 |
Maybach |
E2 |
Feb. 8, 2020, 5:25 a.m. |
OK |
GNU C++17 |
TESTS |
67 |
46 |
716800 |
|
2100 |
71053196 |
cursed |
E2 |
Feb. 14, 2020, 10:45 a.m. |
OK |
GNU C++17 |
TESTS |
67 |
46 |
819200 |
|
2100 |
70520967 |
SummerMing |
E2 |
Feb. 7, 2020, 5:53 p.m. |
OK |
GNU C++17 |
TESTS |
67 |
46 |
819200 |
|
2100 |
70342247 |
achvanov |
E2 |
Feb. 5, 2020, 8:43 a.m. |
OK |
GNU C++17 |
TESTS |
67 |
46 |
819200 |
|
2100 |
70335427 |
farazradfar |
E2 |
Feb. 5, 2020, 7:06 a.m. |
OK |
GNU C++17 |
TESTS |
67 |
46 |
819200 |
|
2100 |
70295264 |
lifeiteng |
E2 |
Feb. 4, 2020, 4:28 p.m. |
OK |
Java 11 |
TESTS |
67 |
202 |
0 |
|
2100 |
70353611 |
ZeyadKhattab |
E2 |
Feb. 5, 2020, 11:39 a.m. |
OK |
Java 11 |
TESTS |
67 |
217 |
0 |
|
2100 |
70453692 |
saiyam_88 |
E2 |
Feb. 6, 2020, 4:57 p.m. |
OK |
Java 11 |
TESTS |
67 |
218 |
0 |
|
2100 |
70394531 |
bleh0.5 |
E2 |
Feb. 5, 2020, 8:25 p.m. |
OK |
Java 11 |
TESTS |
67 |
218 |
0 |
|
2100 |
70582513 |
pennyIsLove |
E2 |
Feb. 8, 2020, 5:38 p.m. |
OK |
Java 11 |
TESTS |
67 |
233 |
0 |
|
2100 |
70413475 |
rohan101 |
E2 |
Feb. 6, 2020, 6:14 a.m. |
OK |
Java 11 |
TESTS |
67 |
233 |
0 |
|
2100 |
70391487 |
Anonymous |
E2 |
Feb. 5, 2020, 7:19 p.m. |
OK |
Java 11 |
TESTS |
67 |
233 |
0 |
|
2100 |
70388165 |
alankritanand001 |
E2 |
Feb. 5, 2020, 6:21 p.m. |
OK |
Java 11 |
TESTS |
67 |
233 |
0 |
|
2100 |
70314108 |
AshrafEzz |
E2 |
Feb. 4, 2020, 8:14 p.m. |
OK |
Java 11 |
TESTS |
67 |
233 |
0 |
|
2100 |
70363532 |
7_7_7 |
E2 |
Feb. 5, 2020, 1:44 p.m. |
OK |
Java 11 |
TESTS |
67 |
249 |
0 |
|
2100 |
70439011 |
sahiltakkar |
E2 |
Feb. 6, 2020, 1:36 p.m. |
OK |
Java 8 |
TESTS |
67 |
124 |
0 |
|
2100 |
70476796 |
robinz62 |
E2 |
Feb. 7, 2020, 4:11 a.m. |
OK |
Java 8 |
TESTS |
67 |
139 |
0 |
|
2100 |
70471318 |
bluesky111 |
E2 |
Feb. 7, 2020, 12:16 a.m. |
OK |
Java 8 |
TESTS |
67 |
139 |
0 |
|
2100 |
70788628 |
dyhu083 |
E2 |
Feb. 11, 2020, 1:06 p.m. |
OK |
Java 8 |
TESTS |
67 |
140 |
0 |
|
2100 |
70683683 |
O_E |
E2 |
Feb. 9, 2020, 5:33 p.m. |
OK |
Java 8 |
TESTS |
67 |
140 |
0 |
|
2100 |
70441184 |
shashwat07 |
E2 |
Feb. 6, 2020, 2:07 p.m. |
OK |
Java 8 |
TESTS |
67 |
140 |
0 |
|
2100 |
70376621 |
Shameek |
E2 |
Feb. 5, 2020, 4:30 p.m. |
OK |
Java 8 |
TESTS |
67 |
140 |
0 |
|
2100 |
70465221 |
unicorn20141 |
E2 |
Feb. 6, 2020, 8:11 p.m. |
OK |
Java 8 |
TESTS |
67 |
155 |
0 |
|
2100 |
70416207 |
jaynils |
E2 |
Feb. 6, 2020, 7:10 a.m. |
OK |
Java 8 |
TESTS |
67 |
155 |
0 |
|
2100 |
70401014 |
Java |
E2 |
Feb. 5, 2020, 10:02 p.m. |
OK |
Java 8 |
TESTS |
67 |
155 |
0 |
|
2100 |
70363630 |
walborn |
E2 |
Feb. 5, 2020, 1:45 p.m. |
OK |
JavaScript |
TESTS |
67 |
124 |
20582400 |
|
2100 |
70358195 |
walborn |
E2 |
Feb. 5, 2020, 12:42 p.m. |
OK |
JavaScript |
TESTS |
67 |
155 |
20582400 |
|
2100 |
70338379 |
Spheniscine |
E2 |
Feb. 5, 2020, 7:48 a.m. |
OK |
Kotlin |
TESTS |
67 |
171 |
716800 |
|
2100 |
70350324 |
SlavaG |
E2 |
Feb. 5, 2020, 10:44 a.m. |
OK |
Kotlin |
TESTS |
67 |
186 |
102400 |
|
2100 |
70372500 |
cjtoribio |
E2 |
Feb. 5, 2020, 3:34 p.m. |
OK |
Kotlin |
TESTS |
67 |
233 |
204800 |
|
2100 |
70296844 |
yakamoto |
E2 |
Feb. 4, 2020, 4:32 p.m. |
OK |
Kotlin |
TESTS |
67 |
249 |
614400 |
|
2100 |
70802409 |
badcw |
E2 |
Feb. 11, 2020, 5:20 p.m. |
OK |
Kotlin |
TESTS |
67 |
265 |
0 |
|
2100 |
70295715 |
avm |
E2 |
Feb. 4, 2020, 4:30 p.m. |
OK |
Kotlin |
TESTS |
67 |
311 |
5632000 |
|
2100 |
70509678 |
artworks |
E2 |
Feb. 7, 2020, 2:31 p.m. |
OK |
Mono C# |
TESTS |
67 |
140 |
12800000 |
|
2100 |
70509613 |
artworks |
E2 |
Feb. 7, 2020, 2:30 p.m. |
OK |
Mono C# |
TESTS |
67 |
187 |
13414400 |
|
2100 |
70766039 |
vjudge3 |
E2 |
Feb. 11, 2020, 4:49 a.m. |
OK |
MS C++ |
TESTS |
67 |
405 |
85606400 |
|
2100 |
70296407 |
milutin_ |
E2 |
Feb. 4, 2020, 4:31 p.m. |
OK |
MS C++ 2017 |
TESTS |
67 |
46 |
1024000 |
|
2100 |
70354036 |
aliupingtao |
E2 |
Feb. 5, 2020, 11:45 a.m. |
OK |
MS C++ 2017 |
TESTS |
67 |
62 |
1228800 |
|
2100 |
70383762 |
lindlind |
E2 |
Feb. 5, 2020, 5:43 p.m. |
OK |
MS C++ 2017 |
TESTS |
67 |
77 |
2150400 |
|
2100 |
70539749 |
EatingMelonPublic |
E2 |
Feb. 8, 2020, 5:24 a.m. |
OK |
MS C++ 2017 |
TESTS |
67 |
78 |
1228800 |
|
2100 |
70298445 |
facedawn |
E2 |
Feb. 4, 2020, 4:38 p.m. |
OK |
MS C++ 2017 |
TESTS |
67 |
93 |
1024000 |
|
2100 |
70326433 |
bibibihhh |
E2 |
Feb. 5, 2020, 3:40 a.m. |
OK |
MS C++ 2017 |
TESTS |
67 |
93 |
1843200 |
|
2100 |
70342388 |
paradoxhzy |
E2 |
Feb. 5, 2020, 8:45 a.m. |
OK |
MS C++ 2017 |
TESTS |
67 |
93 |
7372800 |
|
2100 |
70327353 |
iRuIrUI |
E2 |
Feb. 5, 2020, 4:09 a.m. |
OK |
MS C++ 2017 |
TESTS |
67 |
139 |
1433600 |
|
2100 |
70330839 |
SomeTh1n6 |
E2 |
Feb. 5, 2020, 5:54 a.m. |
OK |
MS C++ 2017 |
TESTS |
67 |
140 |
1433600 |
|
2100 |
70401386 |
AlexanderL |
E2 |
Feb. 5, 2020, 10:18 p.m. |
OK |
MS C++ 2017 |
TESTS |
67 |
140 |
1433600 |
|
2100 |
70512427 |
reyad |
E2 |
Feb. 7, 2020, 3:15 p.m. |
OK |
PHP |
TESTS |
67 |
139 |
14336000 |
|
2100 |
70512316 |
reyad |
E2 |
Feb. 7, 2020, 3:13 p.m. |
OK |
PHP |
TESTS |
67 |
779 |
14336000 |
|
2100 |
70299017 |
pajenegod |
E2 |
Feb. 4, 2020, 4:40 p.m. |
OK |
PyPy 2 |
TESTS |
67 |
171 |
15052800 |
|
2100 |
70757698 |
Lalaleyna |
E2 |
Feb. 10, 2020, 10:14 p.m. |
OK |
PyPy 3 |
TESTS |
67 |
233 |
10752000 |
|
2100 |
70335246 |
Mohamed_Ayman |
E2 |
Feb. 5, 2020, 7:03 a.m. |
OK |
PyPy 3 |
TESTS |
67 |
233 |
10752000 |
|
2100 |
70757726 |
Lalaleyna |
E2 |
Feb. 10, 2020, 10:15 p.m. |
OK |
PyPy 3 |
TESTS |
67 |
248 |
12185600 |
|
2100 |
70386892 |
wilkinson |
E2 |
Feb. 5, 2020, 6:02 p.m. |
OK |
PyPy 3 |
TESTS |
67 |
248 |
16486400 |
|
2100 |
70579532 |
e.m.blagov |
E2 |
Feb. 8, 2020, 4:47 p.m. |
OK |
PyPy 3 |
TESTS |
67 |
249 |
13414400 |
|
2100 |
70834005 |
NocturneBflat |
E2 |
Feb. 12, 2020, 9:28 a.m. |
OK |
PyPy 3 |
TESTS |
67 |
249 |
16076800 |
|
2100 |
70421333 |
megabluejay |
E2 |
Feb. 6, 2020, 8:50 a.m. |
OK |
PyPy 3 |
TESTS |
67 |
249 |
17100800 |
|
2100 |
70303866 |
yh157612 |
E2 |
Feb. 4, 2020, 5:24 p.m. |
OK |
PyPy 3 |
TESTS |
67 |
264 |
11468800 |
|
2100 |
70411394 |
nocreative1 |
E2 |
Feb. 6, 2020, 5:24 a.m. |
OK |
PyPy 3 |
TESTS |
67 |
265 |
14028800 |
|
2100 |
70359107 |
smart_hard |
E2 |
Feb. 5, 2020, 12:53 p.m. |
OK |
PyPy 3 |
TESTS |
67 |
265 |
14131200 |
|
2100 |
70346789 |
SinKing |
E2 |
Feb. 5, 2020, 9:48 a.m. |
OK |
Python 3 |
TESTS |
67 |
577 |
2662400 |
|
2100 |
70346553 |
SinKing |
E2 |
Feb. 5, 2020, 9:44 a.m. |
OK |
Python 3 |
TESTS |
67 |
577 |
2662400 |
|
2100 |
70739177 |
Lalaleyna |
E2 |
Feb. 10, 2020, 3:29 p.m. |
OK |
Python 3 |
TESTS |
67 |
686 |
2560000 |
|
2100 |
70755934 |
Lalaleyna |
E2 |
Feb. 10, 2020, 9:05 p.m. |
OK |
Python 3 |
TESTS |
67 |
686 |
3481600 |
|
2100 |
70756418 |
Lalaleyna |
E2 |
Feb. 10, 2020, 9:21 p.m. |
OK |
Python 3 |
TESTS |
67 |
701 |
3174400 |
|
2100 |
70737137 |
Lalaleyna |
E2 |
Feb. 10, 2020, 2:58 p.m. |
OK |
Python 3 |
TESTS |
67 |
702 |
2662400 |
|
2100 |
70757111 |
Lalaleyna |
E2 |
Feb. 10, 2020, 9:47 p.m. |
OK |
Python 3 |
TESTS |
67 |
733 |
3174400 |
|
2100 |
70756183 |
Lalaleyna |
E2 |
Feb. 10, 2020, 9:13 p.m. |
OK |
Python 3 |
TESTS |
67 |
733 |
3481600 |
|
2100 |
70755902 |
Lalaleyna |
E2 |
Feb. 10, 2020, 9:04 p.m. |
OK |
Python 3 |
TESTS |
67 |
748 |
3481600 |
|
2100 |
70736429 |
Lalaleyna |
E2 |
Feb. 10, 2020, 2:47 p.m. |
OK |
Python 3 |
TESTS |
67 |
748 |
4096000 |
|
2100 |
70606175 |
terraformer |
E2 |
Feb. 9, 2020, 6:55 a.m. |
OK |
Rust |
TESTS |
67 |
78 |
4403200 |
|
2100 |
70300093 |
sansen |
E2 |
Feb. 4, 2020, 4:48 p.m. |
OK |
Rust |
TESTS |
67 |
93 |
3276800 |
|
2100 |
remove filters
Back to search problems