結果
| 問題 |
No.1974 2x2 Flipper
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 14:00:58 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 826 bytes |
| コンパイル時間 | 174 ms |
| コンパイル使用メモリ | 82,640 KB |
| 実行使用メモリ | 85,536 KB |
| 最終ジャッジ日時 | 2025-06-12 14:02:01 |
| 合計ジャッジ時間 | 5,333 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 20 WA * 5 |
ソースコード
H, W = map(int, input().split())
ans = 0
grid = []
if H % 2 == 0 and W % 2 == 0:
ans = H * W
grid = [[1] * W for _ in range(H)]
elif H % 2 == 0:
# W is odd
ans = H * (W - 1)
for _ in range(H):
row = [1] * (W - 1) + [0]
grid.append(row)
elif W % 2 == 0:
# H is odd
ans = (H - 1) * W
for _ in range(H - 1):
grid.append([1] * W)
grid.append([0] * W)
else:
# Both are odd
ans = (H - 1) * (W - 1) + (H - 1) + (W - 1)
for i in range(H):
row = []
for j in range(W):
if i < H - 1 and j < W - 1:
row.append(1)
elif i < H - 1 or j < W - 1:
row.append(1)
else:
row.append(0)
grid.append(row)
print(ans)
for row in grid:
print(' '.join(map(str, row)))
gew1fw