結果

問題 No.2112 All 2x2 are Equal
ユーザー mkawa2mkawa2
提出日時 2023-02-14 22:50:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 253 ms / 2,000 ms
コード長 1,238 bytes
コンパイル時間 275 ms
コンパイル使用メモリ 86,940 KB
実行使用メモリ 86,152 KB
最終ジャッジ日時 2023-09-24 09:49:04
合計ジャッジ時間 12,870 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,492 KB
testcase_01 AC 69 ms
71,408 KB
testcase_02 AC 108 ms
76,360 KB
testcase_03 AC 81 ms
76,596 KB
testcase_04 AC 129 ms
80,676 KB
testcase_05 AC 146 ms
82,036 KB
testcase_06 AC 167 ms
85,488 KB
testcase_07 AC 183 ms
79,460 KB
testcase_08 AC 162 ms
83,748 KB
testcase_09 AC 101 ms
77,340 KB
testcase_10 AC 134 ms
80,260 KB
testcase_11 AC 117 ms
79,280 KB
testcase_12 AC 126 ms
79,344 KB
testcase_13 AC 253 ms
83,964 KB
testcase_14 AC 148 ms
76,564 KB
testcase_15 AC 160 ms
82,084 KB
testcase_16 AC 84 ms
76,640 KB
testcase_17 AC 166 ms
83,924 KB
testcase_18 AC 82 ms
76,872 KB
testcase_19 AC 92 ms
77,852 KB
testcase_20 AC 90 ms
76,868 KB
testcase_21 AC 158 ms
82,836 KB
testcase_22 AC 86 ms
76,584 KB
testcase_23 AC 83 ms
76,824 KB
testcase_24 AC 101 ms
78,048 KB
testcase_25 AC 99 ms
78,108 KB
testcase_26 AC 91 ms
77,628 KB
testcase_27 AC 111 ms
78,700 KB
testcase_28 AC 136 ms
80,880 KB
testcase_29 AC 103 ms
77,912 KB
testcase_30 AC 118 ms
79,552 KB
testcase_31 AC 147 ms
82,132 KB
testcase_32 AC 182 ms
86,152 KB
testcase_33 AC 180 ms
85,596 KB
testcase_34 AC 184 ms
86,100 KB
testcase_35 AC 187 ms
85,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = (1 << 63)-1
# inf = (1 << 31)-1
# md = 10**9+7
md = 998244353

h, w = LI()

aa = [[0]*w for _ in range(h)]

i = j = 0
dj = 2
for a in range(1, (h*w+3)//2):
    aa[i][j] = a
    j += dj
    if j >= w:
        dj = -2
        j = 2*w-1-j
        i += 1
    elif j < 0:
        dj = 2
        j = -1-j
        i += 1
i = 0
j = w-1-(w & 1)
dj = -2
for a in range(h*w, h*w-h*w//2, -1):
    aa[i][j] = a
    j += dj
    if j >= w:
        dj = -2
        j = 2*w-1-j
        i += 1
    elif j < 0:
        dj = 2
        j = -1-j
        i += 1

print("Yes")
for a in aa: print(*a)
0