結果

問題 No.1974 2x2 Flipper
ユーザー ああいいああいい
提出日時 2022-06-12 07:34:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 150 ms / 2,000 ms
コード長 863 bytes
コンパイル時間 178 ms
コンパイル使用メモリ 81,720 KB
実行使用メモリ 85,516 KB
最終ジャッジ日時 2023-10-24 00:19:55
合計ジャッジ時間 5,273 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,500 KB
testcase_01 AC 73 ms
76,524 KB
testcase_02 AC 49 ms
64,352 KB
testcase_03 AC 116 ms
82,068 KB
testcase_04 AC 84 ms
78,412 KB
testcase_05 AC 72 ms
77,352 KB
testcase_06 AC 98 ms
79,872 KB
testcase_07 AC 86 ms
78,544 KB
testcase_08 AC 62 ms
76,252 KB
testcase_09 AC 99 ms
80,340 KB
testcase_10 AC 59 ms
73,972 KB
testcase_11 AC 90 ms
79,000 KB
testcase_12 AC 113 ms
82,040 KB
testcase_13 AC 93 ms
79,336 KB
testcase_14 AC 78 ms
77,712 KB
testcase_15 AC 123 ms
83,168 KB
testcase_16 AC 63 ms
76,148 KB
testcase_17 AC 108 ms
80,868 KB
testcase_18 AC 55 ms
73,332 KB
testcase_19 AC 64 ms
76,196 KB
testcase_20 AC 84 ms
78,312 KB
testcase_21 AC 142 ms
85,512 KB
testcase_22 AC 141 ms
85,516 KB
testcase_23 AC 150 ms
85,464 KB
testcase_24 AC 143 ms
85,516 KB
testcase_25 AC 38 ms
53,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

H,W = map(int,input().split())

import sys
if H == 1 or W == 1:
    print(0)
    for h in range(H):
        for w in range(W):
            print(0,end = " ")
        print()
    exit()
ans = [[0] * W for _ in range(H)]
A = ans
if W % 2 == 1:
    wend = W - 1
else:
    wend = W
if H % 2 == 1:
    hend = H - 1
else:
    hend = H
if H % 2 == 0 or W % 2 == 0:
    for h in range(hend):
        for w in range(wend):
            A[h][w] = 1
    print(hend * wend)
    for h in range(H):
        print(*A[h])
    exit()
else:
    for h in range(H):
        for w in range(W):
            A[h][w] = 1
    m = min(H,W)
    for i in range(m):
        A[i][i] = 0
    if W > m:
        for i in range(m,W):
            A[0][i] = 0
    if H > m:
        for i in range(m,H):
            A[i][0] = 0
    print(H * W - max(H,W))
    for h in range(H):
        print(*A[h])

0