結果

問題 No.1851 Regular Tiling
ユーザー MitarushiMitarushi
提出日時 2022-01-04 21:36:02
言語 Nim
(2.0.2)
結果
AC  
実行時間 91 ms / 2,000 ms
コード長 895 bytes
コンパイル時間 4,746 ms
コンパイル使用メモリ 68,880 KB
実行使用メモリ 4,780 KB
最終ジャッジ日時 2023-09-16 15:10:18
合計ジャッジ時間 6,976 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 27 ms
4,376 KB
testcase_02 AC 31 ms
4,376 KB
testcase_03 AC 30 ms
4,376 KB
testcase_04 AC 28 ms
4,420 KB
testcase_05 AC 29 ms
4,396 KB
testcase_06 AC 33 ms
4,376 KB
testcase_07 AC 28 ms
4,464 KB
testcase_08 AC 29 ms
4,408 KB
testcase_09 AC 33 ms
4,380 KB
testcase_10 AC 30 ms
4,376 KB
testcase_11 AC 3 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 54 ms
4,736 KB
testcase_14 AC 91 ms
4,780 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import strutils, sequtils

proc gen_one_two(x: int): seq[int] =
    result = @[]
    if x mod 3 == 2:
        result.add(2)
    for _ in 0..<x div 3:
        result.add(1)
        result.add(2)
    if x mod 3 == 1:
        result.add(1)

proc set_tile(map: var seq[seq[int]], x, y, h, w: int) =
    for i in 0..<h:
        for j in 0..<w:
            map[i + x][j + y] = h * w div 2

proc solve() =
    var h, w: int
    (h, w) = stdin.readLine.split.map parseInt

    let
        w_tile = gen_one_two(w)
        h_tile = gen_one_two(h)

    var map = newSeqWith(h, newSeq[int](w))

    var acc_h = 0
    for i in h_tile:
        var acc_w = 0
        for j in w_tile:
            set_tile(map, acc_h, acc_w, i, j)
            acc_w += j
        acc_h += i

    for i in map:
        echo i.map(proc(x: int): string = $x).join(" ")


let t = stdin.readLine.parseInt
for _ in 0..<t:
    solve()

0