結果

問題 No.3081 HQ9+
ユーザー cielciel
提出日時 2021-04-15 10:33:44
言語 Ruby
(3.3.0)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 326 bytes
コンパイル時間 44 ms
コンパイル使用メモリ 11,372 KB
実行使用メモリ 15,584 KB
最終ジャッジ日時 2023-09-14 02:01:16
合計ジャッジ時間 3,110 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,156 KB
testcase_01 AC 84 ms
15,084 KB
testcase_02 AC 84 ms
15,044 KB
testcase_03 AC 84 ms
15,128 KB
testcase_04 AC 83 ms
15,156 KB
testcase_05 AC 84 ms
15,068 KB
testcase_06 AC 82 ms
15,108 KB
testcase_07 AC 83 ms
15,048 KB
testcase_08 AC 82 ms
15,220 KB
testcase_09 AC 83 ms
15,084 KB
testcase_10 AC 82 ms
15,132 KB
testcase_11 AC 84 ms
15,308 KB
testcase_12 AC 85 ms
15,172 KB
testcase_13 AC 84 ms
15,212 KB
testcase_14 AC 84 ms
15,148 KB
testcase_15 AC 82 ms
15,208 KB
testcase_16 AC 81 ms
15,108 KB
testcase_17 AC 82 ms
15,192 KB
testcase_18 AC 82 ms
15,456 KB
testcase_19 AC 82 ms
15,116 KB
testcase_20 AC 84 ms
15,288 KB
testcase_21 AC 83 ms
15,484 KB
testcase_22 AC 82 ms
15,584 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:16: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Main.rb:20: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

class Integer
	def isqrt
		return 0 if self<=0
		return 1 if self<4 # 1
		x,y=0,self
		while x!=y&&x+1!=y
			x,y=y,(self/y+y)/2
		end
		x
	end
end
n=gets.to_i
s=gets.chomp
c=s.count 'Q'
if s.include?('H')||c<1||c.isqrt**2!=c
	p -1;exit
end
a=s.chars.each_slice(n/c.isqrt).to_a
if a.any?{|e|e!=a[0]}
	p -1;exit
end
puts a[0]*''
0