結果

問題 No.3081 HQ9+
ユーザー HaarHaar
提出日時 2021-04-01 21:14:07
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 508 bytes
コンパイル時間 73 ms
コンパイル使用メモリ 10,628 KB
実行使用メモリ 8,500 KB
最終ジャッジ日時 2023-08-23 05:09:11
合計ジャッジ時間 1,420 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
8,240 KB
testcase_01 AC 16 ms
8,140 KB
testcase_02 AC 16 ms
8,112 KB
testcase_03 AC 16 ms
8,056 KB
testcase_04 AC 15 ms
7,776 KB
testcase_05 AC 15 ms
7,904 KB
testcase_06 AC 16 ms
7,948 KB
testcase_07 AC 15 ms
7,800 KB
testcase_08 AC 15 ms
8,276 KB
testcase_09 AC 15 ms
8,208 KB
testcase_10 AC 16 ms
8,112 KB
testcase_11 AC 16 ms
7,944 KB
testcase_12 AC 16 ms
7,856 KB
testcase_13 AC 16 ms
7,888 KB
testcase_14 AC 15 ms
7,804 KB
testcase_15 AC 16 ms
7,908 KB
testcase_16 AC 15 ms
7,856 KB
testcase_17 AC 15 ms
7,856 KB
testcase_18 AC 16 ms
8,336 KB
testcase_19 AC 15 ms
7,796 KB
testcase_20 AC 16 ms
8,500 KB
testcase_21 AC 16 ms
8,320 KB
testcase_22 AC 16 ms
8,484 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
s = input()

def is_square(n):
    for i in range(1, 1000):
        if n == i * i:
            return i
    return -1

if 'H' not in s:
    q = s.count('Q')

    sq = is_square(q)

    if sq != -1:
        if n % sq == 0:
            b = n // sq
            t = s[0 : b]

            check = True

            for l in range(0, n, b):
                if t != s[l : l + b]:
                    check = False

            if check:
                print(t)
                exit(0)


print(-1)
0