結果

問題 No.1974 2x2 Flipper
ユーザー titiatitia
提出日時 2022-06-12 01:55:16
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 443 ms / 2,000 ms
コード長 642 bytes
コンパイル時間 107 ms
コンパイル使用メモリ 11,936 KB
実行使用メモリ 18,376 KB
最終ジャッジ日時 2023-10-23 18:20:59
合計ジャッジ時間 9,338 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
10,152 KB
testcase_01 AC 75 ms
11,280 KB
testcase_02 AC 34 ms
10,512 KB
testcase_03 AC 301 ms
15,680 KB
testcase_04 AC 152 ms
12,800 KB
testcase_05 AC 99 ms
11,816 KB
testcase_06 AC 218 ms
13,892 KB
testcase_07 AC 150 ms
12,572 KB
testcase_08 AC 51 ms
10,876 KB
testcase_09 AC 230 ms
14,328 KB
testcase_10 AC 50 ms
10,876 KB
testcase_11 AC 183 ms
13,404 KB
testcase_12 AC 299 ms
15,660 KB
testcase_13 AC 190 ms
13,572 KB
testcase_14 AC 124 ms
12,316 KB
testcase_15 AC 354 ms
16,528 KB
testcase_16 AC 53 ms
10,724 KB
testcase_17 AC 251 ms
14,752 KB
testcase_18 AC 52 ms
10,724 KB
testcase_19 AC 54 ms
10,968 KB
testcase_20 AC 146 ms
12,740 KB
testcase_21 AC 437 ms
18,376 KB
testcase_22 AC 443 ms
18,376 KB
testcase_23 AC 443 ms
18,368 KB
testcase_24 AC 441 ms
18,360 KB
testcase_25 AC 28 ms
10,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

ANS=[[1]*W for i in range(H)]

if H%2==0 and W%2==0:
    print(H*W)
    for ans in ANS:
        print(*ans)

elif H%2==1 and W%2==0:
    print(H*W-W)
    for i in range(W):
        ANS[0][i]=0

    for ans in ANS:
        print(*ans)
elif H%2==0 and W%2==1:
    print(H*W-H)
    for i in range(H):
        ANS[i][0]=0

    for ans in ANS:
        print(*ans)
else:
    if H<=W:
        for i in range(W):
            ANS[min(i,H-1)][i]=0
        print(H*W-W)
    else:
        for i in range(H):
            ANS[i][min(i,W-1)]=0
        print(H*W-H)
        
    for ans in ANS:
        print(*ans)
            
0