結果

問題 No.2687 所により大雨
ユーザー 👑 hos.lyrichos.lyric
提出日時 2024-03-20 22:31:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 143 ms / 2,000 ms
コード長 2,641 bytes
コンパイル時間 1,733 ms
コンパイル使用メモリ 120,976 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2024-03-20 22:32:24
合計ジャッジ時間 5,013 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 142 ms
6,548 KB
testcase_01 AC 142 ms
6,548 KB
testcase_02 AC 143 ms
6,548 KB
testcase_03 AC 142 ms
6,548 KB
testcase_04 AC 142 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 132 ms
6,548 KB
testcase_11 AC 133 ms
6,548 KB
testcase_12 AC 134 ms
6,548 KB
testcase_13 AC 133 ms
6,548 KB
testcase_14 AC 132 ms
6,548 KB
testcase_15 AC 137 ms
6,548 KB
testcase_16 AC 133 ms
6,548 KB
testcase_17 AC 133 ms
6,548 KB
testcase_18 AC 133 ms
6,548 KB
testcase_19 AC 133 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 3 ms
6,548 KB
testcase_27 AC 4 ms
6,548 KB
testcase_28 AC 4 ms
6,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

using Int = long long;

template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }
#define COLOR(s) ("\x1b[" s "m")


constexpr Int INF = 1001001001001001001LL;

int M, N;
vector<pair<Int, Int>> A, B;
int K;
vector<Int> P;

int main() {
  for (; ~scanf("%d%d", &M, &N); ) {
    A.resize(M); for (int i = 0; i < M; ++i) scanf("%lld%lld", &A[i].first, &A[i].second);
    B.resize(N); for (int i = 0; i < N; ++i) scanf("%lld%lld", &B[i].first, &B[i].second);
    scanf("%d", &K);
    P.resize(K);
    for (int k = 0; k < K; ++k) {
      scanf("%lld", &P[k]);
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    
    bool ov = false;
    for (int i = 0; i < M - 1; ++i) ov = ov || (A[i].second >= A[i + 1].first);
    for (int i = 0; i < N - 1; ++i) ov = ov || (B[i].second >= B[i + 1].first);
    
    vector<int> ans(K, ov ? 1 : 0);
    for (int k = 0; k < K; ++k) {
      for (int j = 0; j < N; ++j) {
        // L - t <= P[k] <= R - t
        const Int t0 = B[j].first - P[k];
        const Int t1 = B[j].second - P[k];
        // L + t <= P[k] <= R + t
        const Int l = P[k] - t1;
        const Int r = P[k] - t0;
        const int i = upper_bound(A.begin(), A.end(), make_pair(r, INF)) - A.begin() - 1;
// cerr<<P[k]<<" "<<B[j]<<"; "<<make_pair(l,r)<<" "<<i<<endl;
        if (i >= 0 && A[i].second >= l && r >= A[i].first) {
          ans[k] = 1;
        }
      }
    }
    
    for (int k = 0; k < K; ++k) {
      if (k) printf(" ");
      printf("%d", ans[k]);
    }
    puts("");
  }
  return 0;
}
0