結果

問題 No.2687 所により大雨
ユーザー SSRSSSRS
提出日時 2024-03-20 22:18:21
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 315 ms / 2,000 ms
コード長 1,382 bytes
コンパイル時間 2,298 ms
コンパイル使用メモリ 211,188 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2024-03-20 22:18:30
合計ジャッジ時間 7,359 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  vector<pair<long long, long long>> LR(N + M);
  for (int i = 0; i < N + M; i++){
    cin >> LR[i].first >> LR[i].second;
  }
  int K;
  cin >> K;
  vector<long long> P(K);
  for (int i = 0; i < K; i++){
    cin >> P[i];
  }
  sort(LR.begin(), LR.begin() + N);
  sort(LR.begin() + N, LR.end());
  bool ok = false;
  for (int i = 0; i < N - 1; i++){
    if (LR[i].second >= LR[i + 1].first){
      ok = true;
    }
  }
  for (int i = N; i < N + M - 1; i++){
    if (LR[i].second >= LR[i + 1].first){
      ok = true;
    }
  }
  if (ok){
    for (int i = 0; i < K; i++){
      cout << 1;
      if (i < K - 1){
        cout << ' ';
      }
    }
    cout << endl;
  } else {
    vector<long long> X(N * 2);
    for (int i = 0; i < N; i++){
      X[i * 2] = LR[i].first;
      X[i * 2 + 1] = LR[i].second;
    }
    for (int i = 0; i < K; i++){
      int E = 0;
      for (int j = N; j < N + M; j++){
        long long l = 2 * P[i] - LR[j].second;
        long long r = 2 * P[i] - LR[j].first;
        int pl = lower_bound(X.begin(), X.end(), l) - X.begin();
        int pr = upper_bound(X.begin(), X.end(), r) - X.begin();
        if (!(pl == pr && pl % 2 == 0)){
          E = 1;
        }
      }
      cout << E;
      if (i < K - 1){
        cout << ' ';
      }
    }
    cout << endl;
  }
}
0