結果

問題 No.2520 L1 Explosion
ユーザー MasKoaTS
提出日時 2023-10-05 11:12:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,382 ms / 2,000 ms
コード長 833 bytes
コンパイル時間 273 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 78,156 KB
最終ジャッジ日時 2024-07-26 15:00:44
合計ジャッジ時間 17,194 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
MOD = 998244353
INV2 = pow(2, MOD - 2, MOD)


n, m = map(int, input().split())
mons = [(x - y, x + y, m - h) for x, y, h in (map(int, input().split()) for _ in [0] * n)]

imos = []
for x, y, d in mons:
    imos.append((x - d, y - d, 1))
    imos.append((x + d, y - d, -1))
    imos.append((x - d, y + d, -1))
    imos.append((x + d, y + d, 1))
imos.sort()

area = [0] * (n + 1)
col_nows = []
x_now = -10 ** 18
for x, y, c in imos:
    if(x_now != x):
        col_nows.sort()
        cnt = 0
        for i, (y_now, c_now) in enumerate(col_nows[:-1]):
            cnt += c_now
            y_next = col_nows[i + 1][0]
            area[cnt] += (y_next - y_now) % MOD * (x - x_now) % MOD
        x_now = x
    col_nows.append((y, c))

for s in area[1:]:
    ans = s % MOD * INV2 % MOD
    print(ans)
0