結果
問題 | No.2520 L1 Explosion |
ユーザー | Kude |
提出日時 | 2023-10-27 22:59:45 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 104 ms / 2,000 ms |
コード長 | 2,521 bytes |
コンパイル時間 | 4,476 ms |
コンパイル使用メモリ | 286,408 KB |
実行使用メモリ | 38,632 KB |
最終ジャッジ日時 | 2023-10-27 22:59:52 |
合計ジャッジ時間 | 6,020 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,372 KB |
testcase_01 | AC | 2 ms
4,372 KB |
testcase_02 | AC | 1 ms
4,372 KB |
testcase_03 | AC | 2 ms
4,372 KB |
testcase_04 | AC | 2 ms
4,372 KB |
testcase_05 | AC | 1 ms
4,372 KB |
testcase_06 | AC | 79 ms
38,632 KB |
testcase_07 | AC | 22 ms
12,232 KB |
testcase_08 | AC | 89 ms
38,632 KB |
testcase_09 | AC | 44 ms
38,632 KB |
testcase_10 | AC | 88 ms
38,632 KB |
testcase_11 | AC | 89 ms
38,632 KB |
testcase_12 | AC | 90 ms
38,632 KB |
testcase_13 | AC | 104 ms
38,632 KB |
testcase_14 | AC | 89 ms
38,632 KB |
testcase_15 | AC | 5 ms
4,576 KB |
testcase_16 | AC | 63 ms
28,600 KB |
testcase_17 | AC | 39 ms
19,360 KB |
testcase_18 | AC | 41 ms
19,888 KB |
testcase_19 | AC | 34 ms
16,984 KB |
testcase_20 | AC | 2 ms
4,372 KB |
testcase_21 | AC | 58 ms
26,752 KB |
testcase_22 | AC | 8 ms
5,896 KB |
testcase_23 | AC | 5 ms
4,840 KB |
testcase_24 | AC | 50 ms
23,320 KB |
ソースコード
#include<bits/stdc++.h> namespace { #pragma GCC diagnostic ignored "-Wunused-function" #include<atcoder/all> #pragma GCC diagnostic warning "-Wunused-function" using namespace std; using namespace atcoder; #define rep(i,n) for(int i = 0; i < (int)(n); i++) #define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--) #define all(x) begin(x), end(x) #define rall(x) rbegin(x), rend(x) template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; } template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; } using ll = long long; using P = pair<int,int>; using VI = vector<int>; using VVI = vector<VI>; using VL = vector<ll>; using VVL = vector<VL>; using mint = modint998244353; template <class S> struct value_compression : vector<S> { bool built = false; using VS = vector<S>; using VS::VS; value_compression(vector<S> v) : vector<S>(move(v)) {} void build() { 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(0); int n, m; cin >> n >> m; struct S { ll xl, xr, yl, yr; }; vector<S> sq(n); rep(i, n) { ll x, y, h; cin >> x >> y >> h; ll rad = m - h; ll x1 = x - rad, y1 = y; ll x2 = x + rad, y2 = y; sq[i] = {x1 - y1, x2 - y2, x1 + y1, x2 + y2}; } value_compression<ll> vcx, vcy; for (auto [xl, xr, yl, yr] : sq) { vcx.emplace_back(xl); vcx.emplace_back(xr); vcy.emplace_back(yl); vcy.emplace_back(yr); } vcx.build(); vcy.build(); int h = vcx.size(), w = vcy.size(); VVI d(h, VI(w)); for (auto [xl, xr, yl, yr] : sq) { xl = vcx(xl); xr = vcx(xr); yl = vcy(yl); yr = vcy(yr); d[xl][yl]++; d[xl][yr]--; d[xr][yl]--; 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); const mint inv2 = mint(2).inv(); rep(i, h) rep(j, w) if (d[i][j]) { ans[d[i][j]] += mint(vcx[i+1] - vcx[i]) * (vcy[j+1] - vcy[j]) * inv2; } for (int i = 1; i <= n; i++) cout << ans[i].val() << '\n'; }