結果

問題 No.2421 entersys?
ユーザー a01sa01toa01sa01to
提出日時 2023-08-12 14:28:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,280 bytes
コンパイル時間 3,052 ms
コンパイル使用メモリ 245,524 KB
実行使用メモリ 54,396 KB
最終ジャッジ日時 2024-04-30 06:14:07
合計ジャッジ時間 22,552 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 3 ms
6,944 KB
testcase_02 AC 6 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 3 ms
6,940 KB
testcase_05 AC 5 ms
6,940 KB
testcase_06 AC 5 ms
6,944 KB
testcase_07 AC 4 ms
6,944 KB
testcase_08 AC 5 ms
6,940 KB
testcase_09 AC 7 ms
6,940 KB
testcase_10 AC 4 ms
6,940 KB
testcase_11 WA -
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 WA -
testcase_21 AC 1,036 ms
42,244 KB
testcase_22 AC 862 ms
39,948 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
  #include "settings/debug.cpp"
  #define _GLIBCXX_DEBUG
#else
  #define Debug(...) void(0)
#endif
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); ++i)

#include <atcoder/fenwicktree>

int main() {
  int n;
  cin >> n;

  vector<tuple<string, int, int>> info(n);
  rep(i, n) {
    string x;
    int l, r;
    cin >> x >> l >> r;
    info[i] = { x, l, r + 1 };
  }
  int q;
  cin >> q;
  vector<tuple<int, string, int, int>> query(q);
  rep(i, q) {
    int qtype;
    cin >> qtype;
    if (qtype == 1) {
      string x;
      int t;
      cin >> x >> t;
      query[i] = { qtype, x, t, -1 };
    }
    if (qtype == 2) {
      int t;
      cin >> t;
      query[i] = { qtype, "", t, -1 };
    }
    if (qtype == 3) {
      string x;
      int l, r;
      cin >> x >> l >> r;
      query[i] = { qtype, x, l, r + 1 };
    }
  }

  int comp_cnt = 0;
  {  // compress
    set<int> st;
    rep(i, n) {
      auto [_, l, r] = info[i];
      st.insert(l), st.insert(r);
    }
    rep(i, q) {
      auto [_, __, l, r] = query[i];
      st.insert(l), st.insert(r);
    }
    st.erase(-1);
    map<int, int> mp;
    for (int x : st) mp[x] = comp_cnt++;
    mp[-1] = -1;
    rep(i, n) {
      auto&& [_, l, r] = info[i];
      l = mp[l], r = mp[r];
    }
    rep(i, q) {
      auto&& [_, __, l, r] = query[i];
      l = mp[l], r = mp[r];
    }
  }

  map<string, set<int>> entered, exited;
  atcoder::fenwick_tree<int> fw(comp_cnt + 1);
  rep(i, n) {
    auto [x, l, r] = info[i];
    entered[x].insert(l);
    exited[x].insert(r);
    entered[x].insert(2e9);
    exited[x].insert(2e9);
    fw.add(l, 1);
    fw.add(r, -1);
  }
  rep(i, q) {
    int qtype = get<0>(query[i]);
    if (qtype == 1) {
      auto [_, x, t, __] = query[i];
      int l = *entered[x].upper_bound(t);
      int r = *exited[x].upper_bound(t);
      if (r < l) {
        cout << "Yes" << endl;
      }
      else {
        cout << "No" << endl;
      }
    }
    if (qtype == 2) {
      auto [_, __, t, ___] = query[i];
      cout << fw.sum(0, t + 1) << endl;
    }
    if (qtype == 3) {
      auto [_, x, l, r] = query[i];
      entered[x].insert(l);
      exited[x].insert(r);
      fw.add(l, 1);
      fw.add(r, -1);
    }
  }
  return 0;
}
0