結果

問題 No.2687 所により大雨
ユーザー 沙耶花沙耶花
提出日時 2024-03-20 22:21:08
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 948 ms / 2,000 ms
コード長 5,166 bytes
コンパイル時間 4,431 ms
コンパイル使用メモリ 285,948 KB
実行使用メモリ 106,364 KB
最終ジャッジ日時 2024-09-30 13:59:41
合計ジャッジ時間 16,000 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#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
using P = pair<long long,long long>;
template <class S, S (*op)(S, S), S (*e)()> struct compressed_segtree {
segtree<S,op,e> seg;
compressed_segtree() : compressed_segtree(vector<long long>(0)) {
}
compressed_segtree(vector<long long> tx, vector<S> v){
_tx = tx;
seg = segtree<S,op,e>(v);
}
compressed_segtree(vector<long long> tx){
_tx = tx;
seg = segtree<S,op,e>(tx.size());
}
int lower_ind(long long p){
return distance(_tx.begin(),lower_bound(_tx.begin(),_tx.end(),p));
}
void set(long long p, S x) {
seg.set(lower_ind(p), x);
}
S get(long long p) {
int idx = lower_ind(p);
if(idx!=_tx.size()&&_tx[idx]==p)return seg.get(idx);
return e();
}
S prod(long long l,long long r) {
return seg.prod(lower_ind(l),lower_ind(r));
}
S all_prod() { return seg.all_prod(); }
vector<long long> _tx;
};
template <class S, S (*op)(S, S), S (*e)()> struct compressed_2d_segtree {
vector<compressed_segtree<S,op,e>> seg;
compressed_2d_segtree() : compressed_2d_segtree(vector<long long>(0)) {
}
/*
compressed_2d_segtree(vector<long long> tx, vector<S> v){
_tx = tx;
seg = segtree<S,op,e>(v);
}
*/
compressed_2d_segtree(vector<pair<long long,long long>> tp){
_tp = tp;
rep(i,tp.size()){
_tx.push_back(tp[i].first);
_ty.push_back(tp[i].second);
}
sort(_tx.begin(),_tx.end());
_tx.erase(unique(_tx.begin(),_tx.end()),_tx.end());
sort(_ty.begin(),_ty.end());
_ty.erase(unique(_ty.begin(),_ty.end()),_ty.end());
int n = _tx.size();
log = 0;
while((1LL<<log) < n){
log++;
}
size = 1<<log;
seg.resize(size*2);
vector<vector<long long>> ys(size*2);
rep(i,tp.size()){
ys[size + lower_indx(tp[i].first)].push_back(tp[i].second);
}
for(int i=size;i<size*2;i++){
sort(ys[i].begin(),ys[i].end());
ys[i].erase(unique(ys[i].begin(),ys[i].end()),ys[i].end());
seg[i] = compressed_segtree<S,op,e>(ys[i]);
}
for(int i=size-1;i>=1;i--){
vector<long long> a(ys[i*2].rbegin(),ys[i*2].rend()), b(ys[i*2+1].rbegin(),ys[i*2+1].rend());
while(a.size()>0||b.size()>0){
if(a.size()==0){
swap(a,b);
}
else if(b.size()>0){
if(a.back()>b.back())swap(a,b);
}
if(ys[i].size()==0||ys[i].back()!=a.back())ys[i].push_back(a.back());
a.pop_back();
}
seg[i] = compressed_segtree<S,op,e>(ys[i]);
ys[i*2].clear();
ys[i*2+1].clear();
}
}
int lower_indx(long long p){
return distance(_tx.begin(),lower_bound(_tx.begin(),_tx.end(),p));
}
int lower_indy(long long p){
return distance(_ty.begin(),lower_bound(_ty.begin(),_ty.end(),p));
}
void set(long long px, long long py, S x) {
px = lower_indx(px) + size;
seg[px].set(py,x);
for (int i = 1; i <= log; i++) update(px >> i, py);
}
S get(long long px, long long py) {
int idx = lower_indx(px);
if(idx!=_tx.size()&&_tx[idx]==px)return seg[idx+size].get(py);
return e();
}
S prod(long long lx,long long rx, long long ly, long long ry) {
S sml = e(), smr = e();
lx = lower_indx(lx)+size;
rx = lower_indx(rx)+size;
while (lx < rx) {
if (lx & 1) sml = op(sml, seg[lx++].prod(ly,ry));
if (rx & 1) smr = op(seg[--rx].prod(ly,ry), smr);
lx >>= 1;
rx >>= 1;
}
return op(sml, smr);
}
S all_prod() { return seg[1].all_prod(); }
int size, log;
vector<pair<long long,long long>> _tp;
vector<long long> _tx,_ty;
void update(int k, long long py) {
seg[k].set(py, op(seg[2*k].get(py), seg[2*k+1].get(py)));
}
};
long long op(long long a,long long b){
return a+b;
}
long long e(){
return 0;
}
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int N,M;
cin>>N>>M;
vector<P> i0(N),i1(M);
rep(i,N){
cin>>i0[i].first>>i0[i].second;
rep(j,4){
i0[i].first -= Inf32;
i0[i].second -= Inf32;
}
i0[i].first *= 2;
i0[i].second *= 2;
}
rep(i,M){
cin>>i1[i].first>>i1[i].second;
rep(j,4){
i1[i].first += Inf32;
i1[i].second += Inf32;
}
i1[i].first *= 2;
i1[i].second *= 2;
}
sort(i0.begin(),i0.end());
sort(i1.begin(),i1.end());
int K;
cin>>K;
vector<long long> p(K);
rep(i,K){
cin>>p[i];
p[i] *= 2;
}
rep(i,i0.size()){
if(i>=1 && i0[i].first <= i0[i-1].second){
rep(j,K){
if(j!=0)cout<<' ';
cout<<1;
}
cout<<endl;
return 0;
}
}
rep(i,i1.size()){
if(i>=1 && i1[i].first <= i1[i-1].second){
rep(j,K){
if(j!=0)cout<<' ';
cout<<1;
}
cout<<endl;
return 0;
}
}
compressed_2d_segtree<long long,op,e> seg(i0);
rep(i,N)seg.set(i0[i].first,i0[i].second,1);
vector<int> ans(K+1);
rep(i,K){
rep(j,M){
long long A = p[i] * 2 - i1[j].first;
long long B = p[i] * 2 - i1[j].second;
if(seg.prod(-Inf64,A+1,B,Inf64)>0){
ans[i] = 1;
}
}
}
rep(i,K){
if(i!=0)cout<<' ';
if(ans[i]>0)cout<<1;
else cout<<0;
}
cout<<endl;
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0