結果
| 問題 | 
                            No.8081 HQ9+
                             | 
                    
| コンテスト | |
| ユーザー | 
                            👑  | 
                    
| 提出日時 | 2022-04-17 22:37:48 | 
| 言語 | Lua  (LuaJit 2.1.1734355927)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 332 bytes | 
| コンパイル時間 | 285 ms | 
| コンパイル使用メモリ | 5,248 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-12-26 11:31:30 | 
| 合計ジャッジ時間 | 1,022 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 WA * 1 | 
| other | AC * 17 WA * 4 | 
ソースコード
local n = io.read("*n", "*l")
local s = io.read()
y = 0
for i = 1, n do
  if s:sub(i, i) == "H" then
    print(-1) os.exit()
  end
  if s:sub(i, i) == "Q" then
    y = y + 1
  end
end
z = math.sqrt(y)
if z * z == y then
  print(string.rep(s, z))
elseif (z + 1) * (z + 1) == y then
  print(string.rep(s, z + 1))
else
  print(-1)
end