結果

問題 No.2520 L1 Explosion
ユーザー shobonvipshobonvip
提出日時 2023-10-27 23:37:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 72 ms / 2,000 ms
コード長 2,631 bytes
コンパイル時間 4,734 ms
コンパイル使用メモリ 271,328 KB
実行使用メモリ 38,760 KB
最終ジャッジ日時 2023-10-27 23:37:21
合計ジャッジ時間 6,674 ms
ジャッジサーバーID
(参考情報)
judge10 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,372 KB
testcase_01 AC 2 ms
4,372 KB
testcase_02 AC 1 ms
4,372 KB
testcase_03 AC 1 ms
4,372 KB
testcase_04 AC 1 ms
4,372 KB
testcase_05 AC 2 ms
4,372 KB
testcase_06 AC 70 ms
38,760 KB
testcase_07 AC 18 ms
12,732 KB
testcase_08 AC 68 ms
38,760 KB
testcase_09 AC 69 ms
38,760 KB
testcase_10 AC 72 ms
38,760 KB
testcase_11 AC 69 ms
38,760 KB
testcase_12 AC 68 ms
38,760 KB
testcase_13 AC 71 ms
38,760 KB
testcase_14 AC 69 ms
38,760 KB
testcase_15 AC 4 ms
4,988 KB
testcase_16 AC 49 ms
28,728 KB
testcase_17 AC 30 ms
19,488 KB
testcase_18 AC 32 ms
20,280 KB
testcase_19 AC 26 ms
17,112 KB
testcase_20 AC 3 ms
4,372 KB
testcase_21 AC 46 ms
26,880 KB
testcase_22 AC 7 ms
6,376 KB
testcase_23 AC 4 ms
5,192 KB
testcase_24 AC 38 ms
23,448 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

//* ATCODER
#include<atcoder/all>
using namespace atcoder;
typedef modint998244353 mint;
//*/

/* BOOST MULTIPRECISION
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
//*/

typedef long long ll;

#define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--)

template <typename T> bool chmin(T &a, const T &b) {
	if (a <= b) return false;
	a = b;
	return true;
}

template <typename T> bool chmax(T &a, const T &b) {
	if (a >= b) return false;
	a = b;
	return true;
}

template <typename T> T max(vector<T> &a){
	assert(!a.empty());
	T ret = a[0];
	for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]);
	return ret;
}

template <typename T> T min(vector<T> &a){
	assert(!a.empty());
	T ret = a[0];
	for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]);
	return ret;
}

template <typename T> T sum(vector<T> &a){
	T ret = 0;
	for (int i=0; i<(int)a.size(); i++) ret += a[i];
	return ret;
}

// defcomp
template <typename T>
vector<T> compress(vector<T> &X) {
	vector<T> vals = X;
	sort(vals.begin(), vals.end());
	vals.erase(unique(vals.begin(), vals.end()), vals.end());
	return vals;
}
// -----

// importbisect
template <typename T>
int bisect_left(vector<T> &X, T v){
	return lower_bound(X.begin(), X.end(), v) - X.begin();
}

template <typename T>
int bisect_right(vector<T> &X, T v){
	return upper_bound(X.begin(), X.end(), v) - X.begin();
}
// -----


int main(){
	int n; cin >> n;
	ll m; cin >> m;
	vector<ll> x(n), y(n);
	vector<ll> d(n);
	vector<ll> xs, ys;
	rep(i,0,n){
		ll u, v; cin >> u >> v;
		x[i] = u + v;
		y[i] = u - v;
		cin >> d[i];
		d[i] = m - d[i];
		xs.push_back(x[i] - d[i]);
		xs.push_back(x[i] + d[i]);
		ys.push_back(y[i] - d[i]);
		ys.push_back(y[i] + d[i]);
	}

	vector<ll> x_c = compress(xs);
	vector<ll> y_c = compress(ys);
	mint inv2 = mint(2).inv();
	int s = x_c.size();
	int t = y_c.size();
	vector imos(s + 1, vector<int>(t + 1));
	rep(i,0,n){
		int x1 = bisect_left(x_c, x[i] - d[i]);
		int x2 = bisect_left(x_c, x[i] + d[i]);
		int y1 = bisect_left(y_c, y[i] - d[i]);
		int y2 = bisect_left(y_c, y[i] + d[i]);
		imos[x1][y1]++;
		imos[x1][y2]--;
		imos[x2][y1]--;
		imos[x2][y2]++;
	}
	rep(i,0,s+1){
		rep(j,0,t){
			imos[i][j+1] += imos[i][j];
		}
	}
	rep(i,0,s){
		rep(j,0,t+1){
			imos[i+1][j] += imos[i][j];
		}
	}

	vector<mint> ans(n+1);
	rep(i,0,s-1){
		rep(j,0,t-1){
			ans[imos[i][j]] += mint(x_c[i+1] - x_c[i]) * mint(y_c[j+1] - y_c[j]);
		}
	}

	rep(i,0,n+1){
		ans[i] *= inv2;
	}
	rep(i,1,n+1){
		cout << ans[i].val() << '\n';
	}
}

0