結果

問題 No.2520 L1 Explosion
ユーザー MasKoaTSMasKoaTS
提出日時 2023-03-28 16:54:09
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 134 ms / 2,000 ms
コード長 1,909 bytes
コンパイル時間 2,324 ms
コンパイル使用メモリ 213,552 KB
実行使用メモリ 73,880 KB
最終ジャッジ日時 2023-10-25 00:36:55
合計ジャッジ時間 4,721 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 119 ms
73,880 KB
testcase_07 AC 38 ms
21,080 KB
testcase_08 AC 133 ms
73,880 KB
testcase_09 AC 84 ms
73,880 KB
testcase_10 AC 132 ms
73,880 KB
testcase_11 AC 133 ms
73,880 KB
testcase_12 AC 134 ms
73,880 KB
testcase_13 AC 133 ms
73,880 KB
testcase_14 AC 132 ms
73,880 KB
testcase_15 AC 6 ms
5,768 KB
testcase_16 AC 96 ms
53,816 KB
testcase_17 AC 63 ms
35,336 KB
testcase_18 AC 65 ms
36,656 KB
testcase_19 AC 55 ms
30,584 KB
testcase_20 AC 3 ms
4,624 KB
testcase_21 AC 90 ms
50,120 KB
testcase_22 AC 12 ms
8,672 KB
testcase_23 AC 8 ms
6,296 KB
testcase_24 AC 76 ms
42,992 KB
権限があれば一括ダウンロードができます

ソースコード

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;
}

void set_XY(int n, ll m, vector<ll>& X1, vector<ll>& Y1, vector<ll>& X2, vector<ll>& Y2, vector<ll>& X, vector<ll>& Y) {
	for (int i = 0; i < n; i++) {
		ll x, y, h;	cin >> x >> y >> h;	h = m - h;
		ll x1 = (x - h) - y, y1 = (x - h) + y;
		X1.push_back(x1);	Y1.push_back(y1);
		X.push_back(x1);	Y.push_back(y1);
		ll x2 = (x + h) - y, y2 = (x + h) + 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 main(void) {
	int n;	ll m;
	cin >> n >> m;

	vector<ll> X1 = {}, Y1 = {}, X2 = {}, Y2 = {}, X = {}, Y = {};
	set_XY(n, m, X1, Y1, X2, Y2, X, Y);

	int h = X.size(), w = Y.size();
	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