結果

問題 No.3081 HQ9+
ユーザー Eki1009Eki1009
提出日時 2021-04-01 20:19:17
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 385 bytes
コンパイル時間 325 ms
コンパイル使用メモリ 86,860 KB
実行使用メモリ 75,376 KB
最終ジャッジ日時 2023-08-22 23:09:37
合計ジャッジ時間 3,317 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,144 KB
testcase_01 AC 72 ms
70,836 KB
testcase_02 AC 72 ms
71,232 KB
testcase_03 AC 72 ms
70,996 KB
testcase_04 AC 72 ms
71,140 KB
testcase_05 AC 72 ms
71,176 KB
testcase_06 AC 72 ms
71,172 KB
testcase_07 AC 74 ms
71,160 KB
testcase_08 AC 72 ms
70,992 KB
testcase_09 AC 73 ms
70,952 KB
testcase_10 AC 72 ms
71,316 KB
testcase_11 AC 72 ms
71,200 KB
testcase_12 AC 70 ms
70,988 KB
testcase_13 AC 72 ms
71,032 KB
testcase_14 AC 87 ms
75,348 KB
testcase_15 AC 71 ms
70,956 KB
testcase_16 AC 75 ms
75,376 KB
testcase_17 AC 71 ms
71,144 KB
testcase_18 AC 75 ms
70,832 KB
testcase_19 AC 72 ms
71,156 KB
testcase_20 AC 72 ms
71,228 KB
testcase_21 AC 72 ms
71,168 KB
testcase_22 AC 71 ms
71,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
S = input()
for s in S:
    if s == "9" or s == "H":
        print(-1)
        exit()
q = S.count("Q")
if q == 0:
    print(-1)
    exit()
for i in range(10**3):
    if i*i == q:
        break
else:
    print(-1)
    exit()
if n%i:
    print(-1)
    exit()
m = n//i
P = S[:m]
if P.count("Q") != i:
    print(-1)
    exit()
if S == P*i:
    print(P)
else:
    print(-1)
0