結果
問題 | No.2520 L1 Explosion |
ユーザー | MasKoaTS |
提出日時 | 2023-10-27 13:00:28 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 464 ms / 2,000 ms |
コード長 | 1,862 bytes |
コンパイル時間 | 275 ms |
コンパイル使用メモリ | 82,156 KB |
実行使用メモリ | 150,504 KB |
最終ジャッジ日時 | 2024-09-25 13:00:01 |
合計ジャッジ時間 | 8,836 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 128 ms
86,400 KB |
testcase_01 | AC | 129 ms
86,400 KB |
testcase_02 | AC | 130 ms
86,400 KB |
testcase_03 | AC | 126 ms
86,352 KB |
testcase_04 | AC | 127 ms
86,416 KB |
testcase_05 | AC | 126 ms
86,152 KB |
testcase_06 | AC | 454 ms
150,504 KB |
testcase_07 | AC | 243 ms
105,540 KB |
testcase_08 | AC | 457 ms
150,272 KB |
testcase_09 | AC | 461 ms
150,220 KB |
testcase_10 | AC | 464 ms
150,016 KB |
testcase_11 | AC | 455 ms
150,288 KB |
testcase_12 | AC | 462 ms
150,148 KB |
testcase_13 | AC | 462 ms
150,016 KB |
testcase_14 | AC | 460 ms
150,200 KB |
testcase_15 | AC | 154 ms
90,284 KB |
testcase_16 | AC | 384 ms
140,748 KB |
testcase_17 | AC | 276 ms
107,480 KB |
testcase_18 | AC | 280 ms
107,276 KB |
testcase_19 | AC | 263 ms
107,664 KB |
testcase_20 | AC | 148 ms
90,248 KB |
testcase_21 | AC | 363 ms
127,788 KB |
testcase_22 | AC | 169 ms
89,332 KB |
testcase_23 | AC | 159 ms
89,800 KB |
testcase_24 | AC | 340 ms
128,112 KB |
ソースコード
import itertools as iter import collections as coll import heapq as hq import bisect as bis from decimal import Decimal as dec from functools import cmp_to_key import math import sys #import pypyjit #pypyjit.set_param('max_unroll_recursion=-1') sys.setrecursionlimit(10 ** 6) inp = sys.stdin.readline input = lambda : inp()[:-1] getN = lambda : int(inp()) getNs = lambda : map(int, inp().split()) getList = lambda :list(map(int, inp().split())) getStrs = lambda n : [input() for _ in [0] * n] getEdges = lambda n : [[x - 1 for x in getNs()] for _ in [0] * n] def yexit(): print("Yes"); exit(0) def nexit(): print("No"); exit(0) pi = 3.141592653589793 mod = 1000000007 MOD = 998244353 INF = 4611686018427387903 dx = [1, 0, -1, 0]; dy = [0, 1, 0, -1] #di = coll.defaultdict(int) """ Main Code """ n, m = getNs() enemies_tmp = [getList() for _ in [0] * n] enemies = [[x - y, x + y, m - h] for x, y, h in enemies_tmp] X1 = [x - d for x, _, d in enemies] X2 = [x + d for x, _, d in enemies] Y1 = [y - d for _, y, d in enemies] Y2 = [y + d for _, y, d in enemies] X = sorted(set(X1) | set(X2)) Y = sorted(set(Y1) | set(Y2)) id_X = { x : i for i, x in enumerate(X) } id_Y = { y : i for i, y in enumerate(Y) } w = len(X) h = len(Y) imos = [[0] * h for _ in [0] * w] for x1, x2, y1, y2 in zip(X1, X2, Y1, Y2): imos[id_X[x1]][id_Y[y1]] += 1 imos[id_X[x1]][id_Y[y2]] -= 1 imos[id_X[x2]][id_Y[y1]] -= 1 imos[id_X[x2]][id_Y[y2]] += 1 for x in range(w): for y in range(1, h): imos[x][y] += imos[x][y - 1] for x in range(1, w): for y in range(h): imos[x][y] += imos[x - 1][y] area = [0] * (n + 1) for x in range(w - 1): for y in range(h - 1): area[imos[x][y]] += ((X[x + 1] - X[x]) % MOD) * ((Y[y + 1] - Y[y]) % MOD) % MOD INV2 = pow(2, MOD - 2, MOD) for s in area[1:]: ans = s % MOD * INV2 % MOD print(ans)