結果

問題 No.3081 Make Palindromic Multiple
ユーザー gew1fw
提出日時 2025-06-12 12:58:13
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,109 bytes
コンパイル時間 209 ms
コンパイル使用メモリ 82,036 KB
実行使用メモリ 67,656 KB
最終ジャッジ日時 2025-06-12 13:05:11
合計ジャッジ時間 11,019 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 3
other RE * 54
権限があれば一括ダウンロードができます

ソースコード

diff #

def generate_99_bottles():
    s = []
    for i in range(99, 0, -1):
        line1 = f"{i} bottle{'s' if i != 1 else ''} of beer on the wall, {i} bottle{'s' if i != 1 else ''} of beer."
        line2 = f"Take one down and pass it around, {i-1} bottle{'s' if (i-1) != 1 else ''} of beer on the wall."
        s.append(line1)
        s.append(line2)
        s.append("")
    s.append("No more bottles of beer on the wall, no more bottles of beer.")
    s.append("Go to the store and buy some more, 99 bottles of beer on the wall.")
    return '\n'.join(s)

n = int(input())
s = input().strip()

if s == "Hello, World!":
    print("H")
else:
    song = generate_99_bottles()
    if s == song:
        print("9")
    else:
        q_count = s.count('Q')
        if q_count == 1:
            valid = True
            for c in s:
                if c == 'Q':
                    continue
                if c in {'H', 'Q', '9'}:
                    valid = False
                    break
            if valid:
                print(s)
            else:
                print(-1)
        else:
            print(-1)
0