結果

問題 No.2520 L1 Explosion
ユーザー MasKoaTSMasKoaTS
提出日時 2023-10-05 11:50:29
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 969 ms / 2,000 ms
コード長 1,524 bytes
コンパイル時間 2,509 ms
コンパイル使用メモリ 216,992 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-10-05 11:50:39
合計ジャッジ時間 9,224 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 294 ms
4,380 KB
testcase_07 AC 41 ms
4,376 KB
testcase_08 AC 352 ms
4,380 KB
testcase_09 AC 969 ms
4,384 KB
testcase_10 AC 409 ms
4,376 KB
testcase_11 AC 409 ms
4,376 KB
testcase_12 AC 405 ms
4,376 KB
testcase_13 AC 515 ms
4,380 KB
testcase_14 AC 513 ms
4,380 KB
testcase_15 AC 16 ms
4,380 KB
testcase_16 AC 382 ms
4,380 KB
testcase_17 AC 230 ms
4,380 KB
testcase_18 AC 232 ms
4,376 KB
testcase_19 AC 193 ms
4,380 KB
testcase_20 AC 4 ms
4,380 KB
testcase_21 AC 252 ms
4,384 KB
testcase_22 AC 24 ms
4,380 KB
testcase_23 AC 13 ms
4,380 KB
testcase_24 AC 207 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define MOD 998244353ll
using namespace std;
using ll = long long;

ll powmod(ll a, ll n){
    ll ret = 1;
    while(n){
        if (n & 1) {
            ret = ret * a % MOD;
        }
        a = a * a % MOD;
        n >>= 1;
    }
    return ret;
}
const ll INV2 = powmod(2, MOD - 2);


int main(void){
    ll n, m;  cin >> n >> m;
    vector<tuple<ll, ll, ll> > mons(n, tuple<ll, ll, ll>({}));
    for(auto&[x, y, d] : mons){
        ll x_tmp, y_tmp, h;  cin >> x_tmp >> y_tmp >> h;
        x = x_tmp - y_tmp;  y = x_tmp + y_tmp;  d = m - h;
    }

    vector<tuple<ll, ll, ll> > imos = {};
    for(auto&[x, y, d] : mons){
        imos.push_back({x - d, y - d, 1});
        imos.push_back({x + d, y - d, -1});
        imos.push_back({x - d, y + d, -1});
        imos.push_back({x + d, y + d, 1});
    }
    sort(imos.begin(), imos.end());

    vector<ll> area(n + 1);
    vector<pair<ll, ll> > col_nows = {};
    ll x_now = -(ll)1e18;
    for(auto&[x, y, c] : imos){
        if(x_now != x){
            sort(col_nows.begin(), col_nows.end());
            ll cnt = 0;
            for(int i = 0; i < (int)col_nows.size() - 1; ++i){
                cnt += col_nows[i].second;
                area[cnt] += (col_nows[i + 1].first - col_nows[i].first) % MOD * (x - x_now) % MOD;
            }
            x_now = x;
        }
        col_nows.push_back({y, c});
    }

    for(int i = 1; i < n + 1; ++i){
        ll ans = area[i] % MOD * INV2 % MOD;
        cout << ans << endl;
    }

    return 0;
}
0