結果

問題 No.2687 所により大雨
ユーザー SSRS
提出日時 2024-03-20 22:18:21
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 323 ms / 2,000 ms
コード長 1,382 bytes
コンパイル時間 2,555 ms
コンパイル使用メモリ 203,452 KB
最終ジャッジ日時 2025-02-20 09:22:48
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

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