結果

問題 No.8081 HQ9+
ユーザー nasubi24
提出日時 2021-04-01 21:52:56
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 481 bytes
コンパイル時間 186 ms
コンパイル使用メモリ 82,172 KB
実行使用メモリ 58,496 KB
最終ジャッジ日時 2024-12-21 06:12:12
合計ジャッジ時間 1,932 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 20 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
s=input()
if s.count("Q")==1:
    if s.count("H")==0:
        print(s)
    else:
        print(-1)
elif s.count("Q")!=0:
    for i in range(2,n):
        if n%i==0:
            for j in range(n//i-1):
                if s[i*j:i*(j+1)]!=s[i*(j+1):i*(j+2)]:
                    break
            else:
                t=s[:i]
                if t.count("Q")==n//i:
                    print(t)
                    break
    else:
        print(-1)
else:
    print(-1)
0