結果
問題 | No.2520 L1 Explosion |
ユーザー | pointN |
提出日時 | 2023-10-28 00:31:55 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 124 ms / 2,000 ms |
コード長 | 2,043 bytes |
コンパイル時間 | 3,263 ms |
コンパイル使用メモリ | 203,228 KB |
実行使用メモリ | 74,136 KB |
最終ジャッジ日時 | 2023-10-28 00:32:02 |
合計ジャッジ時間 | 5,740 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,348 KB |
testcase_01 | AC | 1 ms
4,348 KB |
testcase_02 | AC | 1 ms
4,348 KB |
testcase_03 | AC | 1 ms
4,348 KB |
testcase_04 | AC | 1 ms
4,348 KB |
testcase_05 | AC | 1 ms
4,348 KB |
testcase_06 | AC | 119 ms
74,136 KB |
testcase_07 | AC | 36 ms
21,628 KB |
testcase_08 | AC | 120 ms
74,136 KB |
testcase_09 | AC | 124 ms
74,136 KB |
testcase_10 | AC | 120 ms
74,136 KB |
testcase_11 | AC | 118 ms
74,136 KB |
testcase_12 | AC | 118 ms
74,136 KB |
testcase_13 | AC | 118 ms
74,136 KB |
testcase_14 | AC | 119 ms
74,136 KB |
testcase_15 | AC | 6 ms
6,248 KB |
testcase_16 | AC | 85 ms
54,072 KB |
testcase_17 | AC | 53 ms
35,592 KB |
testcase_18 | AC | 68 ms
36,912 KB |
testcase_19 | AC | 48 ms
30,840 KB |
testcase_20 | AC | 3 ms
4,628 KB |
testcase_21 | AC | 77 ms
50,376 KB |
testcase_22 | AC | 10 ms
8,664 KB |
testcase_23 | AC | 6 ms
6,652 KB |
testcase_24 | AC | 66 ms
43,248 KB |
ソースコード
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <functional> #include <cmath> #include <iomanip> #include <stack> #include <queue> #include <numeric> #include <map> #include <unordered_map> #include <set> #include <fstream> #include <chrono> #include <random> #include <bitset> #include <atcoder/all> #define rep(i,n) for(int i=0;i<(n);i++) #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define sz(x) ((int)(x).size()) #define pb push_back using ll = long long; using namespace std; template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;} ll lcm(ll a, ll b) {return a/gcd(a,b)*b;} const ll mod = 998244353; int main(){ ll N,M; cin >> N >> M; vector<ll> X(N), Y(N), H(N); rep(i,N) cin >> X[i] >> Y[i] >> H[i]; vector<vector<pair<pair<ll,ll>,pair<ll,ll>>>> dp(N+1); set<ll> Us,Vs; rep(i,N){ ll d = M-H[i]; ll s = X[i]+Y[i]; ll m = X[i]-Y[i]; Us.insert(s+d); Us.insert(s-d); Vs.insert(m+d); Vs.insert(m-d); } vector<ll> U,V; for(auto u:Us){ U.pb(u); } for(auto v:Vs){ V.pb(v); } int A = sz(U), B = sz(V); vector<vector<ll>> S(A,vector<ll>(B,0)); rep(i,N){ ll d = M-H[i]; ll s = X[i]+Y[i]; ll m = X[i]-Y[i]; int a1 = lower_bound(all(U),s-d)-U.begin(); int a2 = lower_bound(all(U),s+d)-U.begin(); int b1 = lower_bound(all(V),m-d)-V.begin(); int b2 = lower_bound(all(V),m+d)-V.begin(); S[a1][b1]++; S[a1][b2]--; S[a2][b1]--; S[a2][b2]++; } rep(i,A) rep(j,B-1) S[i][j+1]+=S[i][j]; rep(i,A-1) rep(j,B) S[i+1][j]+=S[i][j]; vector<ll> ans(N+1,0); rep(i,A-1){ rep(j,B-1){ ans[S[i][j]] += ((U[i+1]-U[i])%mod) * ((V[j+1]-V[j])%mod) % mod; ans[S[i][j]] %= mod; } } rep(i,N){ if(ans[i+1]%2) ans[i+1] += mod; ans[i+1] /= 2; cout << ans[i+1] % mod << '\n'; } return 0; }