結果
問題 | No.2520 L1 Explosion |
ユーザー | 沙耶花 |
提出日時 | 2023-10-27 22:29:27 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 4,460 bytes |
コンパイル時間 | 4,503 ms |
コンパイル使用メモリ | 277,672 KB |
実行使用メモリ | 74,240 KB |
最終ジャッジ日時 | 2024-09-25 14:31:53 |
合計ジャッジ時間 | 9,702 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
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 <stdio.h> #include <atcoder/all> #include <bits/stdc++.h> using namespace std; using namespace atcoder; using mint = modint998244353; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf32 1000000001 #define Inf64 4000000000000000001 int main(){ long long N,M; cin>>N>>M; vector<long long> x(N),y(N),h(N); rep(i,N){ cin>>x[i]>>y[i]>>h[i]; long long t = x[i]; long long s = y[i]; x[i] = t+s; y[i] = t-s; } vector<pair<long long,long long>> a,b,c,d; vector<pair<long long,long long>> tx,ty; rep(i,N){ if(h[i]>M)continue; long long rem = M - h[i]; a.emplace_back(-rem,x[i]); b.emplace_back(rem,x[i]); c.emplace_back(-rem,y[i]); d.emplace_back(rem,y[i]); tx.emplace_back(-rem,x[i]); tx.emplace_back(rem,x[i]); ty.emplace_back(-rem,y[i]); ty.emplace_back(rem,y[i]); } //tx.emplace_back(Inf32,Inf32); //ty.emplace_back(Inf32,Inf32); sort(tx.begin(),tx.end(),[&](pair<long long,long long> x,pair<long long,long long> y){ long long A = x.first-y.first; long long B = y.second-x.second; if(A*B<=0)return A<B; if(A>0){ return (x.first-y.first)*(x.first-y.first) < (y.second-x.second) * (y.second-x.second) * 2LL; } else{ return (x.first-y.first)*(x.first-y.first) > (y.second-x.second) * (y.second-x.second) * 2LL; } }); sort(ty.begin(),ty.end(),[&](pair<long long,long long> x,pair<long long,long long> y){ long long A = x.first-y.first; long long B = y.second-x.second; if(A*B<=0)return A<B; if(A>0){ return (x.first-y.first)*(x.first-y.first) < (y.second-x.second) * (y.second-x.second) * 2LL; } else{ return (x.first-y.first)*(x.first-y.first) > (y.second-x.second) * (y.second-x.second) * 2LL; } }); /* rep(i,tx.size()){ cout<<tx[i].first<<' '<<tx[i].second<<endl; } */ vector imos(tx.size()+1,vector<long long>(ty.size()+1)); rep(i,a.size()){ int aa = distance(tx.begin(),lower_bound(tx.begin(),tx.end(),a[i], [&](pair<long long,long long> x,pair<long long,long long> y){ long long A = x.first-y.first; long long B = y.second-x.second; if(A*B<=0)return A<B; if(A>0){ return (x.first-y.first)*(x.first-y.first) < (y.second-x.second) * (y.second-x.second) * 2LL; } else{ return (x.first-y.first)*(x.first-y.first) > (y.second-x.second) * (y.second-x.second) * 2LL; } })); int bb = distance(tx.begin(),upper_bound(tx.begin(),tx.end(),b[i], [&](pair<long long,long long> x,pair<long long,long long> y){ long long A = x.first-y.first; long long B = y.second-x.second; if(A*B<=0)return A<B; if(A>0){ return (x.first-y.first)*(x.first-y.first) < (y.second-x.second) * (y.second-x.second) * 2LL; } else{ return (x.first-y.first)*(x.first-y.first) > (y.second-x.second) * (y.second-x.second) * 2LL; } })); int cc = distance(ty.begin(),lower_bound(ty.begin(),ty.end(),c[i], [&](pair<long long,long long> x,pair<long long,long long> y){ long long A = x.first-y.first; long long B = y.second-x.second; if(A*B<=0)return A<B; if(A>0){ return (x.first-y.first)*(x.first-y.first) < (y.second-x.second) * (y.second-x.second) * 2LL; } else{ return (x.first-y.first)*(x.first-y.first) > (y.second-x.second) * (y.second-x.second) * 2LL; } })); int dd = distance(ty.begin(),upper_bound(ty.begin(),ty.end(),d[i], [&](pair<long long,long long> x,pair<long long,long long> y){ long long A = x.first-y.first; long long B = y.second-x.second; if(A*B<=0)return A<B; if(A>0){ return (x.first-y.first)*(x.first-y.first) < (y.second-x.second) * (y.second-x.second) * 2LL; } else{ return (x.first-y.first)*(x.first-y.first) > (y.second-x.second) * (y.second-x.second) * 2LL; } })); imos[aa][cc]++; imos[aa][dd]--; imos[bb][cc]--; imos[bb][dd]++; } rep(i,tx.size()){ rep(j,ty.size()+1)imos[i+1][j] += imos[i][j]; } rep(i,tx.size()+1){ rep(j,ty.size())imos[i][j+1] += imos[i][j]; } vector<mint> ans(N+1); rep(i,tx.size()-1){ rep(j,ty.size()-1){ int num = imos[i][j]; if(num!=2)continue; cout<<tx[i].first<<' '<<tx[i].second<<endl; cout<<tx[i+1].first<<' '<<tx[i+1].second<<endl; cout<<ty[j].first<<' '<<ty[j].second<<endl; cout<<ty[j+1].first<<' '<<ty[j+1].second<<endl; cout<<endl; ans[num] += mint(2).inv() *(tx[i+1].first - tx[i].first) * (ty[j+1].first -ty[j].first); ans[num] += (tx[i+1].second - tx[i].second) * (ty[j+1].second -ty[j].second); } } for(int i=1;i<=N;i++){ cout<<ans[i].val()<<endl; } return 0; }