結果
| 問題 |
No.2520 L1 Explosion
|
| コンテスト | |
| ユーザー |
kwm_t
|
| 提出日時 | 2023-10-28 17:08:50 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 109 ms / 2,000 ms |
| コード長 | 2,507 bytes |
| コンパイル時間 | 4,405 ms |
| コンパイル使用メモリ | 260,720 KB |
| 最終ジャッジ日時 | 2025-02-17 16:42:25 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
ソースコード
#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;
}
kwm_t