| Task: | Edit distance |
| Sender: | Wu xiaobo |
| Submission time: | 2020-09-12 14:21:44 +0300 |
| Language: | Python2 (CPython2) |
| Status: | READY |
| Result: | RUNTIME ERROR |
| test | verdict | time | |
|---|---|---|---|
| #1 | RUNTIME ERROR | 0.02 s | details |
| #2 | RUNTIME ERROR | 0.02 s | details |
| #3 | RUNTIME ERROR | 0.02 s | details |
| #4 | RUNTIME ERROR | 0.02 s | details |
| #5 | RUNTIME ERROR | 0.02 s | details |
| #6 | RUNTIME ERROR | 0.02 s | details |
| #7 | RUNTIME ERROR | 0.02 s | details |
| #8 | RUNTIME ERROR | 0.02 s | details |
| #9 | RUNTIME ERROR | 0.02 s | details |
| #10 | RUNTIME ERROR | 0.02 s | details |
| #11 | RUNTIME ERROR | 0.02 s | details |
| #12 | RUNTIME ERROR | 0.02 s | details |
| #13 | RUNTIME ERROR | 0.02 s | details |
| #14 | RUNTIME ERROR | 0.02 s | details |
| #15 | RUNTIME ERROR | 0.02 s | details |
| #16 | RUNTIME ERROR | 0.02 s | details |
| #17 | RUNTIME ERROR | 0.02 s | details |
| #18 | RUNTIME ERROR | 0.02 s | details |
| #19 | RUNTIME ERROR | 0.02 s | details |
Code
# from collections import deque
# word1 = input()
# word2 = input()
#
# visit, q = set(), deque([(word1, word2, 0)])
# while True:
# w1, w2, d = q.popleft()
# if (w1, w2) not in visit:
# if w1 == w2:
# print(d)
# break
# visit.add((w1, w2))
# while w1 and w2 and w1[0] == w2[0]:
# w1, w2= w1[1:], w2[1:]
# d += 1
# q.extend([(w1[1:], w2[1:], d), (w1, w2[1:], d), (w1[1:], w2, d)])
word1 = input()
word2 = input()
if not word1:
print(len(word2 or '') or 0)
elif not word2:
print(len(word1 or '') or 0)
else:
size1 = len(word1)
size2 = len(word2)
last = 0
tmp = list(range(size2 + 1))
value = None
for i in range(size1):
tmp[0] = i + 1
last = i
# print word1[i], last, tmp
for j in range(size2):
if word1[i] == word2[j]:
value = last
else:
value = 1 + min(last, tmp[j], tmp[j + 1])
# print(last, tmp[j], tmp[j + 1], value)
last = tmp[j+1]
tmp[j+1] = value
# print tmp
print(value)Test details
Test 1
Verdict: RUNTIME ERROR
| input |
|---|
| NEABJPJOI RFMQRJKJKIA |
| correct output |
|---|
| 8 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 18, in <module>
word1...Test 2
Verdict: RUNTIME ERROR
| input |
|---|
| TWXFUABGBNLTBFNSUVQW GPNJILFXJUIZPLTVUIB |
| correct output |
|---|
| 19 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 18, in <module>
word1...Test 3
Verdict: RUNTIME ERROR
| input |
|---|
| HSMOWJXKGRWSMD JMRTLLNPXKKXZC |
| correct output |
|---|
| 14 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 18, in <module>
word1...Test 4
Verdict: RUNTIME ERROR
| input |
|---|
| NGPYCNPO UQPXWVLGHC |
| correct output |
|---|
| 9 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 18, in <module>
word1...Test 5
Verdict: RUNTIME ERROR
| input |
|---|
| SQTCKWAMFJEBV IUWGGNJOMQFP |
| correct output |
|---|
| 13 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 18, in <module>
word1...Test 6
Verdict: RUNTIME ERROR
| input |
|---|
| VDREWLLHMEVGFGBXJJOSSLHNJBOTRK... |
| correct output |
|---|
| 4047 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 18, in <module>
word1...Test 7
Verdict: RUNTIME ERROR
| input |
|---|
| EIIUUQXSAFMTRSEZSFYNSAGHUWTSGY... |
| correct output |
|---|
| 3769 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 18, in <module>
word1...Test 8
Verdict: RUNTIME ERROR
| input |
|---|
| HVOXUVAZYFBKEWQXVGJMYXCCXBWRNW... |
| correct output |
|---|
| 3806 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 18, in <module>
word1...Test 9
Verdict: RUNTIME ERROR
| input |
|---|
| AWGASQANDZQTVKXQDKWNADQDBXKCOK... |
| correct output |
|---|
| 4069 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 18, in <module>
word1...Test 10
Verdict: RUNTIME ERROR
| input |
|---|
| WXAAJJALZRLGLSXDPUPURULYINBFGX... |
| correct output |
|---|
| 3874 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 18, in <module>
word1...Test 11
Verdict: RUNTIME ERROR
| input |
|---|
| A A |
| correct output |
|---|
| 0 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 18, in <module>
word1...Test 12
Verdict: RUNTIME ERROR
| input |
|---|
| A B |
| correct output |
|---|
| 1 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 18, in <module>
word1...Test 13
Verdict: RUNTIME ERROR
| input |
|---|
| AA A |
| correct output |
|---|
| 1 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 18, in <module>
word1...Test 14
Verdict: RUNTIME ERROR
| input |
|---|
| A AA |
| correct output |
|---|
| 1 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 18, in <module>
word1...Test 15
Verdict: RUNTIME ERROR
| input |
|---|
| AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA... |
| correct output |
|---|
| 5000 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 18, in <module>
word1...Test 16
Verdict: RUNTIME ERROR
| input |
|---|
| AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA... |
| correct output |
|---|
| 0 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 18, in <module>
word1...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 18, in <module>
word1...Test 18
Verdict: RUNTIME ERROR
| input |
|---|
| AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA... |
| correct output |
|---|
| 5000 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 18, in <module>
word1...Test 19
Verdict: RUNTIME ERROR
| input |
|---|
| KITTEN SITTING |
| correct output |
|---|
| 3 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 18, in <module>
word1...