QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#363768 | #7705. Make Your Own Morse Code Palindrome | lucasrpatten# | RE | 10ms | 9376kb | Python3 | 1.4kb | 2024-03-24 03:06:24 | 2024-03-24 03:06:25 |
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)
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)
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 6ms
memory: 9300kb
input:
FOOT
output:
1 L
result:
ok correct
Test #2:
score: 0
Accepted
time: 10ms
memory: 9376kb
input:
FOOTS
output:
3 M0L
result:
ok correct
Test #3:
score: 0
Accepted
time: 4ms
memory: 9324kb
input:
FOOTS
output:
3 M0L
result:
ok correct
Test #4:
score: 0
Accepted
time: 2ms
memory: 9324kb
input:
FOOTSTOOL
output:
0
result:
ok correct
Test #5:
score: 0
Accepted
time: 7ms
memory: 9272kb
input:
OOTNX
output:
2 J0
result:
ok correct
Test #6:
score: -100
Dangerous Syscalls
input:
3 FRENCH HENS