結果

問題 No.3081 HQ9+
ユーザー chineristACchineristAC
提出日時 2021-04-01 20:59:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 77 ms / 2,000 ms
コード長 479 bytes
コンパイル時間 265 ms
コンパイル使用メモリ 87,016 KB
実行使用メモリ 76,396 KB
最終ジャッジ日時 2023-08-23 04:53:04
合計ジャッジ時間 3,023 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
76,064 KB
testcase_01 AC 74 ms
76,112 KB
testcase_02 AC 74 ms
76,272 KB
testcase_03 AC 72 ms
76,044 KB
testcase_04 AC 77 ms
76,124 KB
testcase_05 AC 73 ms
76,396 KB
testcase_06 AC 76 ms
76,084 KB
testcase_07 AC 72 ms
76,064 KB
testcase_08 AC 72 ms
76,248 KB
testcase_09 AC 74 ms
76,044 KB
testcase_10 AC 73 ms
76,204 KB
testcase_11 AC 71 ms
76,228 KB
testcase_12 AC 72 ms
76,316 KB
testcase_13 AC 73 ms
76,036 KB
testcase_14 AC 73 ms
76,044 KB
testcase_15 AC 73 ms
76,120 KB
testcase_16 AC 73 ms
76,228 KB
testcase_17 AC 72 ms
76,152 KB
testcase_18 AC 71 ms
76,244 KB
testcase_19 AC 72 ms
76,088 KB
testcase_20 AC 73 ms
76,092 KB
testcase_21 AC 73 ms
76,092 KB
testcase_22 AC 72 ms
76,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

sq = {i**2:i for i in range(10**4)}

N = int(input())
S = input()
k = S.count("Q")
if "H" in S:
    print(-1)
    exit()
if not k:
    print(-1)
else:
    if not k in sq:
        print(-1)
    else:
        Q_cnt = sq[k]
        if N%Q_cnt:
            print(-1)
        else:
            L = N//Q_cnt
            T = [S[i:i+L] for i in range(0,N,L)]
            if all(T[0]==T[i] for i in range(len(T))):
                print(T[0])
            else:
                print(-1)
0