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'The row-major order of an r x c grid of characters A is the string obtained by concatenating all the rows, i.e. A_{11}A_{12} ... A_{1c}A_{21}A_{22} ... A_{2c} ... A_{r1}A_{r2} ... A_{rc}. A grid of characters A is bad if there are some two adjacent cells (cells sharing an edge) with the same character. You are given a positive integer n . Consider all strings s consisting of only lowercase Latin letters such that they are not the row-major order of any bad grid. Find any string with the minimum number of distinct characters among all such strings of length n . It can be proven that at least one such string exists under the constraints of the problem. 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 only line of each test case contains a single integer n ( 1 <= n <= 10^6 ). It is guaranteed that the sum of n over all test cases does not exceed 10^6 . For each test case, output a string with the minimum number of distinct characters among all suitable strings of length n . If there are multiple solutions, print any of them. In the first test case, there are 3 ways s can be the row-major order of a grid, and they are all not bad: tththathatat It can be proven that 3 distinct characters is the minimum possible. In the second test case, there are 2 ways s can be the row-major order of a grid, and they are both not bad: iiss It can be proven that 2 distinct characters is the minimum possible. In the third test case, there is only 1 way s can be the row-major order of a grid, and it is not bad. In the fourth test case, there are 4 ways s can be the row-major order of a grid, and they are all not bad: ttotomtomatoomaatomtoato It can be proven that 4 distinct characters is the minimum possible.'... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
213442636 |
lAMaLOSER |
D |
July 12, 2023, 2:27 a.m. |
OK |
C# 10 |
TESTS |
22 |
389 |
3993600 |
|
|
213424800 |
ShaoNianTongXue5307 |
D |
July 11, 2023, 9:33 p.m. |
OK |
Clang++17 Diagnostics |
TESTS |
22 |
514 |
15872000 |
|
|
213424886 |
ShaoNianTongXue5307 |
D |
July 11, 2023, 9:35 p.m. |
OK |
Clang++17 Diagnostics |
TESTS |
22 |
530 |
15872000 |
|
|
213424824 |
ShaoNianTongXue5307 |
D |
July 11, 2023, 9:34 p.m. |
OK |
Clang++20 Diagnostics |
TESTS |
22 |
514 |
15872000 |
|
|
213431386 |
rainboy |
D |
July 11, 2023, 11:50 p.m. |
OK |
GNU C11 |
TESTS |
22 |
78 |
1024000 |
|
|
213399475 |
Vishal_Singh25 |
D |
July 11, 2023, 5:26 p.m. |
OK |
GNU C11 |
TESTS |
20 |
140 |
1331200 |
|
|
213433229 |
cry |
D |
July 12, 2023, 12:25 a.m. |
OK |
GNU C11 |
TESTS |
22 |
295 |
5017600 |
|
|
213400942 |
canuplsstfu |
D |
July 11, 2023, 5:30 p.m. |
OK |
GNU C++14 |
TESTS |
20 |
30 |
2969600 |
|
|
213427626 |
lukehsiao |
D |
July 11, 2023, 10:27 p.m. |
OK |
GNU C++14 |
TESTS |
22 |
30 |
2969600 |
|
|
213437089 |
Ankush_Goel |
D |
July 12, 2023, 1:20 a.m. |
OK |
GNU C++14 |
TESTS |
22 |
31 |
0 |
|
|
213441043 |
McIron233 |
D |
July 12, 2023, 2:09 a.m. |
OK |
GNU C++14 |
TESTS |
22 |
31 |
1024000 |
|
|
213418831 |
aneeshadas02 |
D |
July 11, 2023, 8:12 p.m. |
OK |
GNU C++14 |
TESTS |
22 |
31 |
1024000 |
|
|
213444374 |
ROADTOBURNTHESUN |
D |
July 12, 2023, 2:46 a.m. |
OK |
GNU C++14 |
TESTS |
22 |
31 |
1024000 |
|
|
213444763 |
zklalalalalala |
D |
July 12, 2023, 2:51 a.m. |
OK |
GNU C++14 |
TESTS |
22 |
31 |
1024000 |
|
|
213445366 |
huyuun |
D |
July 12, 2023, 2:58 a.m. |
OK |
GNU C++14 |
TESTS |
22 |
31 |
1024000 |
|
|
213444096 |
Vishvajeet28 |
D |
July 12, 2023, 2:43 a.m. |
OK |
GNU C++14 |
TESTS |
22 |
31 |
2969600 |
|
|
213452429 |
rkyrahulkumar |
D |
July 12, 2023, 4:49 a.m. |
OK |
GNU C++14 |
TESTS |
22 |
31 |
2969600 |
|
|
213395442 |
Aaryan.Kaushik |
D |
July 11, 2023, 5:12 p.m. |
OK |
GNU C++17 |
TESTS |
20 |
15 |
1024000 |
|
|
213397295 |
AhmedAlamer |
D |
July 11, 2023, 5:19 p.m. |
OK |
GNU C++17 |
TESTS |
20 |
15 |
2969600 |
|
|
213393231 |
anurag7 |
D |
July 11, 2023, 5:05 p.m. |
OK |
GNU C++17 |
TESTS |
20 |
15 |
2969600 |
|
|
213392903 |
lqazzz |
D |
July 11, 2023, 5:04 p.m. |
OK |
GNU C++17 |
TESTS |
20 |
15 |
2969600 |
|
|
213427599 |
Aftershock007 |
D |
July 11, 2023, 10:26 p.m. |
OK |
GNU C++17 |
TESTS |
22 |
30 |
1024000 |
|
|
213393044 |
Arth2022 |
D |
July 11, 2023, 5:05 p.m. |
OK |
GNU C++17 |
TESTS |
20 |
30 |
1024000 |
|
|
213401473 |
manyu19 |
D |
July 11, 2023, 5:32 p.m. |
OK |
GNU C++17 |
TESTS |
20 |
30 |
1126400 |
|
|
213455033 |
Janming |
D |
July 12, 2023, 5:31 a.m. |
OK |
GNU C++17 |
TESTS |
22 |
30 |
2048000 |
|
|
213409047 |
khanayaan7 |
D |
July 11, 2023, 6:31 p.m. |
OK |
GNU C++17 |
TESTS |
21 |
30 |
2969600 |
|
|
213451963 |
abhishek_0123 |
D |
July 12, 2023, 4:42 a.m. |
OK |
GNU C++17 |
TESTS |
22 |
30 |
2969600 |
|
|
213395474 |
Tanphoon |
D |
July 11, 2023, 5:12 p.m. |
OK |
GNU C++17 (64) |
TESTS |
20 |
30 |
3993600 |
|
|
213428891 |
Xylenox |
D |
July 11, 2023, 10:54 p.m. |
OK |
GNU C++17 (64) |
TESTS |
22 |
31 |
0 |
|
|
213416781 |
sahibsingh139 |
D |
July 11, 2023, 7:47 p.m. |
OK |
GNU C++17 (64) |
TESTS |
22 |
31 |
0 |
|
|
213428061 |
tan1shqc |
D |
July 11, 2023, 10:35 p.m. |
OK |
GNU C++17 (64) |
TESTS |
22 |
31 |
1024000 |
|
|
213456415 |
Prahlad_03 |
D |
July 12, 2023, 5:52 a.m. |
OK |
GNU C++17 (64) |
TESTS |
22 |
31 |
3993600 |
|
|
213397103 |
harsh_8484 |
D |
July 11, 2023, 5:18 p.m. |
OK |
GNU C++17 (64) |
TESTS |
20 |
31 |
3993600 |
|
|
213400145 |
ShikiComder |
D |
July 11, 2023, 5:28 p.m. |
OK |
GNU C++17 (64) |
TESTS |
20 |
31 |
3993600 |
|
|
213402503 |
Sunny004 |
D |
July 11, 2023, 5:34 p.m. |
OK |
GNU C++17 (64) |
TESTS |
20 |
31 |
3993600 |
|
|
213400448 |
A.TURKI |
D |
July 11, 2023, 5:29 p.m. |
OK |
GNU C++17 (64) |
TESTS |
20 |
31 |
6553600 |
|
|
213451373 |
AceKnight7 |
D |
July 12, 2023, 4:33 a.m. |
OK |
GNU C++17 (64) |
TESTS |
22 |
31 |
8806400 |
|
|
213394947 |
EdvardsF |
D |
July 11, 2023, 5:11 p.m. |
OK |
GNU C++20 (64) |
TESTS |
20 |
15 |
1024000 |
|
|
213451338 |
may_day |
D |
July 12, 2023, 4:32 a.m. |
OK |
GNU C++20 (64) |
TESTS |
22 |
15 |
1024000 |
|
|
213415784 |
amcbn |
D |
July 11, 2023, 7:36 p.m. |
OK |
GNU C++20 (64) |
TESTS |
22 |
15 |
1024000 |
|
|
213451470 |
Infer_no |
D |
July 12, 2023, 4:35 a.m. |
OK |
GNU C++20 (64) |
TESTS |
22 |
15 |
1024000 |
|
|
213405565 |
abhiofficial1729 |
D |
July 11, 2023, 6:09 p.m. |
OK |
GNU C++20 (64) |
TESTS |
20 |
15 |
1228800 |
|
|
213408884 |
life_of_a_samurai |
D |
July 11, 2023, 6:30 p.m. |
OK |
GNU C++20 (64) |
TESTS |
21 |
15 |
3993600 |
|
|
213404862 |
kshqsz |
D |
July 11, 2023, 6:06 p.m. |
OK |
GNU C++20 (64) |
TESTS |
20 |
15 |
3993600 |
|
|
213450384 |
ressoa |
D |
July 12, 2023, 4:15 a.m. |
OK |
GNU C++20 (64) |
TESTS |
22 |
15 |
3993600 |
|
|
213409843 |
jd_samurai |
D |
July 11, 2023, 6:37 p.m. |
OK |
GNU C++20 (64) |
TESTS |
21 |
15 |
3993600 |
|
|
213392511 |
Shrey2091 |
D |
July 11, 2023, 5:03 p.m. |
OK |
GNU C++20 (64) |
TESTS |
20 |
15 |
180326400 |
|
|
213450393 |
zyf123 |
D |
July 12, 2023, 4:15 a.m. |
OK |
Go |
TESTS |
22 |
31 |
3174400 |
|
|
213406289 |
sad_truant |
D |
July 11, 2023, 6:13 p.m. |
OK |
Java 11 |
TESTS |
20 |
171 |
0 |
|
|
213411462 |
Yousef_Badr |
D |
July 11, 2023, 6:51 p.m. |
OK |
Java 11 |
TESTS |
22 |
186 |
0 |
|
|
213407544 |
dzhi |
D |
July 11, 2023, 6:21 p.m. |
OK |
Java 11 |
TESTS |
21 |
186 |
0 |
|
|
213453091 |
vijender_8601 |
D |
July 12, 2023, 5 a.m. |
OK |
Java 11 |
TESTS |
22 |
217 |
0 |
|
|
213409734 |
venkateshaprabhu |
D |
July 11, 2023, 6:36 p.m. |
OK |
Java 11 |
TESTS |
21 |
248 |
4198400 |
|
|
213423801 |
himanshu19468 |
D |
July 11, 2023, 9:17 p.m. |
OK |
Java 11 |
TESTS |
22 |
280 |
0 |
|
|
213393868 |
Hsharma |
D |
July 11, 2023, 5:07 p.m. |
OK |
Java 11 |
TESTS |
20 |
311 |
0 |
|
|
213406267 |
Pratham2908 |
D |
July 11, 2023, 6:13 p.m. |
OK |
Java 17 |
TESTS |
20 |
186 |
716800 |
|
|
213413235 |
codebook_2000 |
D |
July 11, 2023, 7:08 p.m. |
OK |
Java 17 |
TESTS |
22 |
202 |
512000 |
|
|
213413158 |
wintersoldier2004 |
D |
July 11, 2023, 7:07 p.m. |
OK |
Java 17 |
TESTS |
22 |
218 |
307200 |
|
|
213396206 |
Asnkkzk |
D |
July 11, 2023, 5:15 p.m. |
OK |
Java 17 |
TESTS |
20 |
218 |
409600 |
|
|
213416839 |
TheLastDanceCoder |
D |
July 11, 2023, 7:47 p.m. |
OK |
Java 17 |
TESTS |
22 |
218 |
716800 |
|
|
213396375 |
LeetCodeforces_Null |
D |
July 11, 2023, 5:15 p.m. |
OK |
Java 17 |
TESTS |
20 |
233 |
204800 |
|
|
213412324 |
Akash_Sardar |
D |
July 11, 2023, 6:59 p.m. |
OK |
Java 17 |
TESTS |
22 |
233 |
512000 |
|
|
213404658 |
ManasR_2003 |
D |
July 11, 2023, 6:05 p.m. |
OK |
Java 17 |
TESTS |
20 |
248 |
42803200 |
|
|
213398894 |
Brewers |
D |
July 11, 2023, 5:24 p.m. |
OK |
Java 17 |
TESTS |
20 |
249 |
409600 |
|
|
213408295 |
Danger_Don |
D |
July 11, 2023, 6:26 p.m. |
OK |
Java 17 |
TESTS |
21 |
280 |
614400 |
|
|
213428405 |
vatsal_04 |
D |
July 11, 2023, 10:43 p.m. |
OK |
Java 8 |
TESTS |
22 |
108 |
0 |
|
|
213429062 |
raj_shahh |
D |
July 11, 2023, 10:58 p.m. |
OK |
Java 8 |
TESTS |
22 |
109 |
0 |
|
|
213447904 |
the_unseen |
D |
July 12, 2023, 3:35 a.m. |
OK |
Java 8 |
TESTS |
22 |
124 |
0 |
|
|
213419068 |
iamdimonis |
D |
July 11, 2023, 8:15 p.m. |
OK |
Java 8 |
TESTS |
22 |
140 |
0 |
|
|
213421857 |
molecule03 |
D |
July 11, 2023, 8:49 p.m. |
OK |
Java 8 |
TESTS |
22 |
155 |
38195200 |
|
|
213395850 |
vijay_panwar12 |
D |
July 11, 2023, 5:14 p.m. |
OK |
Java 8 |
TESTS |
20 |
187 |
0 |
|
|
213418956 |
bhavesh555 |
D |
July 11, 2023, 8:13 p.m. |
OK |
Java 8 |
TESTS |
22 |
218 |
0 |
|
|
213417581 |
awishkar973 |
D |
July 11, 2023, 7:57 p.m. |
OK |
Java 8 |
TESTS |
22 |
233 |
0 |
|
|
213396243 |
cherryboom_me |
D |
July 11, 2023, 5:15 p.m. |
OK |
Java 8 |
TESTS |
20 |
233 |
0 |
|
|
213428973 |
raj_shahh |
D |
July 11, 2023, 10:56 p.m. |
OK |
Java 8 |
TESTS |
22 |
670 |
76083200 |
|
|
213398506 |
xinxin_ouo |
D |
July 11, 2023, 5:23 p.m. |
OK |
MS C++ 2017 |
TESTS |
20 |
78 |
819200 |
|
|
213393453 |
return_myself |
D |
July 11, 2023, 5:06 p.m. |
OK |
MS C++ 2017 |
TESTS |
20 |
78 |
3379200 |
|
|
213453236 |
YangTuo |
D |
July 12, 2023, 5:02 a.m. |
OK |
MS C++ 2017 |
TESTS |
22 |
92 |
0 |
|
|
213427874 |
liupengsay |
D |
July 11, 2023, 10:32 p.m. |
OK |
PyPy 3 |
TESTS |
22 |
156 |
7065600 |
|
|
213414592 |
jvatsal0709 |
D |
July 11, 2023, 7:23 p.m. |
OK |
PyPy 3 |
TESTS |
22 |
186 |
5836800 |
|
|
213398277 |
Cypher13 |
D |
July 11, 2023, 5:22 p.m. |
OK |
PyPy 3 |
TESTS |
20 |
202 |
5939200 |
|
|
213393769 |
brokie |
D |
July 11, 2023, 5:07 p.m. |
OK |
PyPy 3 |
TESTS |
20 |
280 |
18124800 |
|
|
213450079 |
mohak_k |
D |
July 12, 2023, 4:09 a.m. |
OK |
PyPy 3 |
TESTS |
22 |
296 |
5120000 |
|
|
213431342 |
DrkShaden |
D |
July 11, 2023, 11:49 p.m. |
OK |
PyPy 3 |
TESTS |
22 |
342 |
18432000 |
|
|
213393725 |
vaibhav2740 |
D |
July 11, 2023, 5:07 p.m. |
OK |
PyPy 3 |
TESTS |
20 |
373 |
6451200 |
|
|
213411408 |
Leeisateam |
D |
July 11, 2023, 6:51 p.m. |
OK |
PyPy 3 |
TESTS |
22 |
499 |
71680000 |
|
|
213440346 |
InHng |
D |
July 12, 2023, 2 a.m. |
OK |
PyPy 3 |
TESTS |
22 |
701 |
10956800 |
|
|
213395665 |
amizhthni |
D |
July 11, 2023, 5:13 p.m. |
OK |
PyPy 3-64 |
TESTS |
20 |
93 |
4198400 |
|
|
213454701 |
brimstone |
D |
July 12, 2023, 5:26 a.m. |
OK |
PyPy 3-64 |
TESTS |
22 |
93 |
5120000 |
|
|
213412190 |
Meiir |
D |
July 11, 2023, 6:58 p.m. |
OK |
PyPy 3-64 |
TESTS |
22 |
93 |
5836800 |
|
|
213415510 |
Jaishriram11 |
D |
July 11, 2023, 7:33 p.m. |
OK |
PyPy 3-64 |
TESTS |
22 |
108 |
5939200 |
|
|
213421814 |
charlieC2000 |
D |
July 11, 2023, 8:48 p.m. |
OK |
PyPy 3-64 |
TESTS |
22 |
108 |
9113600 |
|
|
213427839 |
RobinFromTheHood |
D |
July 11, 2023, 10:31 p.m. |
OK |
PyPy 3-64 |
TESTS |
22 |
124 |
20684800 |
|
|
213406312 |
RobinFromTheHood |
D |
July 11, 2023, 6:13 p.m. |
OK |
PyPy 3-64 |
TESTS |
20 |
124 |
20684800 |
|
|
213398838 |
manishr |
D |
July 11, 2023, 5:24 p.m. |
OK |
PyPy 3-64 |
TESTS |
20 |
124 |
26521600 |
|
|
213438535 |
Remineva |
D |
July 12, 2023, 1:38 a.m. |
OK |
PyPy 3-64 |
TESTS |
22 |
124 |
27545600 |
|
|
213392655 |
denilb |
D |
July 11, 2023, 5:03 p.m. |
OK |
PyPy 3-64 |
TESTS |
20 |
139 |
30310400 |
|
|
213392610 |
sanskar1202 |
D |
July 11, 2023, 5:03 p.m. |
OK |
Python 2 |
TESTS |
20 |
233 |
19046400 |
|
|
213397316 |
skatiyar236 |
D |
July 11, 2023, 5:19 p.m. |
OK |
Python 3 |
TESTS |
20 |
108 |
1843200 |
|
|
213448313 |
abhijit07cf |
D |
July 12, 2023, 3:41 a.m. |
OK |
Python 3 |
TESTS |
22 |
109 |
1843200 |
|
|
213408175 |
BeanBurrito |
D |
July 11, 2023, 6:25 p.m. |
OK |
Python 3 |
TESTS |
21 |
140 |
16896000 |
|
|
213394955 |
Ethan_Hunt_96 |
D |
July 11, 2023, 5:11 p.m. |
OK |
Python 3 |
TESTS |
20 |
155 |
1843200 |
|
|
213453267 |
vasudha_1610 |
D |
July 12, 2023, 5:03 a.m. |
OK |
Python 3 |
TESTS |
22 |
233 |
16281600 |
|
|
213401692 |
Harrish_007 |
D |
July 11, 2023, 5:33 p.m. |
OK |
Python 3 |
TESTS |
20 |
374 |
4608000 |
|
|
213398331 |
hriday_27b |
D |
July 11, 2023, 5:22 p.m. |
OK |
Python 3 |
TESTS |
20 |
420 |
12595200 |
|
|
213431299 |
Arnoob2120 |
D |
July 11, 2023, 11:48 p.m. |
OK |
Python 3 |
TESTS |
22 |
530 |
3891200 |
|
|
213412325 |
DA2904 |
D |
July 11, 2023, 6:59 p.m. |
OK |
Python 3 |
TESTS |
22 |
561 |
4608000 |
|
|
213412183 |
Asharma538 |
D |
July 11, 2023, 6:57 p.m. |
OK |
Python 3 |
TESTS |
22 |
592 |
4608000 |
|
|
213449509 |
cpchenpi |
D |
July 12, 2023, 4 a.m. |
OK |
Rust 2021 |
TESTS |
22 |
15 |
1126400 |
|
|
213443060 |
YummyPie |
D |
July 12, 2023, 2:32 a.m. |
OK |
Rust 2021 |
TESTS |
22 |
31 |
0 |
|
|
213399447 |
n7484443 |
D |
July 11, 2023, 5:26 p.m. |
OK |
Rust 2021 |
TESTS |
20 |
1341 |
82432000 |
|
|
remove filters
Back to search problems