結果
問題 | No.2520 L1 Explosion |
ユーザー | baluteshih |
提出日時 | 2023-10-28 01:49:21 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,350 bytes |
コンパイル時間 | 2,345 ms |
コンパイル使用メモリ | 218,344 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-25 15:55:24 |
合計ジャッジ時間 | 9,350 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,944 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | AC | 2 ms
6,940 KB |
testcase_04 | AC | 2 ms
6,940 KB |
testcase_05 | AC | 2 ms
6,944 KB |
testcase_06 | AC | 420 ms
6,940 KB |
testcase_07 | AC | 384 ms
6,940 KB |
testcase_08 | AC | 422 ms
6,944 KB |
testcase_09 | AC | 172 ms
6,940 KB |
testcase_10 | AC | 672 ms
6,944 KB |
testcase_11 | AC | 672 ms
6,944 KB |
testcase_12 | AC | 683 ms
6,944 KB |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | AC | 9 ms
6,944 KB |
testcase_21 | WA | - |
testcase_22 | AC | 45 ms
6,944 KB |
testcase_23 | AC | 26 ms
6,944 KB |
testcase_24 | AC | 368 ms
6,944 KB |
ソースコード
#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 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; } ll dot(const pll &a, const pll &b) { return a.X * b.X + a.Y * b.Y; } int sign(const ll &a) { return a == 0 ? 0 : a > 0 ? 1 : -1; } int ori(const pll &a, const pll &b, const pll &c) { return sign(cross(b - a, c - a)); } pll arr[1505]; int health[1505]; __int128 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 itvsgn = [&](int l, int r) { return l < r ? 1 : -1; }; 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 = itvsgn(A.X, B.X); vector<pll> segs = {{A.X, 0}, {B.X, 0}}; for (int j = 0; j < n; ++j) { if (i == j) continue; for (int b = 0; b < 4; ++b) { pll C = poly[j][b], D = poly[j][(b + 1) % 4]; int sc = ori(A, B, C), sd = ori(A, B, D); if (sc != sd && min(sc, sd) < 0) { segs.pb(pll(C.X, sign(sc - sd))); } if (!sc && !sd && i < j && sign(dot(B - A, D - C)) > 0) { segs.pb(pll(C.X, 1)); segs.pb(pll(D.X, -1)); } } } if (sgn == 1) sort(ALL(segs)); else sort(ALL(segs), greater<>()); for (auto &s : segs) s.X = clamp(s.X, min(A.X, B.X), max(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)); } 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 << (ll)((sum[i] - sum[i + 1]) % MOD) * TWO % MOD * TWO % MOD << "\n"; }