QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#59504 | #3491. Meow Factor 2 | yahoco | TL | 13ms | 6780kb | Python2 | 511b | 2022-10-29 19:32:42 | 2022-10-29 19:33:40 |
Judging History
answer
P = 'meow'
S = raw_input()
n = len(S)
opt = [i % 5 for i in range(5*(n+1))]
ans = 4
for i in range(n):
for j in range(4):
opt[5*(i+1)+j+1] = min(opt[5*i+j+1] + 1, # del
opt[5*(i+1)+j] + 1, # ins
opt[5*i+j] + (S[i] != P[j])) # sub
if i > 0 and j > 0 and S[i] == P[j-1] and S[i-1] == P[j]: # swap
opt[5*(i+1)+j+1] = min(opt[5*(i+1)+j+1], 1 + opt[5*(i-1)+j-1])
ans = min(ans, opt[5*(i+1)+4])
print ans
詳細信息
Test #1:
score: 100
Accepted
time: 12ms
memory: 6572kb
input:
pastimeofwhimsy
output:
1
result:
ok single line: '1'
Test #2:
score: 0
Accepted
time: 5ms
memory: 6732kb
input:
yarn
output:
4
result:
ok single line: '4'
Test #3:
score: 0
Accepted
time: 7ms
memory: 6696kb
input:
meow
output:
0
result:
ok single line: '0'
Test #4:
score: 0
Accepted
time: 13ms
memory: 6780kb
input:
z
output:
4
result:
ok single line: '4'
Test #5:
score: 0
Accepted
time: 6ms
memory: 6732kb
input:
o
output:
3
result:
ok single line: '3'
Test #6:
score: -100
Time Limit Exceeded
input:
meomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeomeo...