結果

問題 No.8081 HQ9+
ユーザー Kude
提出日時 2021-04-01 21:45:21
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 301 bytes
コンパイル時間 227 ms
コンパイル使用メモリ 81,940 KB
実行使用メモリ 57,620 KB
最終ジャッジ日時 2024-12-21 06:04:17
合計ジャッジ時間 1,748 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 15 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
s = input()
if set(s) | {'+', 'Q'} != {'+', 'Q'}:
    print(-1)
    exit()
#[x, r)
cnt = 0
for r in range(1, n + 1):
    cnt += s[r-1] == 'Q'
    if cnt * r == n:
        code = s[:r]
        break
else:
    print(-1)
    exit()
if code * cnt == s:
    print(code)
else:
    print(-1)
0