結果

問題 No.1974 2x2 Flipper
ユーザー 👑 rin204rin204
提出日時 2022-06-11 14:37:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 151 ms / 2,000 ms
コード長 702 bytes
コンパイル時間 1,409 ms
コンパイル使用メモリ 81,464 KB
実行使用メモリ 85,340 KB
最終ジャッジ日時 2023-10-21 23:58:12
合計ジャッジ時間 7,179 ms
ジャッジサーバーID
(参考情報)
judge9 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,392 KB
testcase_01 AC 67 ms
76,156 KB
testcase_02 AC 49 ms
63,960 KB
testcase_03 AC 115 ms
81,692 KB
testcase_04 AC 82 ms
78,036 KB
testcase_05 AC 71 ms
76,860 KB
testcase_06 AC 98 ms
79,652 KB
testcase_07 AC 84 ms
78,256 KB
testcase_08 AC 56 ms
72,988 KB
testcase_09 AC 100 ms
80,076 KB
testcase_10 AC 56 ms
72,656 KB
testcase_11 AC 88 ms
78,744 KB
testcase_12 AC 115 ms
81,804 KB
testcase_13 AC 92 ms
79,100 KB
testcase_14 AC 79 ms
77,476 KB
testcase_15 AC 127 ms
82,904 KB
testcase_16 AC 57 ms
73,820 KB
testcase_17 AC 106 ms
80,500 KB
testcase_18 AC 54 ms
72,400 KB
testcase_19 AC 62 ms
75,896 KB
testcase_20 AC 81 ms
78,040 KB
testcase_21 AC 145 ms
85,272 KB
testcase_22 AC 148 ms
85,280 KB
testcase_23 AC 150 ms
85,340 KB
testcase_24 AC 151 ms
85,288 KB
testcase_25 AC 37 ms
53,396 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(h, w):
    A = [[1] * w for _ in range(h)]
    if h == 1 or w == 1:
        A = [[0] * w for _ in range(h)]
        cnt = 0
    elif not h & 1 and not w & 1:
        cnt = h * w
    elif not h & 1:
        for i in range(h):
            A[i][0] = 0
        cnt = h * (w - 1)
    elif not w & 1:
        for j in range(w):
            A[0][j] = 0
        cnt = (h - 1) * w
    elif h >= w:
        for i in range(h):
            A[i][min(i, w - 1)] = 0
        cnt = h * (w - 1)
    else:
        for i in range(w):
            A[min(i, h - 1)][i] = 0
        cnt = (h - 1) * w
    return cnt, A


h, w = map(int, input().split())
cnt, A = solve(h, w)
print(cnt)
for row in A:
    print(*row)
0