結果

問題 No.1974 2x2 Flipper
ユーザー simansiman
提出日時 2022-06-12 15:46:54
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 466 bytes
コンパイル時間 196 ms
コンパイル使用メモリ 11,920 KB
実行使用メモリ 30,060 KB
最終ジャッジ日時 2023-10-24 11:43:19
合計ジャッジ時間 11,312 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
16,076 KB
testcase_01 AC 146 ms
18,308 KB
testcase_02 AC 86 ms
16,076 KB
testcase_03 AC 485 ms
26,512 KB
testcase_04 AC 263 ms
20,416 KB
testcase_05 WA -
testcase_06 AC 368 ms
23,484 KB
testcase_07 AC 266 ms
21,792 KB
testcase_08 AC 115 ms
17,580 KB
testcase_09 AC 379 ms
23,112 KB
testcase_10 WA -
testcase_11 AC 314 ms
21,816 KB
testcase_12 AC 484 ms
25,684 KB
testcase_13 AC 325 ms
23,208 KB
testcase_14 AC 226 ms
19,668 KB
testcase_15 AC 557 ms
26,928 KB
testcase_16 WA -
testcase_17 AC 418 ms
25,324 KB
testcase_18 AC 118 ms
16,976 KB
testcase_19 AC 120 ms
17,772 KB
testcase_20 AC 260 ms
20,088 KB
testcase_21 AC 697 ms
30,060 KB
testcase_22 AC 700 ms
30,040 KB
testcase_23 AC 698 ms
30,040 KB
testcase_24 WA -
testcase_25 AC 80 ms
16,076 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

H, W = gets.split.map(&:to_i)
G = Array.new(H) { Array.new(W, 0) }

(H - 1).times do |y|
  (W - 1).times do |x|
    cnt = 0
    cnt += 1 if G[y][x] == 0
    cnt += 1 if G[y][x + 1] == 0
    cnt += 1 if G[y + 1][x] == 0
    cnt += 1 if G[y + 1][x + 1] == 0

    if cnt > 2
      G[y][x] ^= 1
      G[y][x + 1] ^= 1
      G[y + 1][x] ^= 1
      G[y + 1][x + 1] ^= 1
    end
  end
end

ans = G.map { |row| row.count(1) }.sum
puts ans
puts G.map { |row| row.join(' ') }
0