結果
| 問題 |
No.1974 2x2 Flipper
|
| コンテスト | |
| ユーザー |
siman
|
| 提出日時 | 2022-06-12 15:45:01 |
| 言語 | Ruby (3.4.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 467 bytes |
| コンパイル時間 | 55 ms |
| コンパイル使用メモリ | 7,296 KB |
| 実行使用メモリ | 25,984 KB |
| 最終ジャッジ日時 | 2024-09-23 04:00:43 |
| 合計ジャッジ時間 | 16,869 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 1 WA * 24 |
コンパイルメッセージ
Syntax OK
ソースコード
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(' ') }
siman