結果

問題 No.2520 L1 Explosion
ユーザー MasKoaTSMasKoaTS
提出日時 2023-03-28 18:36:35
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,123 bytes
コンパイル時間 345 ms
コンパイル使用メモリ 81,740 KB
実行使用メモリ 147,584 KB
最終ジャッジ日時 2023-10-25 00:37:01
合計ジャッジ時間 6,148 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,580 KB
testcase_01 AC 38 ms
53,580 KB
testcase_02 AC 38 ms
53,580 KB
testcase_03 AC 38 ms
53,580 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 AC 350 ms
147,424 KB
testcase_07 RE -
testcase_08 AC 350 ms
147,432 KB
testcase_09 AC 353 ms
147,432 KB
testcase_10 AC 352 ms
147,432 KB
testcase_11 AC 365 ms
147,428 KB
testcase_12 AC 353 ms
147,432 KB
testcase_13 AC 367 ms
147,428 KB
testcase_14 AC 354 ms
147,584 KB
testcase_15 AC 62 ms
66,164 KB
testcase_16 AC 275 ms
127,216 KB
testcase_17 AC 191 ms
107,976 KB
testcase_18 AC 198 ms
109,252 KB
testcase_19 AC 162 ms
87,992 KB
testcase_20 AC 57 ms
64,116 KB
testcase_21 AC 265 ms
123,476 KB
testcase_22 AC 71 ms
70,260 KB
testcase_23 AC 68 ms
68,212 KB
testcase_24 AC 226 ms
108,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
MOD = 998244353

def solve():
	n, m = map(int, input().split())

	X1 = [];	X2 = [];	X = []
	Y1 = [];	Y2 = [];	Y = []
	for x, y, h in (map(int, input().split()) for _ in [0] * n):
		d = m - h
		x1, y1 = (x - d) - y, (x - d) + y
		x2, y2 = (x + d) - y, (x + d) + y
		X1.append(x1);	X2.append(x2);	X.extend([x1, x2])	
		Y1.append(y1);	Y2.append(y2);	Y.extend([y1, y2])

	X.sort();	Y.sort()
	hX = {};	hY = {}
	for i, (x, y) in enumerate(zip(X, Y)):
		hX[x] = hY[y] = i
	h, w = len(hX), len(hY)

	dp = [[0] * w for _ in [0] * h]
	for x1, y1, x2, y2 in zip(X1, Y1, X2, Y2):
		dp[hX[x1]][hY[y1]] += 1
		dp[hX[x1]][hY[y2]] -= 1
		dp[hX[x2]][hY[y1]] -= 1
		dp[hX[x2]][hY[y2]] += 1
	for i in range(h):
		for j in range(1, w):
			dp[i][j] += dp[i][j - 1]
	for i in range(1, h):
		for j in range(w):
			dp[i][j] += dp[i - 1][j]

	ans = [0] * (n + 1)
	for i in range(h - 1):
		for j in range(w - 1):
			ans[dp[i][j]] += ((X[i + 1] - X[i]) % MOD) * ((Y[j + 1] - Y[j]) % MOD) % MOD
			ans[dp[i][j]] %= MOD
	div2 = pow(2, MOD - 2, MOD)
	for i in range(1, n + 1):
		print(ans[i] * div2 % MOD)

solve()
0