結果

問題 No.2520 L1 Explosion
ユーザー MasKoaTSMasKoaTS
提出日時 2023-02-27 18:29:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,734 bytes
コンパイル時間 2,876 ms
コンパイル使用メモリ 213,728 KB
実行使用メモリ 74,408 KB
最終ジャッジ日時 2023-10-25 00:36:50
合計ジャッジ時間 5,251 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define MOD 998244353ll
using namespace std;
using ll = long long;

ll powmod(ll a, ll n) {
	ll ret = 1;
	while (n) {
		if (n & 1) {
			ret *= a;
			ret %= MOD;
		}
		n >>= 1;
		a *= a;	a %= MOD;
	}
	return ret;
}


int main(void) {
	int n;	cin >> n;

	vector<ll> X1 = {}, Y1 = {}, X2 = {}, Y2 = {}, X = {}, Y = {};
	for (int i = 0; i < n; i++) {
		ll x, y, k;		cin >> x >> y >> k;
		ll x1 = (x - k) + y, y1 = (x - k) - y;
		X1.push_back(x1);	Y1.push_back(y1);
		X.push_back(x1);	Y.push_back(y1);
		ll x2 = (x + k) + y, y2 = (x + k) - y;
		X2.push_back(x2);	Y2.push_back(y2);
		X.push_back(x2);	Y.push_back(y2);
	}
	sort(all(X));	X.erase(unique(all(X)), X.end());
	sort(all(Y));	Y.erase(unique(all(Y)), Y.end());

	int h = X.size() + 10, w = Y.size() + 10;
	vector<vector<ll> > dp(h, vector<ll>(w));
	for (int i = 0; i < n; i++) {
		int x1 = lower_bound(all(X), X1[i]) - X.begin();
		int x2 = lower_bound(all(X), X2[i]) - X.begin();
		int y1 = lower_bound(all(Y), Y1[i]) - Y.begin();
		int y2 = lower_bound(all(Y), Y2[i]) - Y.begin();
		dp[x1][y1]++; dp[x2][y1]--; dp[x1][y2]--; dp[x2][y2]++;
	}
	for (int i = 0; i < h; i++) {
		for (int j = 1; j < w; j++) {
			dp[i][j] += dp[i][j - 1];
		}
	}
	for (int i = 1; i < h; i++) {
		for (int j = 0; j < w; j++) {
			dp[i][j] += dp[i - 1][j];
		}
	}

	vector<ll> ans(n + 1);
	for (int i = 0; i < X.size(); i++) {
		for (int j = 0; j < Y.size(); j++) {
			if (dp[i][j] < 1) {
				continue;
			}
			ans[dp[i][j]] += ((X[i + 1] - X[i]) % MOD) * ((Y[j + 1] - Y[j]) % MOD) % MOD;
			ans[dp[i][j]] %= MOD;
		}
	}
	ll div2 = powmod(2, MOD - 2);
	for (int i = 1; i < n + 1; i++) {
		cout << (ans[i] * div2 % MOD) << endl;
	}

	return 0;
}
0