結果

問題 No.918 LISGRID
ユーザー maspymaspy
提出日時 2020-03-21 11:55:27
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 981 bytes
コンパイル時間 551 ms
コンパイル使用メモリ 10,944 KB
実行使用メモリ 45,560 KB
最終ジャッジ日時 2023-08-23 10:01:30
合計ジャッジ時間 18,146 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
29,808 KB
testcase_01 AC 233 ms
38,504 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 169 ms
32,880 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 131 ms
29,916 KB
testcase_27 AC 134 ms
29,892 KB
testcase_28 AC 131 ms
29,824 KB
testcase_29 WA -
testcase_30 AC 127 ms
29,732 KB
testcase_31 WA -
testcase_32 WA -
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][-1] = D[0][-1], D[0][n - 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