QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#363765#7705. Make Your Own Morse Code Palindromelucasrpatten#RE 11ms9916kbPython31.4kb2024-03-24 03:04:022024-03-24 03:04:03

Judging History

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

  • [2024-03-24 03:04:03]
  • 评测
  • 测评结果:RE
  • 用时:11ms
  • 内存:9916kb
  • [2024-03-24 03:04:02]
  • 提交

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

output:


result: