結果

問題 No.2520 L1 Explosion
ユーザー 👑 kmjpkmjp
提出日時 2023-10-27 23:33:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,746 bytes
コンパイル時間 2,638 ms
コンパイル使用メモリ 218,256 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-27 23:33:27
合計ジャッジ時間 4,344 ms
ジャッジサーバーID
(参考情報)
judge15 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 51 ms
4,348 KB
testcase_07 AC 17 ms
4,348 KB
testcase_08 AC 50 ms
4,348 KB
testcase_09 AC 81 ms
4,348 KB
testcase_10 AC 49 ms
4,348 KB
testcase_11 AC 50 ms
4,348 KB
testcase_12 AC 49 ms
4,348 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 3 ms
4,348 KB
testcase_21 AC 34 ms
4,348 KB
testcase_22 AC 6 ms
4,348 KB
testcase_23 AC 5 ms
4,348 KB
testcase_24 AC 30 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
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(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

int N;
ll M;
ll X[3030],Y[3030],H[3030];
ll L[3030],R[3030],D[3030],U[3030];
ll ret[3030];
int dp[3030];
const ll mo=998244353;
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	map<ll,vector<int>> ev;
	vector<ll> Ys;
	FOR(i,N) {
		cin>>X[i]>>Y[i]>>H[i];
		L[i]=(X[i]-Y[i])-(M-H[i]);
		R[i]=(X[i]-Y[i])+(M-H[i]);
		D[i]=(X[i]+Y[i])-(M-H[i]);
		U[i]=(X[i]+Y[i])+(M-H[i]);
		Ys.push_back(D[i]);
		Ys.push_back(U[i]);
	}
	sort(ALL(Ys));
	Ys.erase(unique(ALL(Ys)),Ys.end());
	FOR(i,N) {
		D[i]=lower_bound(ALL(Ys),D[i])-Ys.begin();
		U[i]=lower_bound(ALL(Ys),U[i])-Ys.begin();
		ev[L[i]].push_back(i);
		ev[R[i]].push_back(i);
	}
	int pre=0;
	FORR2(x,e,ev) {
		FOR(y,Ys.size()-1) {
			(ret[dp[y]]+=1LL*(Ys[y+1]-Ys[y])%mo*((x-pre)%mo))%=mo;
		}
		FORR(i,e) if(R[i]==x) {
			for(y=D[i];y<U[i];y++) dp[y]--;
		}
		FORR(i,e) if(L[i]==x) {
			for(y=D[i];y<U[i];y++) dp[y]++;
		}
		pre=x;
	}
	for(i=1;i<=N;i++) cout<<ret[i]*(mo+1)/2%mo<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0