結果

問題 No.2520 L1 Explosion
ユーザー cho435cho435
提出日時 2023-10-30 21:47:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 323 ms / 2,000 ms
コード長 1,386 bytes
コンパイル時間 4,762 ms
コンパイル使用メモリ 271,896 KB
実行使用メモリ 82,864 KB
最終ジャッジ日時 2023-10-30 21:47:27
合計ジャッジ時間 9,641 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 286 ms
82,864 KB
testcase_07 AC 244 ms
82,864 KB
testcase_08 AC 296 ms
82,864 KB
testcase_09 AC 231 ms
82,864 KB
testcase_10 AC 297 ms
82,864 KB
testcase_11 AC 297 ms
82,864 KB
testcase_12 AC 298 ms
82,864 KB
testcase_13 AC 323 ms
82,864 KB
testcase_14 AC 297 ms
82,864 KB
testcase_15 AC 13 ms
6,528 KB
testcase_16 AC 213 ms
60,160 KB
testcase_17 AC 137 ms
39,304 KB
testcase_18 AC 142 ms
40,888 KB
testcase_19 AC 117 ms
34,288 KB
testcase_20 AC 6 ms
4,724 KB
testcase_21 AC 200 ms
55,936 KB
testcase_22 AC 25 ms
9,208 KB
testcase_23 AC 14 ms
6,976 KB
testcase_24 AC 168 ms
48,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using mint = atcoder::modint998244353;

int main(){
	ll n,m;
	cin>>n>>m;
	vector<ll> x(n),y(n),h(n);
	rep(i,n) cin>>x.at(i)>>y.at(i)>>h.at(i);
	vector<ll> a(n),b(n);
	rep(i,n){
		a.at(i)=x.at(i)+y.at(i);
		b.at(i)=x.at(i)-y.at(i);
	}
	auto ca=a,cb=b;
	rep(i,n){
		ca.push_back(a.at(i)-(m-h.at(i)));
		ca.push_back(a.at(i)+(m-h.at(i)));
		cb.push_back(b.at(i)-(m-h.at(i)));
		cb.push_back(b.at(i)+(m-h.at(i)));
	}
	sort(ca.begin(),ca.end());
	sort(cb.begin(),cb.end());
	int l=ca.size();
	vector<vector<int>> vn(l+1,vector<int>(l+1,0));
	rep(i,n){
		int la=lower_bound(ca.begin(),ca.end(),a.at(i)-(m-h.at(i)))-ca.begin();
		int ua=lower_bound(ca.begin(),ca.end(),a.at(i)+(m-h.at(i)))-ca.begin();
		int lb=lower_bound(cb.begin(),cb.end(),b.at(i)-(m-h.at(i)))-cb.begin();
		int ub=lower_bound(cb.begin(),cb.end(),b.at(i)+(m-h.at(i)))-cb.begin();
		vn.at(la).at(lb)++;
		vn.at(la).at(ub)--;
		vn.at(ua).at(lb)--;
		vn.at(ua).at(ub)++;
	}
	rep(i,l+1) rep(j,l) vn.at(i).at(j+1)+=vn.at(i).at(j);
	rep(i,l) rep(j,l+1) vn.at(i+1).at(j)+=vn.at(i).at(j);
	vector<mint> ans(n);
	rep(i,l){
		rep(j,l){
			if(vn.at(i).at(j)==0) continue;
			ans.at(vn.at(i).at(j)-1)+=(ca.at(i+1)-ca.at(i))*(cb.at(j+1)-cb.at(j));
		}
	}
	rep(i,n) cout<<(ans.at(i)/2).val()<<endl;
}
0