結果

問題 No.38 赤青白ブロック
ユーザー letrangerjpletrangerjp
提出日時 2017-06-14 09:37:25
言語 Ruby
(3.3.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 790 bytes
コンパイル時間 490 ms
コンパイル使用メモリ 11,552 KB
実行使用メモリ 15,688 KB
最終ジャッジ日時 2023-08-25 01:21:52
合計ジャッジ時間 4,712 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
15,060 KB
testcase_01 AC 261 ms
15,496 KB
testcase_02 AC 88 ms
15,296 KB
testcase_03 AC 82 ms
15,128 KB
testcase_04 AC 77 ms
15,260 KB
testcase_05 AC 78 ms
15,148 KB
testcase_06 AC 108 ms
15,448 KB
testcase_07 AC 85 ms
15,372 KB
testcase_08 AC 77 ms
15,152 KB
testcase_09 AC 122 ms
15,452 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 80 ms
15,116 KB
testcase_16 AC 119 ms
15,192 KB
testcase_17 AC 78 ms
15,304 KB
testcase_18 AC 87 ms
15,444 KB
testcase_19 AC 84 ms
15,308 KB
testcase_20 AC 80 ms
15,260 KB
testcase_21 AC 80 ms
15,300 KB
testcase_22 AC 519 ms
15,688 KB
testcase_23 AC 77 ms
15,300 KB
testcase_24 AC 93 ms
15,304 KB
testcase_25 AC 79 ms
15,160 KB
testcase_26 AC 80 ms
15,312 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

Kr, Kb = gets.split.take(2).map(&:to_i)
S = gets.chomp

def ng_at(s, i)
  r = []
  range = 0...s.size
  !case s[i]
  when ?R
    r << i - Kr if range.cover?(i - Kr) && s[i - Kr] == ?R
    r << i + Kr if range.cover?(i + Kr) && s[i + Kr] == ?R
  when ?B
    r << i - Kb if range.cover?(i - Kb) && s[i - Kb] == ?B
    r << i + Kb if range.cover?(i + Kb) && s[i + Kb] == ?B
  else
  end
  r
end

def valid?(s)
  !s.size.times.any?{|i|
    !ng_at(s, i).empty?
  }
end

def count_ng(s)
  count = 0
  s.size.times{|i|
    count += ng_at(s, i).size
  }
  count
end

q = {S=>1}
while !q.empty?
  qq = {}
  q.keys.each{|s|
    s.size.times{|i|
      next if s[i] == ?W
      t = s[0...i] + s[i+1..-1]
      if valid?(t)
        p t.size
        exit
      end
      qq[t] = 1
    }
  }
  q = qq
end
0