QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#59504#3491. Meow Factor 2yahocoTL 13ms6780kbPython2511b2022-10-29 19:32:422022-10-29 19:33:40

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-29 19:33:40]
  • 评测
  • 测评结果:TL
  • 用时:13ms
  • 内存:6780kb
  • [2022-10-29 19:32:42]
  • 提交

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...

output:


result: