結果

問題 No.2687 所により大雨
ユーザー KKT89KKT89
提出日時 2024-03-20 22:59:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 129 ms / 2,000 ms
コード長 2,102 bytes
コンパイル時間 3,114 ms
コンパイル使用メモリ 222,096 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-20 22:59:24
合計ジャッジ時間 6,145 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}
inline double time() {
    return static_cast<long double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count()) * 1e-9;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,m; cin >> n >> m;
    vector<pair<ll,ll>> v(n), u(m);
    for (int i = 0; i < n; ++i) {
        cin >> v[i].first >> v[i].second;
    }
    for (int i = 0; i < m; ++i) {
        cin >> u[i].first >> u[i].second;
    }
    int k; cin >> k;
    vector<ll> pos(k);
    for (int i = 0; i < k; ++i) {
        cin >> pos[i];
    }
    sort(v.begin(), v.end());
    sort(u.begin(), u.end());
    bool ok = false;
    ll mx = v[0].second;
    for (int i = 1; i < n; ++i) {
        if (v[i].first <= mx) ok = true;
        mx = max(mx, v[i].second);
    }
    mx = u[0].second;
    for (int i = 1; i < m; ++i) {
        if (u[i].first <= mx) ok = true;
        mx = max(mx, u[i].second);
    }
    if (ok) {
        for (int i = 0; i < k; ++i) {
            cout << 1 << " ";
        }
        cout << "\n";
        return 0;
    }
    for (int i = 0; i < k; ++i) {
        ok = false;
        for (int j = 0; j < m and !ok; ++j) {
            ll l = u[j].first-pos[i];
            ll r = u[j].second-pos[i];
            if (l > r) swap(l, r);
            ll lx = pos[i]-r, rx = pos[i]-l;
            if (lx > rx) swap(lx, rx);
//            if (pos[i] == 2) {
//                cout << l << " " << r << " " << lx << " " << rx << endl;
//            }
            auto it = lower_bound(v.begin(), v.end(), pair<ll,ll>{rx+1, -2e9});
            if (it != v.begin()) {
                it--;
                auto p = *it;
                if (max(p.first, lx) <= min(p.second, rx)) {
                    ok = true;
                }
            }
        }
        cout << ok << " ";
    }
    cout << endl;
}
0