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 complex version of the problem. This version has no additional restrictions on the number k . The chief wizard of the Wizengamot once caught the evil wizard Drahyrt, but the evil wizard has returned and wants revenge on the chief wizard. So he stole spell s from his student Harry. The spell -- is a n -length string of lowercase Latin letters. Drahyrt wants to replace spell with an unforgivable curse -- string t . Dragirt, using ancient magic, can swap letters at a distance k or k+1 in spell as many times as he wants. In other words, Drahyrt can change letters in positions i and j in spell s if |i-j|=k or |i-j|=k+1 . For example, if k = 3, s = "talant" and t = "atltna", Drahyrt can act as follows: You are given spells s and t . Can Drahyrt change spell s to t ? The first line of input gives a single integer T ( 1 <= T <= 10^4 ) -- the number of test cases in the test. Descriptions of the test cases are follow. The first line contains two integers n, k ( 1 <= n <= 2 cdot 10^5 , 1 <= k <= 2 cdot 10^5 ) -- the length spells and the number k such that Drahyrt can change letters in a spell at a distance k or k+1 . The second line gives spell s -- a string of length n consisting of lowercase Latin letters. The third line gives spell t -- a string of length n consisting of lowercase Latin letters. It is guaranteed that the sum of n values over all test cases does not exceed 2 cdot 10^5 . Note that there is no limit on the sum of k values over all test cases. For each test case, output on a separate line "YES" if Drahyrt can change spell s to t and "NO" otherwise. You can output the answer in any case (for example, lines "yEs", "yes", "Yes" and "YES" will be recognized as positive answer). The first case is explained in the condition. In the sec'... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
195746284 |
mban259 |
E2 |
March 3, 2023, 1:43 a.m. |
OK |
C# 10 |
TESTS |
49 |
62 |
3276800 |
|
|
195748995 |
1435730 |
E2 |
March 3, 2023, 2:42 a.m. |
OK |
GNU C11 |
TESTS |
49 |
46 |
409600 |
|
|
195752062 |
bz2021 |
E2 |
March 3, 2023, 3:36 a.m. |
OK |
GNU C++14 |
TESTS |
49 |
15 |
409600 |
|
|
195749127 |
Rotting |
E2 |
March 3, 2023, 2:45 a.m. |
OK |
GNU C++14 |
TESTS |
49 |
31 |
409600 |
|
|
195752612 |
liaopengfei |
E2 |
March 3, 2023, 3:46 a.m. |
OK |
GNU C++14 |
TESTS |
49 |
31 |
409600 |
|
|
195744623 |
my_father |
E2 |
March 3, 2023, 1:06 a.m. |
OK |
GNU C++14 |
TESTS |
49 |
31 |
819200 |
|
|
195753674 |
Kevin8502 |
E2 |
March 3, 2023, 4:06 a.m. |
OK |
GNU C++14 |
TESTS |
49 |
31 |
1024000 |
|
|
195753662 |
solitude3freedom |
E2 |
March 3, 2023, 4:06 a.m. |
OK |
GNU C++14 |
TESTS |
49 |
31 |
1024000 |
|
|
195749476 |
Jeese |
E2 |
March 3, 2023, 2:51 a.m. |
OK |
GNU C++14 |
TESTS |
49 |
31 |
1024000 |
|
|
195747146 |
NgTrung2217 |
E2 |
March 3, 2023, 2:01 a.m. |
OK |
GNU C++14 |
TESTS |
49 |
31 |
1024000 |
|
|
195743002 |
Chtholly_Nephren |
E2 |
March 3, 2023, 12:28 a.m. |
OK |
GNU C++14 |
TESTS |
48 |
31 |
1024000 |
|
|
195762428 |
vaibhav_op |
E2 |
March 3, 2023, 5:59 a.m. |
OK |
GNU C++14 |
TESTS |
49 |
31 |
1024000 |
|
|
195742687 |
Nas |
E2 |
March 3, 2023, 12:21 a.m. |
OK |
GNU C++17 |
TESTS |
48 |
30 |
1024000 |
|
|
195710637 |
pradyumnkangule |
E2 |
March 2, 2023, 5:30 p.m. |
OK |
GNU C++17 |
TESTS |
48 |
30 |
1024000 |
|
|
195750274 |
Entropy_Reducer |
E2 |
March 3, 2023, 3:04 a.m. |
OK |
GNU C++17 |
TESTS |
49 |
30 |
1024000 |
|
|
195715904 |
Nikhil_Ollala |
E2 |
March 2, 2023, 6:06 p.m. |
OK |
GNU C++17 |
TESTS |
48 |
31 |
409600 |
|
|
195712225 |
edwardnvv57k |
E2 |
March 2, 2023, 5:40 p.m. |
OK |
GNU C++17 |
TESTS |
48 |
31 |
409600 |
|
|
195745259 |
finalissima |
E2 |
March 3, 2023, 1:20 a.m. |
OK |
GNU C++17 |
TESTS |
49 |
31 |
409600 |
|
|
195716036 |
Nikhil_Ollala |
E2 |
March 2, 2023, 6:07 p.m. |
OK |
GNU C++17 |
TESTS |
48 |
31 |
409600 |
|
|
195761502 |
yashesh_07 |
E2 |
March 3, 2023, 5:49 a.m. |
OK |
GNU C++17 |
TESTS |
49 |
31 |
1024000 |
|
|
195761422 |
ryuga01 |
E2 |
March 3, 2023, 5:48 a.m. |
OK |
GNU C++17 |
TESTS |
49 |
31 |
1024000 |
|
|
195759395 |
aviraj_69 |
E2 |
March 3, 2023, 5:24 a.m. |
OK |
GNU C++17 |
TESTS |
49 |
31 |
1024000 |
|
|
195746438 |
3304701766 |
E2 |
March 3, 2023, 1:46 a.m. |
OK |
GNU C++17 (64) |
TESTS |
49 |
15 |
1024000 |
|
|
195722352 |
Mhamad_aboaljood |
E2 |
March 2, 2023, 6:58 p.m. |
OK |
GNU C++17 (64) |
TESTS |
48 |
30 |
1024000 |
|
|
195745860 |
rrtrrt517 |
E2 |
March 3, 2023, 1:33 a.m. |
OK |
GNU C++17 (64) |
TESTS |
49 |
30 |
1024000 |
|
|
195727287 |
danielvitor23 |
E2 |
March 2, 2023, 7:45 p.m. |
OK |
GNU C++17 (64) |
TESTS |
48 |
31 |
1024000 |
|
|
195727231 |
danielvitor23 |
E2 |
March 2, 2023, 7:44 p.m. |
OK |
GNU C++17 (64) |
TESTS |
48 |
31 |
1024000 |
|
|
195714780 |
novaa |
E2 |
March 2, 2023, 5:58 p.m. |
OK |
GNU C++17 (64) |
TESTS |
48 |
31 |
1024000 |
|
|
195713087 |
I_Am_A_Noob |
E2 |
March 2, 2023, 5:46 p.m. |
OK |
GNU C++17 (64) |
TESTS |
48 |
31 |
1024000 |
|
|
195759404 |
sahibsingh139 |
E2 |
March 3, 2023, 5:24 a.m. |
OK |
GNU C++17 (64) |
TESTS |
49 |
31 |
1024000 |
|
|
195758505 |
SA01 |
E2 |
March 3, 2023, 5:13 a.m. |
OK |
GNU C++17 (64) |
TESTS |
49 |
31 |
1024000 |
|
|
195748121 |
s7win99 |
E2 |
March 3, 2023, 2:25 a.m. |
OK |
GNU C++17 (64) |
TESTS |
49 |
31 |
1228800 |
|
|
195752034 |
smile216 |
E2 |
March 3, 2023, 3:36 a.m. |
OK |
GNU C++20 (64) |
TESTS |
49 |
15 |
409600 |
|
|
195757515 |
cjk041212 |
E2 |
March 3, 2023, 5:02 a.m. |
OK |
GNU C++20 (64) |
TESTS |
49 |
15 |
1024000 |
|
|
195759192 |
wtf._. |
E2 |
March 3, 2023, 5:22 a.m. |
OK |
GNU C++20 (64) |
TESTS |
49 |
15 |
1024000 |
|
|
195756269 |
yyyh |
E2 |
March 3, 2023, 4:46 a.m. |
OK |
GNU C++20 (64) |
TESTS |
49 |
15 |
1024000 |
|
|
195751365 |
JiangZi |
E2 |
March 3, 2023, 3:24 a.m. |
OK |
GNU C++20 (64) |
TESTS |
49 |
15 |
1024000 |
|
|
195751350 |
TONEY |
E2 |
March 3, 2023, 3:23 a.m. |
OK |
GNU C++20 (64) |
TESTS |
49 |
15 |
1024000 |
|
|
195751055 |
isheoran |
E2 |
March 3, 2023, 3:18 a.m. |
OK |
GNU C++20 (64) |
TESTS |
49 |
15 |
1024000 |
|
|
195748748 |
zwu2020015020 |
E2 |
March 3, 2023, 2:37 a.m. |
OK |
GNU C++20 (64) |
TESTS |
49 |
15 |
1024000 |
|
|
195744094 |
hiro220214 |
E2 |
March 3, 2023, 12:54 a.m. |
OK |
GNU C++20 (64) |
TESTS |
49 |
15 |
1024000 |
|
|
195743981 |
somaigaurav |
E2 |
March 3, 2023, 12:51 a.m. |
OK |
GNU C++20 (64) |
TESTS |
49 |
15 |
1024000 |
|
|
195715319 |
Reacher01 |
E2 |
March 2, 2023, 6:02 p.m. |
OK |
Java 11 |
TESTS |
48 |
233 |
40652800 |
|
|
195712156 |
anikethend1234 |
E2 |
March 2, 2023, 5:40 p.m. |
OK |
Java 11 |
TESTS |
48 |
249 |
0 |
|
|
195754190 |
aditya2024 |
E2 |
March 3, 2023, 4:15 a.m. |
OK |
Java 11 |
TESTS |
49 |
280 |
0 |
|
|
195715981 |
g_square |
E2 |
March 2, 2023, 6:07 p.m. |
OK |
Java 11 |
TESTS |
48 |
295 |
0 |
|
|
195716850 |
koteswaruduakula |
E2 |
March 2, 2023, 6:13 p.m. |
OK |
Java 11 |
TESTS |
48 |
327 |
204800 |
|
|
195762412 |
ilasiawo |
E2 |
March 3, 2023, 5:59 a.m. |
OK |
Java 11 |
TESTS |
49 |
343 |
0 |
|
|
195730735 |
dzhi |
E2 |
March 2, 2023, 8:22 p.m. |
OK |
Java 11 |
TESTS |
48 |
343 |
40345600 |
|
|
195755819 |
Reacher01 |
E2 |
March 3, 2023, 4:39 a.m. |
OK |
Java 11 |
TESTS |
49 |
389 |
86118400 |
|
|
195741573 |
sarvesh_bawari |
E2 |
March 2, 2023, 11:51 p.m. |
OK |
Java 17 |
TESTS |
48 |
202 |
37785600 |
|
|
195722726 |
Eslam_Ahmed |
E2 |
March 2, 2023, 7:01 p.m. |
OK |
Java 17 |
TESTS |
48 |
218 |
512000 |
|
|
195754758 |
Saurabh_jayaswal |
E2 |
March 3, 2023, 4:23 a.m. |
OK |
Java 17 |
TESTS |
49 |
249 |
614400 |
|
|
195748923 |
Mustela_Erminea |
E2 |
March 3, 2023, 2:40 a.m. |
OK |
Java 17 |
TESTS |
49 |
264 |
512000 |
|
|
195740605 |
ahmedtawfik |
E2 |
March 2, 2023, 11:26 p.m. |
OK |
Java 17 |
TESTS |
48 |
264 |
819200 |
|
|
195740734 |
ahmedtawfik |
E2 |
March 2, 2023, 11:29 p.m. |
OK |
Java 17 |
TESTS |
48 |
280 |
716800 |
|
|
195746561 |
SugoiTurtle |
E2 |
March 3, 2023, 1:49 a.m. |
OK |
Java 17 |
TESTS |
49 |
295 |
409600 |
|
|
195754947 |
sksarfaraz786 |
E2 |
March 3, 2023, 4:26 a.m. |
OK |
Java 17 |
TESTS |
49 |
327 |
1024000 |
|
|
195751448 |
pc_wallace |
E2 |
March 3, 2023, 3:25 a.m. |
OK |
Java 8 |
TESTS |
49 |
109 |
0 |
|
|
195750507 |
Zicode |
E2 |
March 3, 2023, 3:08 a.m. |
OK |
Java 8 |
TESTS |
49 |
109 |
0 |
|
|
195720971 |
Mohamed_Ahmed |
E2 |
March 2, 2023, 6:46 p.m. |
OK |
Java 8 |
TESTS |
48 |
109 |
0 |
|
|
195757456 |
NerfThis |
E2 |
March 3, 2023, 5:01 a.m. |
OK |
Java 8 |
TESTS |
49 |
124 |
0 |
|
|
195736720 |
mohamedhassan_c |
E2 |
March 2, 2023, 9:59 p.m. |
OK |
Java 8 |
TESTS |
48 |
124 |
5836800 |
|
|
195762774 |
chuquwan9964 |
E2 |
March 3, 2023, 6:03 a.m. |
OK |
Java 8 |
TESTS |
49 |
186 |
0 |
|
|
195762363 |
cyclingle |
E2 |
March 3, 2023, 5:58 a.m. |
OK |
Java 8 |
TESTS |
49 |
187 |
2662400 |
|
|
195759539 |
Deependra_coder |
E2 |
March 3, 2023, 5:25 a.m. |
OK |
Java 8 |
TESTS |
49 |
202 |
0 |
|
|
195753334 |
amit_roy |
E2 |
March 3, 2023, 3:59 a.m. |
OK |
Java 8 |
TESTS |
49 |
234 |
0 |
|
|
195756180 |
NewPlayer169 |
E2 |
March 3, 2023, 4:44 a.m. |
OK |
Kotlin 1.7 |
TESTS |
49 |
624 |
24268800 |
|
|
195744135 |
B-i-l-l |
E2 |
March 3, 2023, 12:54 a.m. |
OK |
MS C++ 2017 |
TESTS |
49 |
62 |
819200 |
|
|
195757870 |
adesh123 |
E2 |
March 3, 2023, 5:05 a.m. |
OK |
MS C++ 2017 |
TESTS |
49 |
78 |
18022400 |
|
|
195733440 |
FlakeLCR |
E2 |
March 2, 2023, 8:59 p.m. |
OK |
PyPy 3-64 |
TESTS |
48 |
108 |
7168000 |
|
|
195720655 |
SophieHatter |
E2 |
March 2, 2023, 6:43 p.m. |
OK |
PyPy 3-64 |
TESTS |
48 |
171 |
9830400 |
|
|
195729138 |
moonpay |
E2 |
March 2, 2023, 8:03 p.m. |
OK |
PyPy 3-64 |
TESTS |
48 |
187 |
22118400 |
|
|
195738550 |
voicon |
E2 |
March 2, 2023, 10:38 p.m. |
OK |
PyPy 3-64 |
TESTS |
48 |
202 |
22118400 |
|
|
195709719 |
-Neel- |
E2 |
March 2, 2023, 5:24 p.m. |
OK |
PyPy 3-64 |
TESTS |
48 |
202 |
22118400 |
|
|
195717079 |
SoleProprietor |
E2 |
March 2, 2023, 6:15 p.m. |
OK |
PyPy 3-64 |
TESTS |
48 |
202 |
22528000 |
|
|
195752080 |
InariInDream |
E2 |
March 3, 2023, 3:37 a.m. |
OK |
PyPy 3-64 |
TESTS |
49 |
202 |
22835200 |
|
|
195754830 |
The_MazeRunner |
E2 |
March 3, 2023, 4:25 a.m. |
OK |
PyPy 3-64 |
TESTS |
49 |
218 |
10854400 |
|
|
195754899 |
The_MazeRunner |
E2 |
March 3, 2023, 4:26 a.m. |
OK |
PyPy 3-64 |
TESTS |
49 |
218 |
11161600 |
|
|
195712064 |
HimanshuRajput |
E2 |
March 2, 2023, 5:39 p.m. |
OK |
PyPy 3-64 |
TESTS |
48 |
233 |
10547200 |
|
|
195744530 |
kanth_7 |
E2 |
March 3, 2023, 1:03 a.m. |
OK |
Python 3 |
TESTS |
49 |
140 |
1024000 |
|
|
195711278 |
az_1zbek |
E2 |
March 2, 2023, 5:34 p.m. |
OK |
Python 3 |
TESTS |
48 |
155 |
2969600 |
|
|
195755380 |
sm745052 |
E2 |
March 3, 2023, 4:33 a.m. |
OK |
Python 3 |
TESTS |
49 |
156 |
3788800 |
|
|
195714941 |
PartinGQAQ |
E2 |
March 2, 2023, 5:59 p.m. |
OK |
Python 3 |
TESTS |
48 |
171 |
3174400 |
|
|
195729094 |
Quick-One |
E2 |
March 2, 2023, 8:03 p.m. |
OK |
Python 3 |
TESTS |
48 |
202 |
921600 |
|
|
195744079 |
Schichow |
E2 |
March 3, 2023, 12:53 a.m. |
OK |
Python 3 |
TESTS |
49 |
202 |
1024000 |
|
|
remove filters
Back to search problems