結果
問題 | No.2520 L1 Explosion |
ユーザー | SSRS |
提出日時 | 2023-10-27 21:49:01 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,896 bytes |
コンパイル時間 | 2,357 ms |
コンパイル使用メモリ | 217,212 KB |
実行使用メモリ | 38,784 KB |
最終ジャッジ日時 | 2024-09-25 13:54:26 |
合計ジャッジ時間 | 4,475 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
ソースコード
#include <bits/stdc++.h> using namespace std; const long long MOD = 998244353; const long long HALF = 499122177; int main(){ int N, M; cin >> N >> M; vector<long long> X(N), Y(N), H(N); for (int i = 0; i < N; i++){ cin >> X[i] >> Y[i] >> H[i]; } for (int i = 0; i < N; i++){ tie(X[i], Y[i]) = make_pair(X[i] + Y[i], X[i] - Y[i]); } vector<long long> X2, Y2; for (int i = 0; i < N; i++){ X2.push_back(X[i] - (M - H[i])); X2.push_back(X[i] + (M - H[i])); Y2.push_back(Y[i] - (M - H[i])); Y2.push_back(Y[i] + (M - H[i])); } sort(X2.begin(), X2.end()); sort(Y2.begin(), Y2.end()); X2.erase(unique(X2.begin(), X2.end()), X2.end()); Y2.erase(unique(Y2.begin(), Y2.end()), Y2.end()); int h = X2.size(); int w = Y2.size(); vector<vector<int>> imos(h, vector<int>(w, 0)); for (int i = 0; i < N; i++){ int x1 = lower_bound(X2.begin(), X2.end(), X[i] - (M - H[i])) - X2.begin(); int x2 = lower_bound(X2.begin(), X2.end(), X[i] + (M - H[i])) - X2.begin(); int y1 = lower_bound(Y2.begin(), Y2.end(), Y[i] - (M - H[i])) - Y2.begin(); int y2 = lower_bound(Y2.begin(), Y2.end(), Y[i] + (M - H[i])) - Y2.begin(); imos[x1][y1]++; imos[x1][y2]--; imos[x2][y1]--; imos[x2][y2]++; } for (int i = 0; i < h; i++){ for (int j = 1; j < w; j++){ imos[i][j] += imos[i][j - 1]; } } for (int i = 1; i < h; i++){ for (int j = 0; j < w; j++){ imos[i][j] += imos[i - 1][j]; } } vector<long long> ans(N + 1, 0); for (int i = 0; i < h - 1; i++){ for (int j = 0; j < w - 1; j++){ if (imos[i][j] > 0){ long long dx = (X2[i + 1] - X2[i]) % MOD; long long dy = (Y2[j + 1] - Y2[j]) % MOD; ans[imos[i][j]] += dx * dy % MOD * HALF % MOD; ans[imos[i][j]] %= MOD; } } } cout << endl; for (int i = 1; i <= N; i++){ cout << ans[i] << endl; } }