結果

問題 No.2112 All 2x2 are Equal
ユーザー ygd.ygd.
提出日時 2022-10-28 22:46:46
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 687 ms / 2,000 ms
コード長 1,595 bytes
コンパイル時間 584 ms
コンパイル使用メモリ 10,844 KB
実行使用メモリ 56,512 KB
最終ジャッジ日時 2023-09-20 05:55:52
合計ジャッジ時間 12,688 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
9,176 KB
testcase_01 AC 26 ms
9,260 KB
testcase_02 AC 41 ms
10,472 KB
testcase_03 AC 38 ms
10,040 KB
testcase_04 AC 286 ms
28,364 KB
testcase_05 AC 298 ms
30,276 KB
testcase_06 AC 507 ms
45,928 KB
testcase_07 AC 174 ms
20,828 KB
testcase_08 AC 412 ms
38,720 KB
testcase_09 AC 53 ms
11,244 KB
testcase_10 AC 204 ms
22,604 KB
testcase_11 AC 145 ms
18,384 KB
testcase_12 AC 199 ms
22,176 KB
testcase_13 AC 451 ms
41,704 KB
testcase_14 AC 47 ms
10,712 KB
testcase_15 AC 410 ms
37,176 KB
testcase_16 AC 26 ms
9,360 KB
testcase_17 AC 408 ms
37,928 KB
testcase_18 AC 36 ms
10,112 KB
testcase_19 AC 56 ms
11,472 KB
testcase_20 AC 39 ms
10,228 KB
testcase_21 AC 492 ms
42,360 KB
testcase_22 AC 48 ms
11,060 KB
testcase_23 AC 39 ms
10,076 KB
testcase_24 AC 69 ms
12,604 KB
testcase_25 AC 84 ms
13,880 KB
testcase_26 AC 67 ms
12,380 KB
testcase_27 AC 139 ms
17,492 KB
testcase_28 AC 302 ms
29,828 KB
testcase_29 AC 57 ms
11,572 KB
testcase_30 AC 173 ms
20,668 KB
testcase_31 AC 312 ms
30,984 KB
testcase_32 AC 545 ms
48,464 KB
testcase_33 AC 550 ms
48,404 KB
testcase_34 AC 687 ms
56,512 KB
testcase_35 AC 547 ms
48,416 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from re import A
import sys
#input = sys.stdin.readline
#input = sys.stdin.buffer.readline #文字列はダメ
#sys.setrecursionlimit(1000000)
#import math
import bisect
#import itertools
#import random
#from heapq import heapify, heappop, heappush
from collections import defaultdict
#from collections import deque
#import copy #DeepCopy: hoge = [_[:] for _ in hogehoge]
#from functools import lru_cache
#@lru_cache(maxsize=None)
#MOD = pow(10,9) + 7
MOD = 998244353
#dx = [1,0,-1,0]
#dy = [0,1,0,-1]
#dx8 = [1,1,0,-1,-1,-1,0,1]
#dy8 = [0,1,1,1,0,-1,-1,-1]

def main():
    H,W = map(int,input().split())

    Flag = False
    if H%2 == 1:
        if W%2 == 0:
            H,W = W,H
            Flag = True
    
    A = [[0]*W for _ in range(H)]

    s = H*W+1
    num = 0
    for i in range(H//2):
        for j in range(W):
            num += 1
            if j%2 == 0:
                A[i*2][j] = num
                A[i*2+1][j] = s-num
            else:
                A[i*2][j] = s-num
                A[i*2+1][j] = num

    if H%2 == 1:
        for j in range(W):
            num += 1
            A[H-1][j] = num
        # print(A)
        for j in range(W//4):
            nj = 2*j+1
            # print(nj,W-1-nj)
            A[H-1][nj],A[H-1][W-1-nj] = A[H-1][W-1-nj],A[H-1][nj]

    print('Yes')
    if not Flag:
        for ret in A:
            print(*ret)
    else:
        B = [[0]*H for _ in range(W)]
        for i in range(H):
            for j in range(W):
                B[j][i] = A[i][j]
        for ret in B:
            print(*ret)

if __name__ == '__main__':
    main()
0