結果

問題 No.8081 HQ9+
ユーザー nok0nok0
提出日時 2021-04-01 20:49:53
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 38 ms / 2,000 ms
コード長 336 bytes
コンパイル時間 575 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-12-21 04:27:32
合計ジャッジ時間 2,325 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

n = int(input())
s = input()
cnt = 0
for c in s:
    if c == "H":
        print(-1)
        exit()
    if c == "Q":
        cnt += 1

if cnt == 0:
    print(-1)
    exit()

m = int(math.sqrt(cnt))


if m ** 2 == cnt:
    u = s[0 : n // m]
    if u * m == s:
        print(u)
    else:
        print(-1)
else:
    print(-1)
0