結果

問題 No.918 LISGRID
ユーザー maspymaspy
提出日時 2020-03-21 12:07:52
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 965 bytes
コンパイル時間 98 ms
コンパイル使用メモリ 10,928 KB
実行使用メモリ 45,184 KB
最終ジャッジ日時 2023-08-23 10:39:18
合計ジャッジ時間 16,076 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
29,692 KB
testcase_01 AC 227 ms
38,740 KB
testcase_02 AC 164 ms
32,596 KB
testcase_03 AC 184 ms
33,912 KB
testcase_04 AC 167 ms
33,112 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 133 ms
29,972 KB
testcase_27 AC 135 ms
29,972 KB
testcase_28 AC 133 ms
30,028 KB
testcase_29 WA -
testcase_30 AC 135 ms
30,104 KB
testcase_31 WA -
testcase_32 AC 133 ms
29,908 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/ python3.8
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np

H, W = map(int, readline().split())
A = np.array(readline().split(), np.int64)
B = np.array(readline().split(), np.int64)

A.sort()
B.sort()

L = 1
R = H * W

C = np.zeros((H, W), np.int64)
D = C[:]
while True:
    H, W = D.shape
    if not H:
        break
    if not W:
        break
    if B[0] >= 2:
        D[0] = L + np.arange(W)
        L += W
        n = A[0]
        D[0][n-1:] = D[0][n-1:][::-1]
        A = A[1:]
        B -= 1
        D = D[1:]
        continue
    if A[0] >= 2:
        A, B = B, A
        D = D.T
        continue
    assert A[0] == 1
    n = np.count_nonzero(B <= 1)
    D[0][n:] = L + np.arange(W - n)
    D[0][:n] = R - np.arange(n)
    L += W - n
    R -= n
    A = A[1:]
    B[n:] -= 1
    D = D[1:]
    continue

print('\n'.join(' '.join(row) for row in C.astype(str)))
0