結果

問題 No.3081 HQ9+
ユーザー maimai
提出日時 2021-04-01 22:32:55
言語 Ruby
(3.3.0)
結果
AC  
実行時間 88 ms / 2,000 ms
コード長 327 bytes
コンパイル時間 60 ms
コンパイル使用メモリ 11,260 KB
実行使用メモリ 20,420 KB
最終ジャッジ日時 2023-08-23 06:26:52
合計ジャッジ時間 3,081 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
15,152 KB
testcase_01 AC 82 ms
15,040 KB
testcase_02 AC 83 ms
15,248 KB
testcase_03 AC 80 ms
15,312 KB
testcase_04 AC 81 ms
15,076 KB
testcase_05 AC 82 ms
15,248 KB
testcase_06 AC 82 ms
15,216 KB
testcase_07 AC 85 ms
15,048 KB
testcase_08 AC 82 ms
15,132 KB
testcase_09 AC 84 ms
15,152 KB
testcase_10 AC 82 ms
15,088 KB
testcase_11 AC 82 ms
15,268 KB
testcase_12 AC 84 ms
15,160 KB
testcase_13 AC 81 ms
15,284 KB
testcase_14 AC 85 ms
15,176 KB
testcase_15 AC 83 ms
15,180 KB
testcase_16 AC 84 ms
15,180 KB
testcase_17 AC 82 ms
15,396 KB
testcase_18 AC 86 ms
19,676 KB
testcase_19 AC 83 ms
15,772 KB
testcase_20 AC 86 ms
20,420 KB
testcase_21 AC 87 ms
20,124 KB
testcase_22 AC 88 ms
20,332 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:2: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

def bye
  p -1
  exit
end

gets

li = gets.chomp
abort unless li=~/^[A-Za-z]+$/
if li=~/H/
  bye
else
  m = li.count('Q')
  bye if m == 0
  q = Math::sqrt(m).to_i
  bye if (q**2 != m)
  n = li.size
  bye if (n/q*q != n)
  k = n/q
  pat = li[0...k]
  0.step(n-1, k) do |i|
    bye if pat != li[i...(k+i)]
  end
  
  puts pat
end
0