結果
| 問題 |
No.2520 L1 Explosion
|
| コンテスト | |
| ユーザー |
kmjp
|
| 提出日時 | 2023-10-27 23:33:23 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,746 bytes |
| コンパイル時間 | 2,308 ms |
| コンパイル使用メモリ | 210,628 KB |
| 最終ジャッジ日時 | 2025-02-17 16:06:59 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 15 WA * 7 |
ソースコード
#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;
}
kmjp