結果
問題 | No.918 LISGRID |
ユーザー |
![]() |
提出日時 | 2020-03-21 12:10:52 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 572 ms / 2,000 ms |
コード長 | 973 bytes |
コンパイル時間 | 198 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 57,484 KB |
最終ジャッジ日時 | 2024-12-21 12:56:55 |
合計ジャッジ時間 | 23,769 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 36 |
ソースコード
#!/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))[::-1] 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)))