結果
| 問題 |
No.3081 Make Palindromic Multiple
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 19:03:28 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,150 bytes |
| コンパイル時間 | 167 ms |
| コンパイル使用メモリ | 82,452 KB |
| 実行使用メモリ | 54,508 KB |
| 最終ジャッジ日時 | 2025-06-12 19:03:57 |
| 合計ジャッジ時間 | 10,717 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | WA * 54 |
ソースコード
import math
def generate_lyrics():
verses = []
for v in range(99, 0, -1):
verses.append(f"{v} bottles of beer on the wall, {v} bottles of beer.")
verses.append(f"Take one down and pass it around, {v-1} bottles of beer on the wall.")
verses.append('')
verses.append("No more bottles of beer on the wall, no more bottles of beer.")
verses.append("Go to the store and buy some more, 99 bottles of beer on the wall.")
return '\n'.join(verses[:-1])
def check_case1(S):
n = len(S)
m = int(math.sqrt(n))
if m * m != n:
return None
P = S[:m]
for i in range(m):
if S[i*m : (i+1)*m] != P:
return None
for c in P:
if c not in {'H', 'Q'}:
return None
return P
def main():
import sys
input = sys.stdin.read().split()
N = int(input[0])
S = input[1] if len(input) > 1 else ''
result_case1 = check_case1(S)
if result_case1 is not None:
print(result_case1)
return
lyrics = generate_lyrics()
if S == lyrics:
print("9")
return
print(-1)
if __name__ == "__main__":
main()
gew1fw