結果

問題 No.3081 HQ9+
ユーザー nok0nok0
提出日時 2021-04-01 20:48:58
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 296 bytes
コンパイル時間 110 ms
コンパイル使用メモリ 10,732 KB
実行使用メモリ 8,540 KB
最終ジャッジ日時 2023-08-23 04:31:14
合計ジャッジ時間 2,318 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,952 KB
testcase_01 AC 17 ms
7,908 KB
testcase_02 AC 16 ms
7,944 KB
testcase_03 AC 16 ms
7,884 KB
testcase_04 RE -
testcase_05 AC 17 ms
8,196 KB
testcase_06 AC 17 ms
8,240 KB
testcase_07 AC 17 ms
8,248 KB
testcase_08 AC 16 ms
7,904 KB
testcase_09 AC 17 ms
7,904 KB
testcase_10 AC 17 ms
8,080 KB
testcase_11 AC 16 ms
8,376 KB
testcase_12 AC 17 ms
8,360 KB
testcase_13 AC 17 ms
8,248 KB
testcase_14 AC 16 ms
8,052 KB
testcase_15 AC 17 ms
7,940 KB
testcase_16 AC 16 ms
7,964 KB
testcase_17 AC 17 ms
8,188 KB
testcase_18 AC 16 ms
8,540 KB
testcase_19 AC 16 ms
8,352 KB
testcase_20 AC 17 ms
8,492 KB
testcase_21 AC 16 ms
8,484 KB
testcase_22 AC 16 ms
8,492 KB
権限があれば一括ダウンロードができます

ソースコード

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

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