結果
| 問題 | 
                            No.2520 L1 Explosion
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2023-10-27 23:48:10 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 1,764 ms / 2,000 ms | 
| コード長 | 1,295 bytes | 
| コンパイル時間 | 363 ms | 
| コンパイル使用メモリ | 81,984 KB | 
| 実行使用メモリ | 123,968 KB | 
| 最終ジャッジ日時 | 2024-09-25 15:34:41 | 
| 合計ジャッジ時間 | 16,396 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 22 | 
ソースコード
import sys
sys.setrecursionlimit(5*10**5)
input = sys.stdin.readline
from collections import defaultdict, deque, Counter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right
from math import gcd
n,m = map(int,input().split())
xyh = [list(map(int,input().split())) for i in range(n)]
xyh = [[x-y,x+y,h] for x,y,h in xyh]
mod = 998244353
allx = []
inx = defaultdict(list)
outx = defaultdict(list)
xs = set()
for i in range(n):
    x,y,h = xyh[i]
    inx[x-(m-h)].append(i)
    outx[x+(m-h)].append(i)
    xs.add(x-(m-h))
    xs.add(x+(m-h))
xs = sorted(list(xs))
ans = [0]*(n+1)
nowy = set()
cnt = 0
lastx = -10**18
for xi in xs:
    iny = defaultdict(list)
    outy = defaultdict(list)
    ys = set()
    for i in nowy:
        x,y,h = xyh[i]
        iny[y-(m-h)].append(i)
        outy[y+(m-h)].append(i)
        ys.add(y-(m-h))
        ys.add(y+(m-h))
    ys = sorted(list(ys))
    cnt = 0
    lasty = -10**18
    for yi in ys:
        ans[cnt] += (yi-lasty)*(xi-lastx)%mod
        cnt -= len(outy[yi])
        cnt += len(iny[yi])
        lasty = yi
    lastx = xi
    for i in outx[xi]:
        nowy.discard(i)
    for i in inx[xi]:
        nowy.add(i)
div2 = pow(2, mod-2, mod)
for i in range(len(ans)):
    ans[i] = ans[i]*div2%mod
print(*ans[1:], sep = "\n")