結果

問題 No.1954 CHECKER×CHECKER(2)
ユーザー tomeruntomerun
提出日時 2022-05-20 23:50:29
言語 Crystal
(1.11.2)
結果
AC  
実行時間 4 ms / 1,000 ms
コード長 720 bytes
コンパイル時間 12,049 ms
コンパイル使用メモリ 292,700 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 14:45:01
合計ジャッジ時間 13,528 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 3 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 1 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 3 ms
4,348 KB
testcase_22 AC 4 ms
4,348 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 AC 3 ms
4,348 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 3 ms
4,348 KB
testcase_28 AC 3 ms
4,348 KB
testcase_29 AC 2 ms
4,348 KB
testcase_30 AC 3 ms
4,348 KB
testcase_31 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

h, w = read_line.split.map(&.to_i)
s = Array.new(h) do |i|
  read_line.chars.map_with_index { |ch, j| (ch == '#') ^ ((i + j) % 2 == 0) }
end
rs = Array.new(h, false)
cs = Array.new(w, false)
read_line.to_i.times do
  t, n = read_line.split.map(&.to_i)
  if t == 1
    rs[n - 1] = true
  else
    cs[n - 1] = true
  end
end
(h - 2).downto(0) do |i|
  if s[i][-1] != s[i + 1][-1] && rs[i]
    0.upto(i) do |r|
      w.times do |c|
        s[r][c] ^= true
      end
    end
  end
end
(w - 2).downto(0) do |i|
  if s[-1][i] != s[-1][i + 1] && cs[i]
    h.times do |r|
      0.upto(i) do |c|
        s[r][c] ^= true
      end
    end
  end
end
puts h.times.all? { |i| w.times.all? { |j| s[i][j] == s[0][0] } } ? "Yes" : "No"
0