結果

問題 No.2112 All 2x2 are Equal
ユーザー タコイモタコイモ
提出日時 2022-10-28 23:16:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 238 ms / 2,000 ms
コード長 1,280 bytes
コンパイル時間 327 ms
コンパイル使用メモリ 87,096 KB
実行使用メモリ 93,600 KB
最終ジャッジ日時 2023-09-20 06:31:30
合計ジャッジ時間 10,482 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
70,988 KB
testcase_01 AC 77 ms
70,968 KB
testcase_02 AC 101 ms
76,472 KB
testcase_03 AC 92 ms
76,652 KB
testcase_04 AC 153 ms
84,700 KB
testcase_05 AC 161 ms
81,804 KB
testcase_06 AC 200 ms
85,860 KB
testcase_07 AC 125 ms
79,068 KB
testcase_08 AC 180 ms
84,456 KB
testcase_09 AC 102 ms
77,812 KB
testcase_10 AC 139 ms
80,288 KB
testcase_11 AC 119 ms
78,776 KB
testcase_12 AC 134 ms
81,604 KB
testcase_13 AC 188 ms
84,416 KB
testcase_14 AC 98 ms
76,656 KB
testcase_15 AC 189 ms
87,984 KB
testcase_16 AC 88 ms
76,244 KB
testcase_17 AC 182 ms
83,808 KB
testcase_18 AC 94 ms
76,452 KB
testcase_19 AC 104 ms
77,836 KB
testcase_20 AC 94 ms
76,444 KB
testcase_21 AC 196 ms
89,220 KB
testcase_22 AC 93 ms
76,464 KB
testcase_23 AC 90 ms
76,448 KB
testcase_24 AC 105 ms
77,888 KB
testcase_25 AC 108 ms
78,048 KB
testcase_26 AC 98 ms
77,676 KB
testcase_27 AC 129 ms
80,172 KB
testcase_28 AC 164 ms
84,504 KB
testcase_29 AC 112 ms
78,104 KB
testcase_30 AC 126 ms
79,452 KB
testcase_31 AC 159 ms
82,100 KB
testcase_32 AC 203 ms
86,880 KB
testcase_33 AC 207 ms
86,048 KB
testcase_34 AC 238 ms
93,600 KB
testcase_35 AC 200 ms
85,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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])
  
0