結果

問題 No.3081 HQ9+
ユーザー 大玖すとら大玖すとら
提出日時 2021-04-01 21:20:03
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 369 bytes
コンパイル時間 274 ms
コンパイル使用メモリ 87,304 KB
実行使用メモリ 75,744 KB
最終ジャッジ日時 2023-08-23 05:26:31
合計ジャッジ時間 2,890 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,328 KB
testcase_01 AC 67 ms
71,252 KB
testcase_02 AC 69 ms
71,128 KB
testcase_03 AC 70 ms
71,280 KB
testcase_04 AC 68 ms
71,252 KB
testcase_05 AC 66 ms
71,240 KB
testcase_06 AC 68 ms
71,268 KB
testcase_07 AC 69 ms
71,068 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 67 ms
70,888 KB
testcase_12 AC 68 ms
71,276 KB
testcase_13 AC 67 ms
71,064 KB
testcase_14 AC 71 ms
75,488 KB
testcase_15 AC 68 ms
71,168 KB
testcase_16 AC 72 ms
75,744 KB
testcase_17 AC 69 ms
71,128 KB
testcase_18 AC 68 ms
71,156 KB
testcase_19 AC 68 ms
70,892 KB
testcase_20 AC 69 ms
71,184 KB
testcase_21 AC 67 ms
71,248 KB
testcase_22 AC 68 ms
71,172 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
S = input()
if "H" in S:
  print(-1)
  exit(0)
Q = S.count("Q")
if Q == 1:
  print(S)
  exit(0)
qsqrt = 0
for x in range(1, N):
  if x ** 2 == Q:
    qsqrt = x
    break
else:
  print(-1)
  exit(0)
substring = ""
for x in range(1, N):
  if x * Q == N:
    substring = S[: x]
    break
if substring == "":
  print(-1)
  exit(0)
print(substring * qsqrt)
0