結果

問題 No.1851 Regular Tiling
ユーザー rlangevinrlangevin
提出日時 2023-06-10 00:17:29
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,559 bytes
コンパイル時間 409 ms
コンパイル使用メモリ 86,764 KB
実行使用メモリ 83,596 KB
最終ジャッジ日時 2023-08-30 15:19:05
合計ジャッジ時間 7,242 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,332 KB
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 WA -
testcase_12 AC 82 ms
76,300 KB
testcase_13 RE -
testcase_14 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline


def rot90(A):
    return list(zip(*(A[::-1])))


T = int(input())
for _ in range(T):
    H, W = map(int, input().split())
    flag = 0
    if H > W:
        flag = 1
        H, W = W, H
    if H == 1:
        if W % 3 == 1:
            L = [0, 1, 1] * 50
        else:
            L = [1, 1, 0] * 50
        ans = [L[:W]]
        if flag:
            ans = rot90(ans)
        for a in ans:
            print(*a)
    elif H == 2:
        if W % 3 == 1:
            L = [1, 2, 2] * 50
        else:
            L = [2, 2, 1] * 50
        ans = [L[:W], L[:W]]
        if flag:
            ans = rot90(ans)
        for a in ans:
            print(*a)
    else:
        L = [[0] * W for i in range(H)]
        cnt = 0
        length = 0
        if H % 2 == 0:
            if W % 2 == 0:
                length = H + W - 1
            else:
                length = W
        else:
            if W % 2 == 0:
                length = H
            else:
                length = 0

        if length % 3 == 1:
            temp = [0, 1, 1] * 50
        else:
            temp = [1, 1, 0] * 50

        for i in range(H):
            for j in range(W-1, -1, -1):
                if i % 2 == 1 and j % 2 == 1:
                    L[i][j] = 0
                else:
                    L[i][j] = 2
                if (j == W - 1 and W % 2 == 0) or (i == H - 1 and H % 2 == 0):
                    L[i][j] = temp[cnt]
                    cnt += 1
        if flag:
            L = rot90(L)
        for a in L:
            print(*a)
0