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'You wanted to write a text t consisting of m lowercase Latin letters. But instead, you have written a text s consisting of n lowercase Latin letters, and now you want to fix it by obtaining the text t from the text s . Initially, the cursor of your text editor is at the end of the text s (after its last character). In one move, you can do one of the following actions: Your task is to calculate the minimum number of moves required to obtain the text t from the text s using the given set of actions, or determine it is impossible to obtain the text t from the text s . You have to answer T independent test cases. The first line of the input contains one integer T ( 1 <= T <= 5000 ) -- the number of test cases. Then T test cases follow. The first line of the test case contains two integers n and m ( 1 <= m <= n <= 5000 ) -- the length of s and the length of t , respectively. The second line of the test case contains the string s consisting of n lowercase Latin letters. The third line of the test case contains the string t consisting of m lowercase Latin letters. It is guaranteed that the sum of n over all test cases does not exceed 5000 ( sum n <= 5000 ). For each test case, print one integer -- the minimum number of moves required to obtain the text t from the text s using the given set of actions, or -1 if it is impossible to obtain the text t from the text s in the given test case. '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
163302953 |
mban259 |
E |
July 8, 2022, 4:47 p.m. |
OK |
C# 10 |
TESTS |
64 |
421 |
154828800 |
|
|
163334810 |
gray-youth |
E |
July 9, 2022, 3:18 a.m. |
OK |
GNU C++14 |
TESTS |
64 |
93 |
100659200 |
|
|
163328614 |
kevin006 |
E |
July 9, 2022, 1:05 a.m. |
OK |
GNU C++14 |
TESTS |
64 |
93 |
100659200 |
|
|
163332644 |
zjhztxy |
E |
July 9, 2022, 2:38 a.m. |
OK |
GNU C++14 |
TESTS |
64 |
109 |
150630400 |
|
|
163332841 |
zjhztxy |
E |
July 9, 2022, 2:42 a.m. |
OK |
GNU C++14 |
TESTS |
64 |
124 |
150630400 |
|
|
163305374 |
F99_ll_H21 |
E |
July 8, 2022, 5:04 p.m. |
OK |
GNU C++14 |
TESTS |
64 |
139 |
409600 |
|
|
163334127 |
BARBARIANNNNN |
E |
July 9, 2022, 3:06 a.m. |
OK |
GNU C++14 |
TESTS |
64 |
140 |
100454400 |
|
|
163322509 |
Kaitokid |
E |
July 8, 2022, 9:25 p.m. |
OK |
GNU C++14 |
TESTS |
64 |
140 |
100659200 |
|
|
163303923 |
zmj2008AKIOI |
E |
July 8, 2022, 4:53 p.m. |
OK |
GNU C++14 |
TESTS |
64 |
155 |
100659200 |
|
|
163300769 |
caan_do |
E |
July 8, 2022, 4:36 p.m. |
OK |
GNU C++14 |
TESTS |
64 |
187 |
204800 |
|
|
163333864 |
jucason_chen |
E |
July 9, 2022, 3:01 a.m. |
OK |
GNU C++14 |
TESTS |
64 |
202 |
3276800 |
|
|
163306453 |
1459007298 |
E |
July 8, 2022, 5:14 p.m. |
OK |
GNU C++17 |
TESTS |
64 |
31 |
102400 |
|
|
163304136 |
QwQATMQwQ |
E |
July 8, 2022, 4:54 p.m. |
OK |
GNU C++17 |
TESTS |
64 |
31 |
102400 |
|
|
163298178 |
chaiyihan |
E |
July 8, 2022, 4:31 p.m. |
OK |
GNU C++17 |
TESTS |
64 |
31 |
102400 |
|
|
163305196 |
Splashing |
E |
July 8, 2022, 5:03 p.m. |
OK |
GNU C++17 |
TESTS |
64 |
62 |
100454400 |
|
|
163330878 |
limbo16 |
E |
July 9, 2022, 2:04 a.m. |
OK |
GNU C++17 |
TESTS |
64 |
93 |
100352000 |
|
|
163306660 |
DeadlyPillow |
E |
July 8, 2022, 5:16 p.m. |
OK |
GNU C++17 |
TESTS |
64 |
93 |
100556800 |
|
|
163312280 |
PineapplesOnPizza |
E |
July 8, 2022, 6:21 p.m. |
OK |
GNU C++17 |
TESTS |
64 |
124 |
200806400 |
|
|
163337937 |
sky123 |
E |
July 9, 2022, 4:19 a.m. |
OK |
GNU C++17 |
TESTS |
64 |
139 |
100454400 |
|
|
163337990 |
suiren |
E |
July 9, 2022, 4:20 a.m. |
OK |
GNU C++17 |
TESTS |
64 |
139 |
100659200 |
|
|
163344811 |
xiong_dream_master |
E |
July 9, 2022, 5:57 a.m. |
OK |
GNU C++17 |
TESTS |
64 |
139 |
100761600 |
|
|
163297241 |
keziaaurelia |
E |
July 8, 2022, 4:29 p.m. |
OK |
GNU C++17 (64) |
TESTS |
64 |
15 |
8089600 |
|
|
163297304 |
Kude |
E |
July 8, 2022, 4:29 p.m. |
OK |
GNU C++17 (64) |
TESTS |
64 |
31 |
819200 |
|
|
163341409 |
victor.gao |
E |
July 9, 2022, 5:15 a.m. |
OK |
GNU C++17 (64) |
TESTS |
64 |
93 |
100864000 |
|
|
163336291 |
LebronDurant |
E |
July 9, 2022, 3:47 a.m. |
OK |
GNU C++17 (64) |
TESTS |
64 |
93 |
105472000 |
|
|
163333202 |
zjhztxy |
E |
July 9, 2022, 2:49 a.m. |
OK |
GNU C++17 (64) |
TESTS |
64 |
108 |
150528000 |
|
|
163332929 |
luogu_bot1 |
E |
July 9, 2022, 2:44 a.m. |
OK |
GNU C++17 (64) |
TESTS |
64 |
108 |
150528000 |
|
|
163300931 |
Wangxueyi |
E |
July 8, 2022, 4:37 p.m. |
OK |
GNU C++17 (64) |
TESTS |
64 |
124 |
102400 |
|
|
163301822 |
dean.menezes |
E |
July 8, 2022, 4:41 p.m. |
OK |
GNU C++17 (64) |
TESTS |
64 |
155 |
100556800 |
|
|
163332891 |
gqf123 |
E |
July 9, 2022, 2:43 a.m. |
OK |
GNU C++17 (64) |
TESTS |
64 |
170 |
100659200 |
|
|
163337046 |
Artemis_Bow |
E |
July 9, 2022, 4:02 a.m. |
OK |
GNU C++17 (64) |
TESTS |
64 |
187 |
102400 |
|
|
163337552 |
road_police |
E |
July 9, 2022, 4:12 a.m. |
OK |
GNU C++20 (64) |
TESTS |
64 |
15 |
0 |
|
|
163315985 |
mars4 |
E |
July 8, 2022, 7:14 p.m. |
OK |
GNU C++20 (64) |
TESTS |
64 |
46 |
0 |
|
|
163305717 |
shadow221213 |
E |
July 8, 2022, 5:07 p.m. |
OK |
GNU C++20 (64) |
TESTS |
64 |
124 |
102400 |
|
|
163315131 |
kaiboy |
E |
July 8, 2022, 7 p.m. |
OK |
GNU C++20 (64) |
TESTS |
64 |
124 |
100249600 |
|
|
163331216 |
lx_tyin |
E |
July 9, 2022, 2:11 a.m. |
OK |
GNU C++20 (64) |
TESTS |
64 |
139 |
100352000 |
|
|
163344959 |
Gats |
E |
July 9, 2022, 5:59 a.m. |
OK |
GNU C++20 (64) |
TESTS |
64 |
140 |
100556800 |
|
|
163330615 |
WinterLove |
E |
July 9, 2022, 1:58 a.m. |
OK |
GNU C++20 (64) |
TESTS |
64 |
140 |
100659200 |
|
|
163345000 |
Gats |
E |
July 9, 2022, 5:59 a.m. |
OK |
GNU C++20 (64) |
TESTS |
64 |
155 |
100556800 |
|
|
163332257 |
star. |
E |
July 9, 2022, 2:30 a.m. |
OK |
GNU C++20 (64) |
TESTS |
64 |
155 |
100556800 |
|
|
163300715 |
liouzhou_101 |
E |
July 8, 2022, 4:36 p.m. |
OK |
GNU C++20 (64) |
TESTS |
64 |
155 |
102707200 |
|
|
163310868 |
Dukkha |
E |
July 8, 2022, 6:03 p.m. |
OK |
Java 11 |
TESTS |
64 |
685 |
260505600 |
|
|
163307931 |
cjcjcjcj |
E |
July 8, 2022, 5:29 p.m. |
OK |
Java 8 |
TESTS |
64 |
1918 |
259072000 |
|
|
remove filters
Back to search problems