ソースコード 拡げる

Copy
```import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8

@njit((i8, i8, i8[:, :], i8[:, :]), cache=True)
def main(H, W, AB, CD):
G = np.zeros((H, W), np.int64)
for i in range(len(AB)):
a, b = AB[i]
G[a - 1, b - 1] = 1
for i in range(len(CD)):
c, d = CD[i]
G[c - 1, d - 1] = -1
res = np.zeros((H, W), np.bool_)  # 光ったマス
for _ in range(4):
res, G = res.T[::-1], G.T[::-1]
# 下方向に解く
A = np.zeros_like(res)
H, W = A.shape
for h in range(H):
if h >= 1:
A[h] |= A[h - 1]
A[h][G[h] == 1] = 1
A[h][G[h] == -1] = 0
res |= A
return np.sum(res)

H, W, N, M = map(int, readline().split())
AB = nums[:N + N].reshape(N, 2)
CD = nums[N + N:].reshape(M, 2)

print(main(H, W, AB, CD))```

#### 提出情報

提出日時 2020-11-08 21:26:35+0900 E - Akari maspy Python (3.8.2) 500 1240 Byte AC 610 ms 139968 KB

#### ジャッジ結果

セット名 Sample All

 AC × 3
 AC × 20
セット名 テストケース
Sample sample_01.txt, sample_02.txt, sample_03.txt
All handmade_00.txt, max_random_00.txt, max_random_01.txt, max_random_02.txt, max_random_03.txt, max_random_04.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, sample_01.txt, sample_02.txt, sample_03.txt, surrounded_00.txt
ケース名 結果 実行時間 メモリ
handmade_00.txt AC 491 ms 105700 KB
max_random_00.txt AC 586 ms 137428 KB
max_random_01.txt AC 581 ms 138124 KB
max_random_02.txt AC 587 ms 138072 KB
max_random_03.txt AC 580 ms 138104 KB
max_random_04.txt AC 586 ms 137380 KB
random_00.txt AC 610 ms 139612 KB
random_01.txt AC 597 ms 139968 KB
random_02.txt AC 468 ms 106872 KB
random_03.txt AC 471 ms 106216 KB
random_04.txt AC 532 ms 124568 KB
random_05.txt AC 527 ms 124808 KB
random_06.txt AC 521 ms 122284 KB
random_07.txt AC 553 ms 131128 KB
random_08.txt AC 477 ms 108440 KB
random_09.txt AC 541 ms 127376 KB
sample_01.txt AC 469 ms 106232 KB
sample_02.txt AC 469 ms 106548 KB
sample_03.txt AC 471 ms 106552 KB
surrounded_00.txt AC 590 ms 138132 KB