結果

問題 No.2687 所により大雨
ユーザー RubikunRubikun
提出日時 2024-03-20 21:56:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 450 ms / 2,000 ms
コード長 2,054 bytes
コンパイル時間 2,710 ms
コンパイル使用メモリ 213,240 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2024-03-20 21:56:31
合計ジャッジ時間 8,639 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
6,548 KB
testcase_01 AC 33 ms
6,548 KB
testcase_02 AC 34 ms
6,548 KB
testcase_03 AC 33 ms
6,548 KB
testcase_04 AC 33 ms
6,548 KB
testcase_05 AC 2 ms
6,548 KB
testcase_06 AC 2 ms
6,548 KB
testcase_07 AC 2 ms
6,548 KB
testcase_08 AC 2 ms
6,548 KB
testcase_09 AC 2 ms
6,548 KB
testcase_10 AC 438 ms
6,548 KB
testcase_11 AC 449 ms
6,548 KB
testcase_12 AC 450 ms
6,548 KB
testcase_13 AC 440 ms
6,548 KB
testcase_14 AC 435 ms
6,548 KB
testcase_15 AC 436 ms
6,548 KB
testcase_16 AC 427 ms
6,548 KB
testcase_17 AC 440 ms
6,548 KB
testcase_18 AC 437 ms
6,548 KB
testcase_19 AC 436 ms
6,548 KB
testcase_20 AC 2 ms
6,548 KB
testcase_21 AC 2 ms
6,548 KB
testcase_22 AC 2 ms
6,548 KB
testcase_23 AC 2 ms
6,548 KB
testcase_24 AC 4 ms
6,548 KB
testcase_25 AC 4 ms
6,548 KB
testcase_26 AC 4 ms
6,548 KB
testcase_27 AC 4 ms
6,548 KB
testcase_28 AC 4 ms
6,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}

0