結果
問題 |
No.2520 L1 Explosion
|
ユーザー |
![]() |
提出日時 | 2023-10-27 23:37:14 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 76 ms / 2,000 ms |
コード長 | 2,631 bytes |
コンパイル時間 | 3,562 ms |
コンパイル使用メモリ | 258,600 KB |
最終ジャッジ日時 | 2025-02-17 16:10:16 |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#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'; } }