結果

問題 No.1974 2x2 Flipper
ユーザー ansainansain
提出日時 2022-06-11 02:43:26
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 403 ms / 2,000 ms
コード長 714 bytes
コンパイル時間 89 ms
コンパイル使用メモリ 11,864 KB
実行使用メモリ 10,564 KB
最終ジャッジ日時 2023-10-21 08:56:01
合計ジャッジ時間 7,797 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
10,180 KB
testcase_01 AC 63 ms
10,516 KB
testcase_02 AC 31 ms
10,508 KB
testcase_03 AC 273 ms
10,520 KB
testcase_04 AC 135 ms
10,524 KB
testcase_05 AC 89 ms
10,520 KB
testcase_06 AC 190 ms
10,520 KB
testcase_07 AC 144 ms
10,516 KB
testcase_08 AC 47 ms
10,512 KB
testcase_09 AC 208 ms
10,524 KB
testcase_10 AC 45 ms
10,512 KB
testcase_11 AC 162 ms
10,520 KB
testcase_12 AC 269 ms
10,524 KB
testcase_13 AC 177 ms
10,516 KB
testcase_14 AC 111 ms
10,520 KB
testcase_15 AC 302 ms
10,524 KB
testcase_16 AC 47 ms
10,512 KB
testcase_17 AC 228 ms
10,516 KB
testcase_18 AC 47 ms
10,516 KB
testcase_19 AC 48 ms
10,512 KB
testcase_20 AC 133 ms
10,524 KB
testcase_21 AC 393 ms
10,520 KB
testcase_22 AC 394 ms
10,524 KB
testcase_23 AC 403 ms
10,524 KB
testcase_24 AC 401 ms
10,564 KB
testcase_25 AC 26 ms
10,180 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def yn(hantei, yes='Yes', no='No'): print(yes if hantei else no)
def p(*args): print(*args)
n,m=map(int, input().split())
if n%2==0 and m%2==0:
    print(n*m)
    for i in range(n):
        print(*[1]*m)
elif n%2==1 and m%2==0:
    print((n-1)*m)
    for i in range(n-1):
        print(*[1]*m)
    print(*[0]*m)
elif n%2==0 and m%2==1:
    print((n)*(m-1))
    for i in range(n):
        print(*[1]*(m-1)+[0])
    #print(*[0]*m)
elif n >= m:
    print(n*m-n)
    for i in range(n-m):
        print(*[1]*(m-1)+[0])
    for i in range(m):
        print(*[1]*(m-i-1) + [0] + [1] * i)
else:
    print(n*m-m)
    print(*[0]*(m-n+1) + [1] * (n-1))
    for i in range(1,n):
        print(*[1]*(m-n+i) + [0] + [1]*(n-i-1))
0