結果

問題 No.1974 2x2 Flipper
ユーザー lloyzlloyz
提出日時 2022-06-11 00:26:24
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 477 ms / 2,000 ms
コード長 919 bytes
コンパイル時間 158 ms
コンパイル使用メモリ 11,876 KB
実行使用メモリ 19,188 KB
最終ジャッジ日時 2023-10-21 06:26:33
合計ジャッジ時間 8,122 ms
ジャッジサーバーID
(参考情報)
judge14 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,136 KB
testcase_01 AC 78 ms
11,188 KB
testcase_02 AC 36 ms
10,504 KB
testcase_03 AC 333 ms
16,200 KB
testcase_04 AC 163 ms
13,064 KB
testcase_05 AC 106 ms
11,888 KB
testcase_06 AC 236 ms
13,972 KB
testcase_07 AC 163 ms
12,772 KB
testcase_08 AC 55 ms
10,828 KB
testcase_09 AC 253 ms
14,660 KB
testcase_10 AC 53 ms
10,868 KB
testcase_11 AC 196 ms
13,776 KB
testcase_12 AC 320 ms
16,176 KB
testcase_13 AC 205 ms
13,704 KB
testcase_14 AC 135 ms
12,408 KB
testcase_15 AC 373 ms
16,716 KB
testcase_16 AC 56 ms
10,932 KB
testcase_17 AC 272 ms
14,960 KB
testcase_18 AC 57 ms
10,944 KB
testcase_19 AC 57 ms
10,948 KB
testcase_20 AC 157 ms
12,792 KB
testcase_21 AC 477 ms
19,184 KB
testcase_22 AC 476 ms
19,044 KB
testcase_23 AC 477 ms
19,188 KB
testcase_24 AC 472 ms
19,044 KB
testcase_25 AC 30 ms
10,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

h, w = map(int, input().split())

if h == 1 and w == 1:
    print(0)
    print(0)
    exit()
if h == 1:
    ANS = [0 for _ in range(w)]
    print(0)
    print(*ANS)
    exit()
if w == 1:
    print(0)
    for i in range(h):
        print(0)
    exit()

ans = 0
ANS = [[1 for _ in range(w)] for _ in range(h)]
if h % 2 == 0 and w % 2 == 0:
    ans += h * w
elif h % 2 == 1 and w % 2 == 0:
    ans += w * (h - 1)
    for i in range(w):
        ANS[-1][i] = 0
elif h % 2 == 0 and w % 2 == 1:
    ans += (w - 1) * h
    for i in range(h):
        ANS[i][-1] = 0
else:
    if h <= w:
        ans += (h - 1) * w
        for i in range(h):
            ANS[h - i - 1][i] = 0
        for i in range(h, w):
            ANS[0][i] = 0
    else:
        ans += h * (w - 1)
        for i in range(w):
            ANS[w - i - 1][i] = 0
        for i in range(w, h):
            ANS[i][0] = 0
print(ans)
for ele in ANS:
    print(*ele)
0