結果
問題 | No.2687 所により大雨 |
ユーザー |
![]() |
提出日時 | 2024-03-20 21:56:22 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 456 ms / 2,000 ms |
コード長 | 2,054 bytes |
コンパイル時間 | 2,560 ms |
コンパイル使用メモリ | 205,728 KB |
最終ジャッジ日時 | 2025-02-20 09:05:45 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 25 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; } #define all(x) (x).begin(),(x).end() #define fi first #define se second #define mp make_pair #define si(x) int(x.size()) const int mod=998244353,MAX=300005,INF=1<<30; int main(){ std::ifstream in("text.txt"); std::cin.rdbuf(in.rdbuf()); cin.tie(0); ios::sync_with_stdio(false); int N,M;cin>>N>>M; vector<pair<ll,ll>> S(N),T(M); for(int i=0;i<N;i++){ cin>>S[i].fi>>S[i].se; } for(int i=0;i<M;i++){ cin>>T[i].fi>>T[i].se; } sort(all(S)); sort(all(T)); int K;cin>>K; vector<ll> U(K); for(int i=0;i<K;i++){ cin>>U[i]; } for(int i=0;i+1<N;i++){ if(S[i].se>=S[i+1].fi){ for(int j=0;j<K;j++){ cout<<1<<" "; } cout<<endl; return 0; } } for(int i=0;i+1<M;i++){ if(T[i].se>=T[i+1].fi){ for(int j=0;j<K;j++){ cout<<1<<" "; } cout<<endl; return 0; } } for(ll u:U){ bool ans=false; vector<pair<ll,ll>> A(N+2); A[0]=mp(1LL<<60,1LL<<60); for(int i=0;i<N;i++){ A[i+1]=mp(u-S[i].se,u-S[i].fi); } A[N+1]=mp(-(1LL<<60),-(1LL<<60)); reverse(all(A)); for(auto [c,d]:T){ ll L=c-u,R=d-u; auto it=lower_bound(all(A),mp(L,-(1LL<<60))); it--; { auto [l,r]=*it; if(max(l,L)<=min(r,R)) ans=true; } it++; { auto [l,r]=*it; if(max(l,L)<=min(r,R)) ans=true; } } if(ans) cout<<1<<" "; else cout<<0<<" "; } cout<<endl; }