結果
問題 |
No.1490 スライムと爆弾
|
ユーザー |
![]() |
提出日時 | 2021-04-23 23:20:43 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 566 ms / 2,000 ms |
コード長 | 1,427 bytes |
コンパイル時間 | 396 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 121,600 KB |
最終ジャッジ日時 | 2024-07-04 08:45:28 |
合計ジャッジ時間 | 7,851 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
import sys sys.setrecursionlimit(10 ** 6) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.buffer.readline()) def LI(): return list(map(int, sys.stdin.buffer.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LI1(): return list(map(int1, sys.stdin.buffer.readline().split())) def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def BI(): return sys.stdin.buffer.readline().rstrip() def SI(): return sys.stdin.buffer.readline().rstrip().decode() inf = 10 ** 16 md = 10 ** 9 + 7 # md = 998244353 h, w, n, m = LI() ss = LLI(n) cs = [[0] * (w + 2) for _ in range(h + 2)] for _ in range(m): x, y, b, c = LI() i0 = max(1, x - b) i1 = min(h+1, x + b + 1) j0 = max(1, y - b) j1 = min(w+1, y + b + 1) cs[i0][j0] += c cs[i1][j1] += c cs[i0][j1] -= c cs[i1][j0] -= c for i in range(1, h + 1): for j in range(w): cs[i][j + 1] += cs[i][j] for j in range(1, w + 1): for i in range(h): cs[i + 1][j] += cs[i][j] for i in range(1, h + 1): for j in range(w): cs[i][j + 1] += cs[i][j] for j in range(1, w + 1): for i in range(h): cs[i + 1][j] += cs[i][j] # p2D(cs) ans = 0 for t, u, l, r, a in ss: t, l = t - 1, l - 1 # print(cs[t][l] + cs[u][r] - cs[t][r] - cs[u][l]) if cs[t][l] + cs[u][r] - cs[t][r] - cs[u][l] < a: ans += 1 print(ans)