結果

問題 No.2112 All 2x2 are Equal
コンテスト
ユーザー flygon
提出日時 2022-10-28 22:43:27
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 121 ms / 2,000 ms
コード長 573 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 126 ms
コンパイル使用メモリ 85,648 KB
実行使用メモリ 89,640 KB
最終ジャッジ日時 2026-03-27 12:09:27
合計ジャッジ時間 6,351 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

h,w = map(int,input().split())
ans = [[0]*(w) for i in range(h)]
now = 1
for i in range(h):
  for j in range(w):
    if i % 2 == j % 2:
      ans[i][j] = now
      now += 1
  
for i in range(h)[::-1]:
  for j in range(w)[::-1]:
    tmp = i*w+j
    if i%2 != j% 2:
      ans[i][j] = now
      now += 1

flg = True
s = ans[0][0] + ans[0][1] + ans[1][0] + ans[1][1]
for i in range(h-1):
  for j in range(w-1):
    if ans[i][j] +ans[i+1][j] +ans[i][j+1] +ans[i+1][j+1] == s: continue
    flg = False 
if flg:
  print('Yes')
  for i in ans:
    print(*i)   
else:
  print('No') 
0