結果

問題 No.2520 L1 Explosion
コンテスト
ユーザー MasKoaTS
提出日時 2023-10-05 11:12:58
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 904 ms / 2,000 ms
コード長 833 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 124 ms
コンパイル使用メモリ 85,504 KB
実行使用メモリ 82,432 KB
最終ジャッジ日時 2026-04-03 17:23:07
合計ジャッジ時間 11,867 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge5_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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