結果

問題 No.2687 所により大雨
ユーザー てんぷらてんぷら
提出日時 2024-03-20 22:23:45
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 72 ms / 2,000 ms
コード長 1,725 bytes
コンパイル時間 5,949 ms
コンパイル使用メモリ 313,860 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-20 22:23:54
合計ジャッジ時間 7,965 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
6,676 KB
testcase_01 AC 35 ms
6,676 KB
testcase_02 AC 35 ms
6,676 KB
testcase_03 AC 35 ms
6,676 KB
testcase_04 AC 35 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 71 ms
6,676 KB
testcase_11 AC 71 ms
6,676 KB
testcase_12 AC 71 ms
6,676 KB
testcase_13 AC 71 ms
6,676 KB
testcase_14 AC 71 ms
6,676 KB
testcase_15 AC 71 ms
6,676 KB
testcase_16 AC 72 ms
6,676 KB
testcase_17 AC 71 ms
6,676 KB
testcase_18 AC 71 ms
6,676 KB
testcase_19 AC 71 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 5 ms
6,676 KB
testcase_25 AC 5 ms
6,676 KB
testcase_26 AC 5 ms
6,676 KB
testcase_27 AC 5 ms
6,676 KB
testcase_28 AC 5 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <atcoder/all>
#include <bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
using namespace std;
using namespace atcoder;
using mint = modint998244353;
const int inf = 1000000007;
const ll longinf = 1ll << 60;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;
    vector<pair<ll, ll>> p(n), q(m);
    rep(i, n) {
        cin >> p[i].first >> p[i].second;
        p[i].second++;
    }
    rep(i, m) {
        cin >> q[i].first >> q[i].second;
        q[i].second++;
    }
    int k;
    cin >> k;
    vector<ll> a(k);
    rep(i, k) cin >> a[i];

    sort(p.begin(), p.end());
    sort(q.begin(), q.end());
    rep(i, n - 1) {
        if(p[i].second > p[i + 1].first) {
            rep(i, k) cout << "1 ";
            cout << endl;
            return 0;
        }
    }
    rep(i, m - 1) {
        if(q[i].second > q[i + 1].first) {
            rep(i, k) cout << "1 ";
            cout << endl;
            return 0;
        }
    }
    vector<int> ans(k);
    rep(i, m) {
        rep(j, k) {
            ll l = 2 * a[j] - q[i].second + 1, r = 2 * a[j] - q[i].first + 1;
            int _idx = lower_bound(p.begin(), p.end(), make_pair(l, r)) - p.begin();
            _idx -= 2;
            rep(ii, 5) {
                int idx = ii + _idx;
                if(idx < 0 || idx >= n)
                    continue;
                if(max(p[idx].first, l) < min(p[idx].second, r)) {
                    ans[j] = 1;
                }
            }
        }
    }
    rep(i, k) cout << ans[i] << " \n"[i + 1 == k];
    return 0;
}
0