QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#363765 | #7705. Make Your Own Morse Code Palindrome | lucasrpatten# | RE | 11ms | 9916kb | Python3 | 1.4kb | 2024-03-24 03:04:02 | 2024-03-24 03:04:03 |
Judging History
answer
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': '----.'
}
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={}
def dp(i: int):
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
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: 11ms
memory: 9916kb
input:
FOOT
output:
1 L
result:
ok correct
Test #2:
score: 0
Accepted
time: 11ms
memory: 9804kb
input:
FOOTS
output:
3 M0L
result:
ok correct
Test #3:
score: 0
Accepted
time: 11ms
memory: 9784kb
input:
FOOTS
output:
3 M0L
result:
ok correct
Test #4:
score: 0
Accepted
time: 8ms
memory: 9812kb
input:
FOOTSTOOL
output:
0
result:
ok correct
Test #5:
score: 0
Accepted
time: 2ms
memory: 9844kb
input:
OOTNX
output:
2 J0
result:
ok correct
Test #6:
score: -100
Dangerous Syscalls
input:
3 FRENCH HENS