結果

問題 No.1851 Regular Tiling
ユーザー titiatitia
提出日時 2022-02-25 21:38:51
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,199 bytes
コンパイル時間 303 ms
コンパイル使用メモリ 87,064 KB
実行使用メモリ 85,712 KB
最終ジャッジ日時 2023-09-16 16:20:41
合計ジャッジ時間 5,590 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,416 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 AC 90 ms
76,632 KB
testcase_13 AC 248 ms
82,072 KB
testcase_14 AC 297 ms
85,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

ANS=[]

for i in range(120):
    if i%3==0:
        A=[1,1,0]*40
        ANS.append(A)
    else:
        A=[2,2,1]*40
        ANS.append(A)
        

def check(X):
    for i in range(len(X)):
        for j in range(len(X[0])):
            x=X[i][j]
            count=0

            for z,w in [(i+1,j),(i-1,j),(i,j+1),(i,j-1)]:
                if 0<=z<len(X) and 0<=w<len(X[0]) and X[z][w]==x:
                    count+=1

            if count!=x:
                return False
    return True


T=int(input())
for tests in range(T):
    H,W=map(int,input().split())

    L=[]

    for i in range(H):
        L.append(ANS[i][:W])

    if check(L)==True:
        for l in L:
            print(*l)
        continue

    L=[]

    for i in range(H):
        L.append(ANS[i+2][:W])

    if check(L)==True:
        for l in L:
            print(*l)
        continue

    L=[]

    for i in range(H):
        L.append(ANS[i][2:W+2])

    if check(L)==True:
        for l in L:
            print(*l)
        continue

    L=[]

    for i in range(H):
        L.append(ANS[i+2][2:W+2])

    if check(L)==True:
        for l in L:
            print(*l)
        continue
0