QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#363779 | #7705. Make Your Own Morse Code Palindrome | lucasrpatten# | AC ✓ | 13ms | 9464kb | Python3 | 1.4kb | 2024-03-24 03:15:19 | 2024-03-24 03:15:19 |
Judging History
answer
import sys
sys.setrecursionlimit(100000)
LtoM={
'A': '.-',
'B': '-...',
"C": '-.-.',
"D": "-..",
"E": '.',
'F': '..-.',
'G': '--.',
'H': '....',
'I': '..',
'J': '.---',
'K': '-.-',
'L': '.-..',
'M': '--',
'N': '-.',
'O': '---',
'P': '.--.',
'Q': '--.-',
'R': '.-.',
'S': '...',
'T': '-',
'U': '..-',
'V': '...-',
'W': '.--',
'X': '-..-',
'Y': '-.--',
'Z': '--..',
'0': '-----',
'1': '.----',
'2': '..---',
'3': '...--',
'4': '....-',
'5': '.....',
'6': '-....',
'7': '--...',
'8': '---..',
'9': '----.'
}
def dp(i):
if i==len(dps):
return ""
if i in d:
return d[i]
val="A"*100
for L in LtoM:
dots = LtoM[L]
if dots==dps[i:i+len(dots)]:
current = L+dp(i+len(dots))
if len(current)<len(val):
val=current
d[i]=val
return val
MtoL={LtoM[i]:i for i in LtoM}
S=input()
s=''.join(LtoM[i] for i in S if i in LtoM)
ansS="A"*100
for i in range(len(s)):
w=True
for j in range(i,len(s)):
if s[j]!=s[i+len(s)-j-1]:
w=False
break
if w:
dps=s[:i][::-1]
d={}
current=dp(0)
if len(current)<len(ansS):
ansS=current
print(len(ansS),ansS)
詳細信息
Test #1:
score: 100
Accepted
time: 6ms
memory: 9332kb
input:
FOOT
output:
1 L
result:
ok correct
Test #2:
score: 0
Accepted
time: 0ms
memory: 9284kb
input:
FOOTS
output:
3 M0L
result:
ok correct
Test #3:
score: 0
Accepted
time: 9ms
memory: 9340kb
input:
FOOTS
output:
3 M0L
result:
ok correct
Test #4:
score: 0
Accepted
time: 6ms
memory: 9272kb
input:
FOOTSTOOL
output:
0
result:
ok correct
Test #5:
score: 0
Accepted
time: 7ms
memory: 9340kb
input:
OOTNX
output:
2 J0
result:
ok correct
Test #6:
score: 0
Accepted
time: 10ms
memory: 9372kb
input:
3 FRENCH HENS
output:
6 HFCLD7
result:
ok correct
Test #7:
score: 0
Accepted
time: 5ms
memory: 9328kb
input:
TWAS THE NIGHT BEFORE XMAS
output:
13 KGLKGB357BFFQ
result:
ok correct
Test #8:
score: 0
Accepted
time: 8ms
memory: 9376kb
input:
1A2B3C4D5E6F7G8H9I10J
output:
18 M9V84G7Q5L5P4J51F9
result:
ok correct
Test #9:
score: 0
Accepted
time: 8ms
memory: 9424kb
input:
A PARTRIDGE IN A PEAR TREE
output:
8 QF3FFCXC
result:
ok correct
Test #10:
score: 0
Accepted
time: 10ms
memory: 9368kb
input:
TEN LORDS ALEAPING
output:
9 BG6C5C8DK
result:
ok correct
Test #11:
score: 0
Accepted
time: 6ms
memory: 9348kb
input:
XABCDQRST1234567890123456789
output:
7 6CZCBGX
result:
ok correct
Test #12:
score: 0
Accepted
time: 11ms
memory: 9360kb
input:
ASDFGHJKLQWERTYUIOPMNBVCXZ987
output:
23 GAQ88CZ4JP8DQCPYFY73LFF
result:
ok correct
Test #13:
score: 0
Accepted
time: 10ms
memory: 9284kb
input:
THE QUICK BROWN FOX JUMPS OVER
output:
17 24YXQ2CUQGBPCDXP4
result:
ok correct
Test #14:
score: 0
Accepted
time: 8ms
memory: 9380kb
input:
1234567891 IS A PRIME NUMBER 0
output:
18 A59F7XC59123456789
result:
ok correct
Test #15:
score: 0
Accepted
time: 9ms
memory: 9424kb
input:
INTRANSIGENCE
output:
0
result:
ok correct
Test #16:
score: 0
Accepted
time: 0ms
memory: 9344kb
input:
ANTICKING ANTICKING WRECKING A
output:
5 CRCXP
result:
ok correct
Test #17:
score: 0
Accepted
time: 13ms
memory: 9292kb
input:
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
output:
1 E
result:
ok correct
Test #18:
score: 0
Accepted
time: 8ms
memory: 9464kb
input:
ISO9001 "IEEEEEEEEEEEEEEEEEEEE
output:
6 900J9H
result:
ok correct