結果
| 問題 | No.8081 HQ9+ | 
| コンテスト | |
| ユーザー |  NOSS | 
| 提出日時 | 2021-04-01 21:45:10 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 488 bytes | 
| コンパイル時間 | 114 ms | 
| コンパイル使用メモリ | 12,544 KB | 
| 実行使用メモリ | 11,008 KB | 
| 最終ジャッジ日時 | 2024-12-21 06:04:06 | 
| 合計ジャッジ時間 | 1,954 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 18 WA * 3 | 
ソースコード
n = int(input())
s = input()
x = 0
ng = False
for c in s:
    if c == 'Q':
        x += 1
    if c == 'H' or c == '9':
        ng = True
if ng:
    print(-1)
elif x>0:
    ok = True
    k = 1
    while int(pow(k,k)) < x:
        k += 1
    if int(pow(k,k)) != x or n%k != 0:
        ok = False
    m = n//k
    for i in range(k):
        if s[i*m:(i+1)*m] != s[0:m]:
            ok = False
            break
    if ok:
        print(s[0:m])
    else:
        print(-1)
else:
    print(-1)
            
            
            
        