結果

問題 No.2520 L1 Explosion
ユーザー kwm_tkwm_t
提出日時 2023-10-28 17:08:50
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 129 ms / 2,000 ms
コード長 2,507 bytes
コンパイル時間 4,427 ms
コンパイル使用メモリ 272,620 KB
実行使用メモリ 38,644 KB
最終ジャッジ日時 2023-10-28 17:08:58
合計ジャッジ時間 6,701 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 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 91 ms
38,644 KB
testcase_07 AC 28 ms
12,244 KB
testcase_08 AC 104 ms
38,644 KB
testcase_09 AC 55 ms
38,644 KB
testcase_10 AC 104 ms
38,644 KB
testcase_11 AC 129 ms
38,644 KB
testcase_12 AC 105 ms
38,644 KB
testcase_13 AC 103 ms
38,644 KB
testcase_14 AC 103 ms
38,644 KB
testcase_15 AC 6 ms
4,588 KB
testcase_16 AC 74 ms
28,612 KB
testcase_17 AC 48 ms
19,372 KB
testcase_18 AC 50 ms
19,900 KB
testcase_19 AC 41 ms
16,996 KB
testcase_20 AC 3 ms
4,348 KB
testcase_21 AC 71 ms
26,764 KB
testcase_22 AC 10 ms
5,908 KB
testcase_23 AC 6 ms
4,852 KB
testcase_24 AC 60 ms
23,332 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
const int mod = 998244353;
//using mint = modint1000000007;
//const int mod = 1000000007;
//const int INF = 1e9;
//const long long LINF = 1e18;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i,l,r)for(int i=(l);i<(r);++i)
#define rrep(i, n) for (int i = (n-1); i >= 0; --i)
#define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i)
#define all(x) (x).begin(),(x).end()
#define allR(x) (x).rbegin(),(x).rend()
#define P pair<int,int>
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }
template <class S>
struct value_compression : std::vector<S> {
	bool built = false;
	using VS = std::vector<S>;
	using VS::VS;
	value_compression(std::vector<S> v = {}) : std::vector<S>(move(v)) {}
	void build() {
		std::sort(this->begin(), this->end());
		this->erase(unique(this->begin(), this->end()), this->end());
		built = true;
	}
	template <class T>
	void convert(T first, T last) {
		assert(built);
		for (; first != last; ++first) *first = (*this)(*first);
	}
	int operator()(S x) {
		assert(built);
		return lower_bound(this->begin(), this->end(), x) - this->begin();
	}
	void clear() {
		this->clear();
		built = false;
	}
};
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, m; cin >> n >> m;
	struct S {
		long long xl, xr, yl, yr;
	};
	vector<S>vs(n);
	rep(i, n) {
		long long x, y, h; cin >> x >> y >> h;
		long long d = m - h;
		vs[i] = {
			x - y - d,
			x - y + d,
			x + y - d,
			x + y + d
		};
	}
	value_compression<long long>vcx, vcy;
	for (auto e : vs) {
		vcx.emplace_back(e.xl);
		vcx.emplace_back(e.xr);
		vcy.emplace_back(e.yl);
		vcy.emplace_back(e.yr);
	}
	vcx.build();
	vcy.build();
	int h = vcx.size();
	int w = vcy.size();
	vector d(h, vector<int>(w));
	for (auto e : vs) {
		auto xl = vcx(e.xl);
		auto xr = vcx(e.xr);
		auto yl = vcy(e.yl);
		auto yr = vcy(e.yr);
		d[xl][yl]++;
		d[xr][yl]--;
		d[xl][yr]--;
		d[xr][yr]++;
	}
	rep(i, h)rep(j, w - 1)d[i][j + 1] += d[i][j];
	rep(i, h - 1)rep(j, w)d[i + 1][j] += d[i][j];
	vector<mint>ans(n + 1);
	mint inv2 = mint(2).inv();
	rep(i, h)rep(j, w) {
		if (d[i][j])ans[d[i][j]] += inv2 * (vcx[i + 1] - vcx[i]) * (vcy[j + 1] - vcy[j]);
	}
	rep2(i, 1, n + 1)cout << ans[i].val() << endl;
	return 0;
}
0