結果

問題 No.1851 Regular Tiling
ユーザー 👑 rin204rin204
提出日時 2022-02-25 22:13:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 171 ms / 2,000 ms
コード長 947 bytes
コンパイル時間 407 ms
コンパイル使用メモリ 87,072 KB
実行使用メモリ 79,356 KB
最終ジャッジ日時 2023-09-16 17:12:35
合計ジャッジ時間 4,307 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,196 KB
testcase_01 AC 136 ms
77,628 KB
testcase_02 AC 126 ms
77,668 KB
testcase_03 AC 130 ms
77,540 KB
testcase_04 AC 125 ms
77,540 KB
testcase_05 AC 119 ms
77,516 KB
testcase_06 AC 123 ms
77,560 KB
testcase_07 AC 120 ms
77,300 KB
testcase_08 AC 129 ms
78,196 KB
testcase_09 AC 125 ms
77,288 KB
testcase_10 AC 124 ms
77,400 KB
testcase_11 AC 80 ms
76,396 KB
testcase_12 AC 80 ms
76,296 KB
testcase_13 AC 130 ms
77,980 KB
testcase_14 AC 171 ms
79,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

"""
3以上は使えない

0 

11

22
22

22222
2...2
2...2
22222
みたいに2で囲う

のどれか

1 * n := 0 と 1 でできる
2 * n := 1 と 2 でできる
3 * n := 2 で周りを囲って間が 1 * (n - 2)
4 * n := 1 * n と 3 * n に分割すればいい

[1, 2, 3] の中で 2 * n と 3 * n だけ隣り合わせられない

011011011011
122122122122
122122122122

の繰り返しでok

"""
def solve():
    w, h = map(int, input().split())
    if h % 3 == 2:
        s = 1
    else:
        s = 0
    
    A = []
    while len(A) < h:
        if s == 1:
            A += [1, 1]
        else:
            A += [0]
        s ^= 1
    
    if w % 3 == 2:
        s = 1
    else:
        s = 0
    
    B = [a + 1 for a in A]
    while w:
        if s == 1:
            print(*B)
            print(*B)
            w -= 2
        else:
            print(*A)
            w -= 1
        s ^= 1
    
for _ in range(int(input())):
    solve()
0