| Task: | Edit distance |
| Sender: | Wu xiaobo |
| Submission time: | 2020-09-12 13:47:21 +0300 |
| Language: | Python3 (CPython3) |
| Status: | READY |
| Result: | RUNTIME ERROR |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.02 s | details |
| #2 | ACCEPTED | 0.02 s | details |
| #3 | ACCEPTED | 0.02 s | details |
| #4 | ACCEPTED | 0.02 s | details |
| #5 | ACCEPTED | 0.02 s | details |
| #6 | RUNTIME ERROR | 0.49 s | details |
| #7 | RUNTIME ERROR | 0.42 s | details |
| #8 | RUNTIME ERROR | 0.42 s | details |
| #9 | RUNTIME ERROR | 0.45 s | details |
| #10 | RUNTIME ERROR | 0.43 s | details |
| #11 | ACCEPTED | 0.02 s | details |
| #12 | ACCEPTED | 0.02 s | details |
| #13 | ACCEPTED | 0.02 s | details |
| #14 | ACCEPTED | 0.02 s | details |
| #15 | RUNTIME ERROR | 0.03 s | details |
| #16 | RUNTIME ERROR | 0.56 s | details |
| #17 | RUNTIME ERROR | 0.03 s | details |
| #18 | RUNTIME ERROR | 0.56 s | details |
| #19 | ACCEPTED | 0.02 s | details |
Code
word1 = input()
word2 = input()
n1 = len(word1)
n2 = len(word2)
dp = [[-1] * (n2 + 1) for _ in range(n1 + 1)]
def helper(n1, n2):
if dp[n1][n2] >= 0:
return dp[n1][n2]
if not n1 or not n2:
q = n1 + n2
else:
if word1[n1 - 1] == word2[n2 - 1]:
q = helper(n1 - 1, n2 - 1)
else:
q = min(helper(n1 - 1, n2), helper(n1, n2 - 1), helper(n1 - 1, n2 - 1)) + 1
dp[n1][n2] = q
return q
print(helper(n1, n2))Test details
Test 1
Verdict: ACCEPTED
| input |
|---|
| NEABJPJOI RFMQRJKJKIA |
| correct output |
|---|
| 8 |
| user output |
|---|
| 8 |
Test 2
Verdict: ACCEPTED
| input |
|---|
| TWXFUABGBNLTBFNSUVQW GPNJILFXJUIZPLTVUIB |
| correct output |
|---|
| 19 |
| user output |
|---|
| 19 |
Test 3
Verdict: ACCEPTED
| input |
|---|
| HSMOWJXKGRWSMD JMRTLLNPXKKXZC |
| correct output |
|---|
| 14 |
| user output |
|---|
| 14 |
Test 4
Verdict: ACCEPTED
| input |
|---|
| NGPYCNPO UQPXWVLGHC |
| correct output |
|---|
| 9 |
| user output |
|---|
| 9 |
Test 5
Verdict: ACCEPTED
| input |
|---|
| SQTCKWAMFJEBV IUWGGNJOMQFP |
| correct output |
|---|
| 13 |
| user output |
|---|
| 13 |
Test 6
Verdict: RUNTIME ERROR
| input |
|---|
| VDREWLLHMEVGFGBXJJOSSLHNJBOTRK... |
| correct output |
|---|
| 4047 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 23, in <module>
print(...Test 7
Verdict: RUNTIME ERROR
| input |
|---|
| EIIUUQXSAFMTRSEZSFYNSAGHUWTSGY... |
| correct output |
|---|
| 3769 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 23, in <module>
print(...Test 8
Verdict: RUNTIME ERROR
| input |
|---|
| HVOXUVAZYFBKEWQXVGJMYXCCXBWRNW... |
| correct output |
|---|
| 3806 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 23, in <module>
print(...Test 9
Verdict: RUNTIME ERROR
| input |
|---|
| AWGASQANDZQTVKXQDKWNADQDBXKCOK... |
| correct output |
|---|
| 4069 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 23, in <module>
print(...Test 10
Verdict: RUNTIME ERROR
| input |
|---|
| WXAAJJALZRLGLSXDPUPURULYINBFGX... |
| correct output |
|---|
| 3874 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 23, in <module>
print(...Test 11
Verdict: ACCEPTED
| input |
|---|
| A A |
| correct output |
|---|
| 0 |
| user output |
|---|
| 0 |
Test 12
Verdict: ACCEPTED
| input |
|---|
| A B |
| correct output |
|---|
| 1 |
| user output |
|---|
| 1 |
Test 13
Verdict: ACCEPTED
| input |
|---|
| AA A |
| correct output |
|---|
| 1 |
| user output |
|---|
| 1 |
Test 14
Verdict: ACCEPTED
| input |
|---|
| A AA |
| correct output |
|---|
| 1 |
| user output |
|---|
| 1 |
Test 15
Verdict: RUNTIME ERROR
| input |
|---|
| AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA... |
| correct output |
|---|
| 5000 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 23, in <module>
print(...Test 16
Verdict: RUNTIME ERROR
| input |
|---|
| AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA... |
| correct output |
|---|
| 0 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 23, in <module>
print(...Test 17
Verdict: RUNTIME ERROR
| input |
|---|
| B AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA... |
| correct output |
|---|
| 5000 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 23, in <module>
print(...Test 18
Verdict: RUNTIME ERROR
| input |
|---|
| AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA... |
| correct output |
|---|
| 5000 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 23, in <module>
print(...Test 19
Verdict: ACCEPTED
| input |
|---|
| KITTEN SITTING |
| correct output |
|---|
| 3 |
| user output |
|---|
| 3 |
