結果
問題 | 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 = 0if H % 2 == 1 and W % 2 == 0:H,W = W,Hcheck = 1print('Yes')S = 1+H*Wcount = 1co = H*Wans = [[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] = countans[2*i+1][j] = cocount += 1co -= 1else:ans[2*i][j] = coans[2*i+1][j] = countcount += 1co -= 1if H % 2 == 1:D = ans[-2][0]+ans[-2][1]ans[-1][0] = countfor 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]-2answer = [[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] = countans[2*i+1][j] = cocount += 1co -= 1else:ans[2*i][j] = coans[2*i+1][j] = countcount += 1co -= 1print(*ans[2*i])print(*ans[2*i+1])if H % 2 == 1:D = ans[-2][0]+ans[-2][1]ans[-1][0] = countfor 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]-2print(*ans[-1])