結果

問題 No.1851 Regular Tiling
ユーザー simansiman
提出日時 2022-03-11 04:09:35
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 816 bytes
コンパイル時間 56 ms
コンパイル使用メモリ 11,240 KB
実行使用メモリ 16,176 KB
最終ジャッジ日時 2023-10-13 06:51:14
合計ジャッジ時間 8,141 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
15,288 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 619 ms
15,988 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

B = [
  [0, 1, 1],
  [1, 2, 2],
  [1, 2, 2],
]

T = gets.to_i

def build_grid(h, w)
  grid = []

  h.times do |y|
    row = []
    w.times do |x|
      cy = if h - y >= 3
             y % 3
           else
             case h % 3
             when 0
               y % 3
             when 1
               y % 3
             when 2
               y % 3 + 1
             end
           end

      cx = if w - x >= 3
             x % 3
           else
             case w % 3
             when 0
               x % 3
             when 1
               x % 3
             when 2
               x % 3 + 1
             end
           end

      row << B[cy][cx]
    end

    grid << row
  end

  grid
end

T.times do
  h, w = gets.split.map(&:to_i)

  grid = build_grid(h, w)

  puts grid.map { |row| row.join(' ') }
end
0