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"Theofanis has a string s_1 s_2 ... s_n and a character c . He wants to make all characters of the string equal to c using the minimum number of operations. In one operation he can choose a number x ( 1 <= x <= n ) and for every position i , where i is not divisible by x , replace s_i with c . Find the minimum number of operations required to make all the characters equal to c and the x -s that he should use in his operations. The first line contains a single integer t ( 1 <= t <= 10^4 ) -- the number of test cases. The first line of each test case contains the integer n ( 3 <= n <= 3 cdot 10^5 ) and a lowercase Latin letter c -- the length of the string s and the character the resulting string should consist of. The second line of each test case contains a string s of lowercase Latin letters -- the initial string. It is guaranteed that the sum of n over all test cases does not exceed 3 cdot 10^5 . For each test case, firstly print one integer m -- the minimum number of operations required to make all the characters equal to c . Next, print m integers x_1, x_2, ... , x_m ( 1 <= x_j <= n ) -- the x -s that should be used in the order they are given. It can be proved that under given constraints, an answer always exists. If there are multiple answers, print any. Let's describe what happens in the third test case: "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
131238655 |
cyrus_msk |
C |
Oct. 8, 2021, 6:44 p.m. |
OK |
D |
TESTS |
26 |
46 |
8908800 |
|
1200 |
131263049 |
BadCodeBuilder |
C |
Oct. 9, 2021, 2:52 a.m. |
OK |
GNU C11 |
TESTS |
26 |
46 |
3993600 |
|
1200 |
131264860 |
sandbad |
C |
Oct. 9, 2021, 3:25 a.m. |
OK |
GNU C11 |
TESTS |
26 |
62 |
3993600 |
|
1200 |
131264896 |
sandbad |
C |
Oct. 9, 2021, 3:26 a.m. |
OK |
GNU C11 |
TESTS |
26 |
77 |
3993600 |
|
1200 |
131253892 |
Sympa |
C |
Oct. 9, 2021, 1:05 a.m. |
OK |
GNU C++14 |
TESTS |
26 |
15 |
3993600 |
|
1200 |
131270986 |
Jarden |
C |
Oct. 9, 2021, 5:05 a.m. |
OK |
GNU C++14 |
TESTS |
27 |
15 |
4096000 |
|
1200 |
131254086 |
Hunkihas |
C |
Oct. 9, 2021, 1:10 a.m. |
OK |
GNU C++14 |
TESTS |
26 |
15 |
4096000 |
|
1200 |
131236276 |
155016 |
C |
Oct. 8, 2021, 6:23 p.m. |
OK |
GNU C++14 |
TESTS |
26 |
15 |
4812800 |
|
1200 |
131272542 |
dbwhdans |
C |
Oct. 9, 2021, 5:26 a.m. |
OK |
GNU C++14 |
TESTS |
27 |
15 |
4812800 |
|
1200 |
131264627 |
Marshall_Lee |
C |
Oct. 9, 2021, 3:21 a.m. |
OK |
GNU C++14 |
TESTS |
26 |
15 |
4812800 |
|
1200 |
131259625 |
Mahmoud-warrak |
C |
Oct. 9, 2021, 2:16 a.m. |
OK |
GNU C++14 |
TESTS |
26 |
15 |
4812800 |
|
1200 |
131253323 |
duoluoluo |
C |
Oct. 9, 2021, 12:49 a.m. |
OK |
GNU C++14 |
TESTS |
26 |
15 |
5222400 |
|
1200 |
131234716 |
shivam_751 |
C |
Oct. 8, 2021, 6:09 p.m. |
OK |
GNU C++14 |
TESTS |
26 |
30 |
3993600 |
|
1200 |
131256994 |
zjkzjkzjk |
C |
Oct. 9, 2021, 2:01 a.m. |
OK |
GNU C++14 |
TESTS |
26 |
30 |
3993600 |
|
1200 |
131242437 |
safiyyahAhmad |
C |
Oct. 8, 2021, 7:39 p.m. |
OK |
GNU C++17 |
TESTS |
26 |
15 |
3891200 |
|
1200 |
131231193 |
55190123 |
C |
Oct. 8, 2021, 5:19 p.m. |
OK |
GNU C++17 |
TESTS |
26 |
15 |
3993600 |
|
1200 |
131265757 |
W_34 |
C |
Oct. 9, 2021, 3:42 a.m. |
OK |
GNU C++17 |
TESTS |
27 |
15 |
4096000 |
|
1200 |
131268293 |
Deepraj99 |
C |
Oct. 9, 2021, 4:26 a.m. |
OK |
GNU C++17 |
TESTS |
27 |
15 |
4198400 |
|
1200 |
131266649 |
jaimehta |
C |
Oct. 9, 2021, 3:59 a.m. |
OK |
GNU C++17 |
TESTS |
27 |
15 |
4812800 |
|
1200 |
131272358 |
Peal_Mazumder |
C |
Oct. 9, 2021, 5:24 a.m. |
OK |
GNU C++17 |
TESTS |
27 |
15 |
4812800 |
|
1200 |
131266102 |
BernardHH |
C |
Oct. 9, 2021, 3:49 a.m. |
OK |
GNU C++17 |
TESTS |
27 |
15 |
4812800 |
|
1200 |
131266287 |
YIEC2538 |
C |
Oct. 9, 2021, 3:52 a.m. |
OK |
GNU C++17 |
TESTS |
27 |
15 |
4812800 |
|
1200 |
131271828 |
YeoBL |
C |
Oct. 9, 2021, 5:17 a.m. |
OK |
GNU C++17 |
TESTS |
27 |
15 |
4812800 |
|
1200 |
131268381 |
Egoistiv |
C |
Oct. 9, 2021, 4:28 a.m. |
OK |
GNU C++17 |
TESTS |
27 |
15 |
4812800 |
|
1200 |
131246302 |
vora_dev |
C |
Oct. 8, 2021, 8:50 p.m. |
OK |
GNU C++17 (64) |
TESTS |
26 |
15 |
4812800 |
|
1200 |
131264764 |
HollwoQ_Pelw |
C |
Oct. 9, 2021, 3:23 a.m. |
OK |
GNU C++17 (64) |
TESTS |
26 |
15 |
4812800 |
|
1200 |
131244080 |
AGRU |
C |
Oct. 8, 2021, 8:05 p.m. |
OK |
GNU C++17 (64) |
TESTS |
26 |
15 |
5324800 |
|
1200 |
131242859 |
Kali1314 |
C |
Oct. 8, 2021, 7:45 p.m. |
OK |
GNU C++17 (64) |
TESTS |
26 |
15 |
5324800 |
|
1200 |
131241009 |
programmer765 |
C |
Oct. 8, 2021, 7:17 p.m. |
OK |
GNU C++17 (64) |
TESTS |
26 |
15 |
5324800 |
|
1200 |
131235015 |
yog_111 |
C |
Oct. 8, 2021, 6:12 p.m. |
OK |
GNU C++17 (64) |
TESTS |
26 |
15 |
5324800 |
|
1200 |
131234363 |
placik |
C |
Oct. 8, 2021, 6:07 p.m. |
OK |
GNU C++17 (64) |
TESTS |
26 |
15 |
5324800 |
|
1200 |
131256898 |
froggyzhang |
C |
Oct. 9, 2021, 1:59 a.m. |
OK |
GNU C++17 (64) |
TESTS |
26 |
15 |
5324800 |
|
1200 |
131261618 |
over_flow |
C |
Oct. 9, 2021, 2:22 a.m. |
OK |
GNU C++17 (64) |
TESTS |
26 |
15 |
5324800 |
|
1200 |
131267370 |
nomad_heart |
C |
Oct. 9, 2021, 4:12 a.m. |
OK |
GNU C++17 (64) |
TESTS |
27 |
15 |
5324800 |
|
1200 |
131274808 |
KarMa_ |
C |
Oct. 9, 2021, 5:51 a.m. |
OK |
Java 11 |
TESTS |
27 |
202 |
24166400 |
|
1200 |
131257234 |
Satyaa |
C |
Oct. 9, 2021, 2:07 a.m. |
OK |
Java 11 |
TESTS |
26 |
217 |
23961600 |
|
1200 |
131238484 |
dhruvil_8803 |
C |
Oct. 8, 2021, 6:42 p.m. |
OK |
Java 11 |
TESTS |
26 |
217 |
24064000 |
|
1200 |
131273349 |
Avatar |
C |
Oct. 9, 2021, 5:36 a.m. |
OK |
Java 11 |
TESTS |
27 |
218 |
23961600 |
|
1200 |
131269804 |
Soham7 |
C |
Oct. 9, 2021, 4:48 a.m. |
OK |
Java 11 |
TESTS |
27 |
218 |
24064000 |
|
1200 |
131235761 |
MoonCoder1234 |
C |
Oct. 8, 2021, 6:18 p.m. |
OK |
Java 11 |
TESTS |
26 |
218 |
24064000 |
|
1200 |
131265593 |
I_love_camel_case |
C |
Oct. 9, 2021, 3:39 a.m. |
OK |
Java 11 |
TESTS |
27 |
218 |
24166400 |
|
1200 |
131246243 |
Toinfinity |
C |
Oct. 8, 2021, 8:48 p.m. |
OK |
Java 11 |
TESTS |
26 |
218 |
28569600 |
|
1200 |
131225476 |
sharnit |
C |
Oct. 8, 2021, 5:05 p.m. |
OK |
Java 11 |
TESTS |
26 |
233 |
23961600 |
|
1200 |
131270546 |
Soham7 |
C |
Oct. 9, 2021, 4:58 a.m. |
OK |
Java 11 |
TESTS |
27 |
233 |
24576000 |
|
1200 |
131235803 |
Keyur21 |
C |
Oct. 8, 2021, 6:19 p.m. |
OK |
Java 8 |
TESTS |
26 |
124 |
20480000 |
|
1200 |
131247631 |
piyush33patel |
C |
Oct. 8, 2021, 9:20 p.m. |
OK |
Java 8 |
TESTS |
26 |
124 |
20582400 |
|
1200 |
131235478 |
RonWonWon |
C |
Oct. 8, 2021, 6:16 p.m. |
OK |
Java 8 |
TESTS |
26 |
124 |
20582400 |
|
1200 |
131266511 |
HastaLaVistaLa |
C |
Oct. 9, 2021, 3:57 a.m. |
OK |
Java 8 |
TESTS |
27 |
124 |
40550400 |
|
1200 |
131248743 |
SpargelTarzan |
C |
Oct. 8, 2021, 9:52 p.m. |
OK |
Java 8 |
TESTS |
26 |
140 |
20582400 |
|
1200 |
131247213 |
piyush33patel |
C |
Oct. 8, 2021, 9:09 p.m. |
OK |
Java 8 |
TESTS |
26 |
140 |
20582400 |
|
1200 |
131271589 |
aashay_03 |
C |
Oct. 9, 2021, 5:14 a.m. |
OK |
Java 8 |
TESTS |
27 |
140 |
20684800 |
|
1200 |
131264697 |
alibaba |
C |
Oct. 9, 2021, 3:22 a.m. |
OK |
Java 8 |
TESTS |
26 |
171 |
20787200 |
|
1200 |
131263365 |
ITBeater |
C |
Oct. 9, 2021, 2:58 a.m. |
OK |
Java 8 |
TESTS |
26 |
171 |
20889600 |
|
1200 |
131263591 |
XUQING |
C |
Oct. 9, 2021, 3:02 a.m. |
OK |
Java 8 |
TESTS |
26 |
171 |
21196800 |
|
1200 |
131245877 |
mishgan |
C |
Oct. 8, 2021, 8:39 p.m. |
OK |
Kotlin 1.4 |
TESTS |
26 |
311 |
21913600 |
|
1200 |
131236822 |
huy.caohuyhuy123 |
C |
Oct. 8, 2021, 6:29 p.m. |
OK |
Kotlin 1.5 |
TESTS |
26 |
342 |
24883200 |
|
1200 |
131240051 |
UnHingedFrog |
C |
Oct. 8, 2021, 7:02 p.m. |
OK |
MS C++ 2017 |
TESTS |
26 |
46 |
4608000 |
|
1200 |
131236008 |
codmacian |
C |
Oct. 8, 2021, 6:21 p.m. |
OK |
MS C++ 2017 |
TESTS |
26 |
46 |
4608000 |
|
1200 |
131275382 |
yashgul |
C |
Oct. 9, 2021, 5:57 a.m. |
OK |
MS C++ 2017 |
TESTS |
27 |
61 |
4608000 |
|
1200 |
131275204 |
Jonathan_Chang |
C |
Oct. 9, 2021, 5:55 a.m. |
OK |
MS C++ 2017 |
TESTS |
27 |
62 |
4096000 |
|
1200 |
131236114 |
AllDirections |
C |
Oct. 8, 2021, 6:22 p.m. |
OK |
MS C++ 2017 |
TESTS |
26 |
77 |
4608000 |
|
1200 |
131262388 |
x_silter |
C |
Oct. 9, 2021, 2:39 a.m. |
OK |
MS C++ 2017 |
TESTS |
26 |
93 |
4198400 |
|
1200 |
131266858 |
utsavm |
C |
Oct. 9, 2021, 4:03 a.m. |
OK |
MS C++ 2017 |
TESTS |
27 |
109 |
4608000 |
|
1200 |
131229603 |
Damirca |
C |
Oct. 8, 2021, 5:16 p.m. |
OK |
MS C++ 2017 |
TESTS |
26 |
124 |
4608000 |
|
1200 |
131262884 |
lanwang |
C |
Oct. 9, 2021, 2:49 a.m. |
OK |
MS C++ 2017 |
TESTS |
26 |
186 |
13312000 |
|
1200 |
131226526 |
Yuno_Gasai |
C |
Oct. 8, 2021, 5:08 p.m. |
OK |
MS C++ 2017 |
TESTS |
26 |
888 |
14848000 |
|
1200 |
131252477 |
chinesedfan |
C |
Oct. 9, 2021, 12:21 a.m. |
OK |
Node.js |
TESTS |
26 |
218 |
19865600 |
|
1200 |
131246352 |
lebron87 |
C |
Oct. 8, 2021, 8:51 p.m. |
OK |
PyPy 3 |
TESTS |
26 |
187 |
34099200 |
|
1200 |
131234672 |
1_2_3_4_5_9 |
C |
Oct. 8, 2021, 6:09 p.m. |
OK |
PyPy 3 |
TESTS |
26 |
202 |
27136000 |
|
1200 |
131226481 |
10_11_12 |
C |
Oct. 8, 2021, 5:08 p.m. |
OK |
PyPy 3 |
TESTS |
26 |
202 |
27136000 |
|
1200 |
131271796 |
iimmortal |
C |
Oct. 9, 2021, 5:17 a.m. |
OK |
PyPy 3 |
TESTS |
27 |
202 |
31744000 |
|
1200 |
131240095 |
jano31415 |
C |
Oct. 8, 2021, 7:03 p.m. |
OK |
PyPy 3 |
TESTS |
26 |
202 |
32768000 |
|
1200 |
131249646 |
Het_Fadia |
C |
Oct. 8, 2021, 10:23 p.m. |
OK |
PyPy 3 |
TESTS |
26 |
218 |
30924800 |
|
1200 |
131227846 |
asady529 |
C |
Oct. 8, 2021, 5:12 p.m. |
OK |
PyPy 3 |
TESTS |
26 |
233 |
27955200 |
|
1200 |
131262630 |
zayn. |
C |
Oct. 9, 2021, 2:44 a.m. |
OK |
PyPy 3 |
TESTS |
26 |
233 |
29593600 |
|
1200 |
131263018 |
zayn. |
C |
Oct. 9, 2021, 2:52 a.m. |
OK |
PyPy 3 |
TESTS |
26 |
233 |
30105600 |
|
1200 |
131262420 |
zayn. |
C |
Oct. 9, 2021, 2:40 a.m. |
OK |
PyPy 3 |
TESTS |
26 |
248 |
28364800 |
|
1200 |
131241821 |
tieros |
C |
Oct. 8, 2021, 7:29 p.m. |
OK |
Python 3 |
TESTS |
26 |
109 |
8089600 |
|
1200 |
131268251 |
Bambam_Shivam |
C |
Oct. 9, 2021, 4:26 a.m. |
OK |
Python 3 |
TESTS |
27 |
155 |
8499200 |
|
1200 |
131235669 |
nishant_25 |
C |
Oct. 8, 2021, 6:17 p.m. |
OK |
Python 3 |
TESTS |
26 |
171 |
7884800 |
|
1200 |
131229010 |
freshnewname |
C |
Oct. 8, 2021, 5:15 p.m. |
OK |
Python 3 |
TESTS |
26 |
186 |
8089600 |
|
1200 |
131240201 |
ronakaghera |
C |
Oct. 8, 2021, 7:05 p.m. |
OK |
Python 3 |
TESTS |
26 |
187 |
7884800 |
|
1200 |
131245872 |
ShagunG |
C |
Oct. 8, 2021, 8:39 p.m. |
OK |
Python 3 |
TESTS |
26 |
202 |
7884800 |
|
1200 |
131242331 |
eugalt |
C |
Oct. 8, 2021, 7:37 p.m. |
OK |
Python 3 |
TESTS |
26 |
217 |
7884800 |
|
1200 |
131242426 |
eugalt |
C |
Oct. 8, 2021, 7:39 p.m. |
OK |
Python 3 |
TESTS |
26 |
218 |
7475200 |
|
1200 |
131243912 |
eugalt |
C |
Oct. 8, 2021, 8:02 p.m. |
OK |
Python 3 |
TESTS |
26 |
218 |
7884800 |
|
1200 |
131263594 |
SF-Manman |
C |
Oct. 9, 2021, 3:02 a.m. |
OK |
Python 3 |
TESTS |
26 |
218 |
8089600 |
|
1200 |
131252943 |
Spheniscine |
C |
Oct. 9, 2021, 12:37 a.m. |
OK |
Rust |
TESTS |
26 |
31 |
4198400 |
|
1200 |
131234128 |
freshnewname |
C |
Oct. 8, 2021, 6:05 p.m. |
OK |
Rust |
TESTS |
26 |
31 |
4915200 |
|
1200 |
131228524 |
Ahmed_M_Abdelhamed |
C |
Oct. 8, 2021, 5:14 p.m. |
OK |
Rust |
TESTS |
26 |
202 |
4505600 |
|
1200 |
remove filters
Back to search problems