結果

問題 No.2520 L1 Explosion
ユーザー baluteshihbaluteshih
提出日時 2023-10-27 23:14:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,628 bytes
コンパイル時間 2,509 ms
コンパイル使用メモリ 215,596 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-27 23:14:19
合計ジャッジ時間 9,153 ms
ジャッジサーバーID
(参考情報)
judge10 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 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 396 ms
4,348 KB
testcase_07 WA -
testcase_08 AC 357 ms
4,348 KB
testcase_09 AC 62 ms
4,348 KB
testcase_10 AC 613 ms
4,348 KB
testcase_11 AC 616 ms
4,348 KB
testcase_12 AC 616 ms
4,348 KB
testcase_13 AC 388 ms
4,348 KB
testcase_14 AC 395 ms
4,348 KB
testcase_15 AC 14 ms
4,348 KB
testcase_16 AC 276 ms
4,348 KB
testcase_17 AC 164 ms
4,348 KB
testcase_18 AC 179 ms
4,348 KB
testcase_19 AC 146 ms
4,348 KB
testcase_20 AC 7 ms
4,348 KB
testcase_21 AC 388 ms
4,348 KB
testcase_22 AC 40 ms
4,348 KB
testcase_23 AC 22 ms
4,348 KB
testcase_24 AC 331 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define X first
#define Y second
#define SZ(a) ((int)a.size())
#define ALL(v) v.begin(), v.end()
#define pb push_back

const int MOD = 998244353;
const int TWO = (MOD + 1) / 2;
pll operator+(const pll &a, const pll &b) { return pll(a.X + b.X, a.Y + b.Y); }
pll perp(const pll &a) { return pll(-a.Y, a.X); }
ll cross(const pll &a, const pll &b) { return a.X * b.Y - a.Y * b.X; }

pll arr[1505];
int health[1505];
ll sum[1505];

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i].X >> arr[i].Y >> health[i];
        auto [x, y] = arr[i];
        arr[i] = pll(x + y, x - y);
    }

    vector<vector<pll>> poly(n);
    
    auto solve = [&]() {
        for (int i = 0; i < n; ++i)
            for (int a = 0; a < 4; a += 2) {
                pll A = poly[i][a], B = poly[i][(a + 1) % 4];
                assert(A.Y == B.Y);
                int sgn = 1;
                if (A.X > B.X) swap(A, B), sgn = -1;
                vector<pll> segs = {{A.X, 0}, {B.X, 0}};
                for (int j = 0; j < n; ++j) {
                    if (i == j) continue;
                    auto [yl, yr] = minmax(poly[j][0].Y, poly[j][2].Y);
                    if (clamp(A.Y, yl, yr) == A.Y) {
                        auto [xl, xr] = minmax(poly[j][0].X, poly[j][2].X);
                        segs.pb(pll(xl, 1));
                        segs.pb(pll(xr, -1));
                    }
                }
                sort(ALL(segs));
                for (auto &s : segs) s.X = clamp(s.X, A.X, B.X);
                int cnt = segs[0].second + 1;
                for (int j = 1; j < SZ(segs); ++j) {
                    if (cnt > 0) {
                        sum[cnt] += cross(pll(segs[j - 1].X, A.Y), pll(segs[j].X, A.Y)) * sgn;
                    }
                    cnt += segs[j].Y;
                }
            }
    };

    for (int i = 0; i < n; ++i) {
        health[i] = m - health[i];
        poly[i].pb(arr[i] + pll(-health[i], -health[i]));
        poly[i].pb(arr[i] + pll(health[i], -health[i]));
        poly[i].pb(arr[i] + pll(health[i], health[i]));
        poly[i].pb(arr[i] + pll(-health[i], health[i]));
    }
    solve();
    for (int i = 0; i < n; ++i) {
        for (auto &p : poly[i])
            p = perp(p);
        rotate(poly[i].begin(), poly[i].begin() + 1, poly[i].end());
    }
    solve();

    for (int i = 1; i <= n; ++i)
        cout << (sum[i] - sum[i + 1]) % MOD * TWO % MOD * TWO % MOD << "\n";
}
0