結果
| 問題 | No.8081 HQ9+ |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-04-01 20:16:35 |
| 言語 | Crystal (1.19.1) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 440 bytes |
| 記録 | |
| コンパイル時間 | 12,308 ms |
| コンパイル使用メモリ | 342,692 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-05-27 03:23:03 |
| 合計ジャッジ時間 | 13,497 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 21 |
ソースコード
lib C
fun strtoll(s : UInt8*, p : UInt8**, b : Int32) : Int64
end
class String
def to_i64
C.strtoll(self, nil, 10)
end
end
n = read_line.to_i
s = read_line
if s.includes?('H') || s.includes?('9')
puts -1; exit
end
cnt = s.count('Q')
sq = Math.sqrt(cnt).to_i
if cnt == 0 || sq ** 2 != cnt || n % sq != 0
puts -1; exit
end
len = n // sq
t = s.chars.each_slice(len).to_a
if t.uniq.size != 1
puts -1; exit
end
puts t[0].join