結果

問題 No.3081 HQ9+
ユーザー Shiro_SShiro_S
提出日時 2021-04-01 20:22:48
言語 Ruby
(3.3.0)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 193 bytes
コンパイル時間 389 ms
コンパイル使用メモリ 11,264 KB
実行使用メモリ 15,704 KB
最終ジャッジ日時 2023-08-22 23:19:07
合計ジャッジ時間 3,902 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
15,200 KB
testcase_01 AC 76 ms
15,240 KB
testcase_02 AC 77 ms
15,296 KB
testcase_03 AC 75 ms
14,984 KB
testcase_04 AC 76 ms
15,192 KB
testcase_05 AC 75 ms
15,096 KB
testcase_06 AC 75 ms
15,236 KB
testcase_07 AC 74 ms
15,168 KB
testcase_08 AC 74 ms
15,620 KB
testcase_09 AC 74 ms
15,336 KB
testcase_10 AC 76 ms
15,468 KB
testcase_11 AC 77 ms
15,236 KB
testcase_12 AC 77 ms
15,136 KB
testcase_13 AC 78 ms
15,468 KB
testcase_14 AC 75 ms
15,400 KB
testcase_15 AC 75 ms
15,476 KB
testcase_16 AC 77 ms
15,624 KB
testcase_17 AC 75 ms
15,196 KB
testcase_18 AC 77 ms
15,368 KB
testcase_19 AC 75 ms
15,180 KB
testcase_20 AC 75 ms
15,536 KB
testcase_21 AC 75 ms
15,704 KB
testcase_22 AC 76 ms
15,668 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:6: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Main.rb:11: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

n=gets.to_i
s=gets.chomp
q=s.count(?Q)
w=(q**0.5).to_i
if q==0 || q!=w**2 || n%w>0 ||s[/[H9]/]
 puts -1
 exit
end
t=s.scan(/.{1,#{n/w}}/).sort
if t[0]!=t[t.size-1]
 puts -1
else
 puts t[0]
end
0