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 an easy version of the problem. In this version, k is always 3 . 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 . Drahyrt, using ancient magic, can swap letters at a distance k or k+1 in spell as many times as he wants. In this version of the problem, you can swap letters at a distance of 3 or 4 . In other words, Drahyrt can change letters in positions i and j in spell s if |i-j|=3 or |i-j|=4 . For example, if 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 , k = 3 ) -- 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 example i'... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
195746297 |
mban259 |
E1 |
March 3, 2023, 1:43 a.m. |
OK |
C# 10 |
TESTS |
22 |
46 |
3174400 |
|
|
195749007 |
1435730 |
E1 |
March 3, 2023, 2:42 a.m. |
OK |
GNU C11 |
TESTS |
22 |
61 |
409600 |
|
|
195723540 |
iamattri0001 |
E1 |
March 2, 2023, 7:08 p.m. |
OK |
GNU C++14 |
TESTS |
19 |
15 |
716800 |
|
|
195757450 |
prince077 |
E1 |
March 3, 2023, 5:01 a.m. |
OK |
GNU C++14 |
TESTS |
22 |
15 |
716800 |
|
|
195749215 |
Xanadu13 |
E1 |
March 3, 2023, 2:46 a.m. |
OK |
GNU C++14 |
TESTS |
22 |
15 |
716800 |
|
|
195746736 |
yimuhua |
E1 |
March 3, 2023, 1:53 a.m. |
OK |
GNU C++14 |
TESTS |
22 |
15 |
921600 |
|
|
195746446 |
NuLL__ |
E1 |
March 3, 2023, 1:46 a.m. |
OK |
GNU C++14 |
TESTS |
22 |
30 |
2355200 |
|
|
195752060 |
bz2021 |
E1 |
March 3, 2023, 3:36 a.m. |
OK |
GNU C++14 |
TESTS |
22 |
31 |
409600 |
|
|
195749239 |
Rotting |
E1 |
March 3, 2023, 2:46 a.m. |
OK |
GNU C++14 |
TESTS |
22 |
31 |
409600 |
|
|
195752599 |
liaopengfei |
E1 |
March 3, 2023, 3:46 a.m. |
OK |
GNU C++14 |
TESTS |
22 |
31 |
409600 |
|
|
195753670 |
Kevin8502 |
E1 |
March 3, 2023, 4:06 a.m. |
OK |
GNU C++14 |
TESTS |
22 |
31 |
716800 |
|
|
195762459 |
vaibhav_op |
E1 |
March 3, 2023, 5:59 a.m. |
OK |
GNU C++14 |
TESTS |
22 |
31 |
716800 |
|
|
195751286 |
linjiangli |
E1 |
March 3, 2023, 3:22 a.m. |
OK |
GNU C++17 |
TESTS |
22 |
15 |
716800 |
|
|
195710573 |
pradyumnkangule |
E1 |
March 2, 2023, 5:29 p.m. |
OK |
GNU C++17 |
TESTS |
19 |
15 |
716800 |
|
|
195755653 |
hardstone |
E1 |
March 3, 2023, 4:37 a.m. |
OK |
GNU C++17 |
TESTS |
22 |
15 |
716800 |
|
|
195748474 |
Freed0m8197 |
E1 |
March 3, 2023, 2:32 a.m. |
OK |
GNU C++17 |
TESTS |
22 |
15 |
30822400 |
|
|
195758535 |
bachvnk |
E1 |
March 3, 2023, 5:13 a.m. |
OK |
GNU C++17 |
TESTS |
22 |
30 |
716800 |
|
|
195754765 |
SheikhFahadShaon |
E1 |
March 3, 2023, 4:23 a.m. |
OK |
GNU C++17 |
TESTS |
22 |
30 |
716800 |
|
|
195762240 |
SahilHarkhani |
E1 |
March 3, 2023, 5:57 a.m. |
OK |
GNU C++17 |
TESTS |
22 |
30 |
716800 |
|
|
195752404 |
lO_ol |
E1 |
March 3, 2023, 3:42 a.m. |
OK |
GNU C++17 |
TESTS |
22 |
30 |
716800 |
|
|
195752056 |
lasventuras |
E1 |
March 3, 2023, 3:36 a.m. |
OK |
GNU C++17 |
TESTS |
22 |
30 |
716800 |
|
|
195754376 |
abhinav6483 |
E1 |
March 3, 2023, 4:18 a.m. |
OK |
GNU C++17 |
TESTS |
22 |
30 |
716800 |
|
|
195745854 |
rrtrrt517 |
E1 |
March 3, 2023, 1:33 a.m. |
OK |
GNU C++17 (64) |
TESTS |
22 |
15 |
716800 |
|
|
195727661 |
danielvitor23 |
E1 |
March 2, 2023, 7:49 p.m. |
OK |
GNU C++17 (64) |
TESTS |
19 |
15 |
716800 |
|
|
195722191 |
Mhamad_aboaljood |
E1 |
March 2, 2023, 6:56 p.m. |
OK |
GNU C++17 (64) |
TESTS |
19 |
15 |
716800 |
|
|
195758522 |
SA01 |
E1 |
March 3, 2023, 5:13 a.m. |
OK |
GNU C++17 (64) |
TESTS |
22 |
31 |
716800 |
|
|
195714736 |
novaa |
E1 |
March 2, 2023, 5:58 p.m. |
OK |
GNU C++17 (64) |
TESTS |
19 |
31 |
716800 |
|
|
195713030 |
I_Am_A_Noob |
E1 |
March 2, 2023, 5:46 p.m. |
OK |
GNU C++17 (64) |
TESTS |
19 |
31 |
716800 |
|
|
195759426 |
sahibsingh139 |
E1 |
March 3, 2023, 5:24 a.m. |
OK |
GNU C++17 (64) |
TESTS |
22 |
31 |
716800 |
|
|
195746856 |
Once_I_Liked_AGirl |
E1 |
March 3, 2023, 1:55 a.m. |
OK |
GNU C++17 (64) |
TESTS |
22 |
31 |
921600 |
|
|
195744336 |
alixeid |
E1 |
March 3, 2023, 12:59 a.m. |
OK |
GNU C++17 (64) |
TESTS |
22 |
31 |
921600 |
|
|
195748131 |
s7win99 |
E1 |
March 3, 2023, 2:25 a.m. |
OK |
GNU C++17 (64) |
TESTS |
22 |
31 |
921600 |
|
|
195757508 |
cjk041212 |
E1 |
March 3, 2023, 5:02 a.m. |
OK |
GNU C++20 (64) |
TESTS |
22 |
15 |
1024000 |
|
|
195756288 |
yyyh |
E1 |
March 3, 2023, 4:46 a.m. |
OK |
GNU C++20 (64) |
TESTS |
22 |
15 |
1024000 |
|
|
195756248 |
tsdk02 |
E1 |
March 3, 2023, 4:46 a.m. |
OK |
GNU C++20 (64) |
TESTS |
22 |
15 |
1024000 |
|
|
195756235 |
kmaydo |
E1 |
March 3, 2023, 4:45 a.m. |
OK |
GNU C++20 (64) |
TESTS |
22 |
15 |
1024000 |
|
|
195755800 |
bandiaoz |
E1 |
March 3, 2023, 4:39 a.m. |
OK |
GNU C++20 (64) |
TESTS |
22 |
15 |
1024000 |
|
|
195755689 |
Kakashi_ |
E1 |
March 3, 2023, 4:38 a.m. |
OK |
GNU C++20 (64) |
TESTS |
22 |
15 |
1024000 |
|
|
195753549 |
zhangzs |
E1 |
March 3, 2023, 4:04 a.m. |
OK |
GNU C++20 (64) |
TESTS |
22 |
15 |
1024000 |
|
|
195753122 |
YoungChigga |
E1 |
March 3, 2023, 3:55 a.m. |
OK |
GNU C++20 (64) |
TESTS |
22 |
15 |
1024000 |
|
|
195752886 |
funtastic_envy |
E1 |
March 3, 2023, 3:50 a.m. |
OK |
GNU C++20 (64) |
TESTS |
22 |
15 |
1024000 |
|
|
195760577 |
JO_o |
E1 |
March 3, 2023, 5:38 a.m. |
OK |
GNU C++20 (64) |
TESTS |
22 |
15 |
1024000 |
|
|
195748703 |
Jeon9811 |
E1 |
March 3, 2023, 2:37 a.m. |
OK |
Java 11 |
TESTS |
22 |
186 |
0 |
|
|
195713193 |
Reacher01 |
E1 |
March 2, 2023, 5:47 p.m. |
OK |
Java 11 |
TESTS |
19 |
202 |
40550400 |
|
|
195712122 |
anikethend1234 |
E1 |
March 2, 2023, 5:39 p.m. |
OK |
Java 11 |
TESTS |
19 |
233 |
0 |
|
|
195730026 |
dzhi |
E1 |
March 2, 2023, 8:14 p.m. |
OK |
Java 11 |
TESTS |
21 |
265 |
0 |
|
|
195715115 |
g_square |
E1 |
March 2, 2023, 6:01 p.m. |
OK |
Java 11 |
TESTS |
19 |
280 |
0 |
|
|
195739894 |
creativegiant |
E1 |
March 2, 2023, 11:08 p.m. |
OK |
Java 11 |
TESTS |
21 |
296 |
0 |
|
|
195762386 |
ilasiawo |
E1 |
March 3, 2023, 5:59 a.m. |
OK |
Java 11 |
TESTS |
22 |
327 |
0 |
|
|
195755785 |
Reacher01 |
E1 |
March 3, 2023, 4:39 a.m. |
OK |
Java 11 |
TESTS |
22 |
374 |
85504000 |
|
|
195722679 |
Eslam_Ahmed |
E1 |
March 2, 2023, 7:01 p.m. |
OK |
Java 17 |
TESTS |
19 |
218 |
409600 |
|
|
195741578 |
sarvesh_bawari |
E1 |
March 2, 2023, 11:51 p.m. |
OK |
Java 17 |
TESTS |
21 |
218 |
37785600 |
|
|
195754724 |
Saurabh_jayaswal |
E1 |
March 3, 2023, 4:23 a.m. |
OK |
Java 17 |
TESTS |
22 |
233 |
716800 |
|
|
195748940 |
Mustela_Erminea |
E1 |
March 3, 2023, 2:41 a.m. |
OK |
Java 17 |
TESTS |
22 |
249 |
819200 |
|
|
195737417 |
ahmedtawfik |
E1 |
March 2, 2023, 10:13 p.m. |
OK |
Java 17 |
TESTS |
21 |
264 |
716800 |
|
|
195740573 |
ahmedtawfik |
E1 |
March 2, 2023, 11:25 p.m. |
OK |
Java 17 |
TESTS |
21 |
265 |
512000 |
|
|
195759225 |
Black-Heart |
E1 |
March 3, 2023, 5:22 a.m. |
OK |
Java 17 |
TESTS |
22 |
280 |
921600 |
|
|
195756627 |
NerfThis |
E1 |
March 3, 2023, 4:50 a.m. |
OK |
Java 8 |
TESTS |
22 |
108 |
0 |
|
|
195751437 |
pc_wallace |
E1 |
March 3, 2023, 3:25 a.m. |
OK |
Java 8 |
TESTS |
22 |
108 |
0 |
|
|
195736676 |
mohamedhassan_c |
E1 |
March 2, 2023, 9:58 p.m. |
OK |
Java 8 |
TESTS |
21 |
109 |
5734400 |
|
|
195750482 |
Zicode |
E1 |
March 3, 2023, 3:07 a.m. |
OK |
Java 8 |
TESTS |
22 |
124 |
0 |
|
|
195720935 |
Mohamed_Ahmed |
E1 |
March 2, 2023, 6:45 p.m. |
OK |
Java 8 |
TESTS |
19 |
124 |
0 |
|
|
195762822 |
chuquwan9964 |
E1 |
March 3, 2023, 6:03 a.m. |
OK |
Java 8 |
TESTS |
22 |
171 |
0 |
|
|
195759493 |
Deependra_coder |
E1 |
March 3, 2023, 5:25 a.m. |
OK |
Java 8 |
TESTS |
22 |
187 |
0 |
|
|
195762400 |
cyclingle |
E1 |
March 3, 2023, 5:59 a.m. |
OK |
Java 8 |
TESTS |
22 |
187 |
2662400 |
|
|
195753305 |
amit_roy |
E1 |
March 3, 2023, 3:59 a.m. |
OK |
Java 8 |
TESTS |
22 |
233 |
0 |
|
|
195720044 |
nilanshu_yadav |
E1 |
March 2, 2023, 6:38 p.m. |
OK |
Java 8 |
TESTS |
19 |
265 |
0 |
|
|
195756138 |
NewPlayer169 |
E1 |
March 3, 2023, 4:44 a.m. |
OK |
Kotlin 1.7 |
TESTS |
22 |
655 |
31948800 |
|
|
195757822 |
adesh123 |
E1 |
March 3, 2023, 5:05 a.m. |
OK |
MS C++ 2017 |
TESTS |
22 |
77 |
18022400 |
|
|
195719738 |
Damirem |
E1 |
March 2, 2023, 6:35 p.m. |
OK |
PyPy 3 |
TESTS |
19 |
546 |
13721600 |
|
|
195733446 |
FlakeLCR |
E1 |
March 2, 2023, 8:59 p.m. |
OK |
PyPy 3-64 |
TESTS |
21 |
93 |
7065600 |
|
|
195720597 |
SophieHatter |
E1 |
March 2, 2023, 6:42 p.m. |
OK |
PyPy 3-64 |
TESTS |
19 |
171 |
10035200 |
|
|
195752133 |
InariInDream |
E1 |
March 3, 2023, 3:38 a.m. |
OK |
PyPy 3-64 |
TESTS |
22 |
171 |
22528000 |
|
|
195717126 |
SoleProprietor |
E1 |
March 2, 2023, 6:15 p.m. |
OK |
PyPy 3-64 |
TESTS |
19 |
186 |
22425600 |
|
|
195754814 |
The_MazeRunner |
E1 |
March 3, 2023, 4:24 a.m. |
OK |
PyPy 3-64 |
TESTS |
22 |
202 |
10547200 |
|
|
195713559 |
oneku16 |
E1 |
March 2, 2023, 5:49 p.m. |
OK |
PyPy 3-64 |
TESTS |
19 |
202 |
11264000 |
|
|
195712117 |
HimanshuRajput |
E1 |
March 2, 2023, 5:39 p.m. |
OK |
PyPy 3-64 |
TESTS |
19 |
217 |
10342400 |
|
|
195749396 |
liuaaa |
E1 |
March 3, 2023, 2:49 a.m. |
OK |
PyPy 3-64 |
TESTS |
22 |
217 |
10547200 |
|
|
195738534 |
voicon |
E1 |
March 2, 2023, 10:38 p.m. |
OK |
PyPy 3-64 |
TESTS |
21 |
217 |
22118400 |
|
|
195729148 |
moonpay |
E1 |
March 2, 2023, 8:04 p.m. |
OK |
PyPy 3-64 |
TESTS |
21 |
217 |
22220800 |
|
|
195744512 |
kanth_7 |
E1 |
March 3, 2023, 1:03 a.m. |
OK |
Python 3 |
TESTS |
22 |
140 |
1024000 |
|
|
195714810 |
PartinGQAQ |
E1 |
March 2, 2023, 5:58 p.m. |
OK |
Python 3 |
TESTS |
19 |
171 |
2969600 |
|
|
195744014 |
Schichow |
E1 |
March 3, 2023, 12:52 a.m. |
OK |
Python 3 |
TESTS |
22 |
218 |
1024000 |
|
|
195727894 |
Quick-One |
E1 |
March 2, 2023, 7:51 p.m. |
OK |
Python 3 |
TESTS |
21 |
280 |
819200 |
|
|
remove filters
Back to search problems