結果

問題 No.1974 2x2 Flipper
ユーザー 👑 KazunKazun
提出日時 2022-06-10 22:19:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 141 ms / 2,000 ms
コード長 1,061 bytes
コンパイル時間 664 ms
コンパイル使用メモリ 81,560 KB
実行使用メモリ 85,656 KB
最終ジャッジ日時 2023-10-21 05:58:16
合計ジャッジ時間 5,464 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,356 KB
testcase_01 AC 64 ms
76,360 KB
testcase_02 AC 45 ms
64,064 KB
testcase_03 AC 110 ms
81,740 KB
testcase_04 AC 77 ms
78,200 KB
testcase_05 AC 73 ms
77,048 KB
testcase_06 AC 97 ms
79,828 KB
testcase_07 AC 84 ms
78,240 KB
testcase_08 AC 63 ms
75,880 KB
testcase_09 AC 94 ms
80,088 KB
testcase_10 AC 63 ms
75,768 KB
testcase_11 AC 87 ms
78,984 KB
testcase_12 AC 104 ms
81,616 KB
testcase_13 AC 87 ms
79,272 KB
testcase_14 AC 73 ms
77,520 KB
testcase_15 AC 118 ms
82,648 KB
testcase_16 AC 61 ms
75,916 KB
testcase_17 AC 101 ms
80,504 KB
testcase_18 AC 49 ms
73,356 KB
testcase_19 AC 61 ms
75,948 KB
testcase_20 AC 79 ms
78,108 KB
testcase_21 AC 139 ms
85,380 KB
testcase_22 AC 141 ms
85,344 KB
testcase_23 AC 139 ms
85,256 KB
testcase_24 AC 141 ms
85,656 KB
testcase_25 AC 37 ms
53,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(H,W):
    A=[[0]*W for _ in range(H)]

    if H==1 or W==1:
        pass
    elif H%2==0:
        if W%2==0:
            for i in range(H):
                a=A[i]
                for j in range(W):
                    a[j]=1
        else:
            for i in range(H):
                a=A[i]
                for j in range(W-1):
                    a[j]=1
    else:
        if W%2==0:
            for i in range(H-1):
                a=A[i]
                for j in range(W):
                    a[j]=1
        else:
            if H>W:
                flag=1
                H,W=W,H
                A=[list(a[::-1]) for a in zip(*A)]
            else:
                flag=0

            for i in range(H):
                for j in range(W):
                    if not((i==j) or ((i==H-1) and (j>=H))):
                        A[i][j]=1

            if flag:
                A=[list(a[::-1]) for a in zip(*A)]

    X=0
    for a in A:
        X+=sum(a)
    return X,A

H,W=map(int,input().split())
X,A=solve(H,W)

print(X)
for a in A:
    print(*a)
0