結果
| 問題 |
No.2112 All 2x2 are Equal
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-10-28 23:16:59 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 166 ms / 2,000 ms |
| コード長 | 1,280 bytes |
| コンパイル時間 | 250 ms |
| コンパイル使用メモリ | 82,224 KB |
| 実行使用メモリ | 93,020 KB |
| 最終ジャッジ日時 | 2024-07-06 02:31:29 |
| 合計ジャッジ時間 | 7,025 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 34 |
ソースコード
H,W= map(int,input().split())
check = 0
if H % 2 == 1 and W % 2 == 0:
H,W = W,H
check = 1
print('Yes')
S = 1+H*W
count = 1
co = H*W
ans = [[0]*W for _ in range(H)]
if check:
for i in range(H//2):
for j in range(W):
if j % 2 == 0:
ans[2*i][j] = count
ans[2*i+1][j] = co
count += 1
co -= 1
else:
ans[2*i][j] = co
ans[2*i+1][j] = count
count += 1
co -= 1
if H % 2 == 1:
D = ans[-2][0]+ans[-2][1]
ans[-1][0] = count
for j in range(1,W):
if j % 2 == 0:
ans[-1][j] = D-ans[-1][j-1]
else:
ans[-1][j] = D-ans[-1][j-1]-2
answer = [[0]*H for _ in range(W)]
for w in range(W):
for h in range(H):
answer[w][h] = ans[h][w]
print(*answer[w])
exit()
for i in range(H//2):
for j in range(W):
if j % 2 == 0:
ans[2*i][j] = count
ans[2*i+1][j] = co
count += 1
co -= 1
else:
ans[2*i][j] = co
ans[2*i+1][j] = count
count += 1
co -= 1
print(*ans[2*i])
print(*ans[2*i+1])
if H % 2 == 1:
D = ans[-2][0]+ans[-2][1]
ans[-1][0] = count
for j in range(1,W):
if j % 2 == 0:
ans[-1][j] = D-ans[-1][j-1]
else:
ans[-1][j] = D-ans[-1][j-1]-2
print(*ans[-1])