結果

問題 No.2220 Range Insert & Point Mex
ユーザー stoqstoq
提出日時 2023-01-31 06:15:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 853 bytes
コンパイル時間 2,522 ms
コンパイル使用メモリ 215,856 KB
実行使用メモリ 13,480 KB
最終ジャッジ日時 2023-09-14 15:46:53
合計ジャッジ時間 9,136 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 WA -
testcase_04 AC 2 ms
4,380 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 1 ms
4,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 215 ms
11,644 KB
testcase_21 AC 215 ms
12,184 KB
testcase_22 AC 215 ms
12,392 KB
testcase_23 AC 216 ms
11,972 KB
testcase_24 AC 180 ms
10,720 KB
testcase_25 AC 137 ms
7,956 KB
testcase_26 AC 189 ms
12,000 KB
testcase_27 AC 150 ms
10,168 KB
testcase_28 AC 39 ms
4,684 KB
testcase_29 AC 51 ms
4,864 KB
testcase_30 AC 51 ms
4,628 KB
testcase_31 AC 172 ms
11,964 KB
testcase_32 AC 122 ms
9,228 KB
testcase_33 AC 127 ms
9,536 KB
testcase_34 AC 195 ms
11,796 KB
testcase_35 AC 203 ms
11,820 KB
testcase_36 AC 190 ms
12,984 KB
testcase_37 AC 191 ms
12,536 KB
testcase_38 AC 189 ms
11,852 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<tuple<int, int, int>> event;
  for (int i = 0; i < n; i++) {
    int l, r, a;
    cin >> l >> r >> a;
    event.push_back({l, 1, a});
    event.push_back({r, 3, a});
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int x;
    cin >> x;
    event.push_back({x, 2, i});
  }
  sort(begin(event), end(event));

  set<int> unused;
  for (int i = 0; i <= n; i++) unused.insert(i);
  vector<int> ans(q);
  for (auto [x, type, num] : event) {
    if (type == 1) {  // 追加
      if (num >= n) continue;
      if(unused.count(num)) unused.erase(num);
    } else if (type == 2) {  // クエリ
      ans[num] = *unused.begin();
    } else {  // 削除
      if (num >= n) continue;
      unused.insert(num);
    }
  }
  for (auto a : ans) cout << a << "\n";
}
0