結果

問題 No.2421 entersys?
ユーザー siro53siro53
提出日時 2023-08-12 15:53:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,696 bytes
コンパイル時間 2,230 ms
コンパイル使用メモリ 226,400 KB
実行使用メモリ 19,040 KB
最終ジャッジ日時 2024-04-30 10:24:53
合計ジャッジ時間 10,418 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/fenwicktree>
using namespace std;
using ll = long long;

struct E {
  int type, time, uid, qid;
};

int main() {
  int N;
  cin >> N;
  map<string, int> ID;
  auto get_id = [&](string x) -> int {
    if(ID.count(x)) return ID[x];
    int res = ID.size();
    ID[x] = res;
    return res;
  };
  vector<E> es;
  for(int i = 0; i < N; i++) {
    string x;
    int L, R;
    cin >> x >> L >> R;
    int uid = get_id(x);
    es.push_back(E{1, L, uid, -1});
    es.push_back(E{2, R+1, uid, -1});
  }
  int Q;
  cin >> Q;
  for(int i = 0; i < Q; i++) {
    int t;
    cin >> t;
    if(t == 1) {
      string x;
      int time;
      cin >> x >> time;
      int uid = get_id(x);
      es.emplace_back(E{3, time, uid, i});
    } else if(t == 2) {
      int time;
      cin >> time;
      es.emplace_back(E{4, time, -1, i});
    } else {
      string x;
      int L, R;
      cin >> x >> L >> R;
      int uid = get_id(x);
      es.emplace_back(E{1, L, uid, i});
      es.emplace_back(E{2, R+1, uid, i});
    }
  }
  sort(es.begin(), es.end(), [](const E& l, const E& r) {
    if(l.time != r.time) return (l.time < r.time);
    return (l.type < r.type);
  });
  set<pair<int, int>> id_set;
  atcoder::fenwick_tree<int> bt(Q+1);
  for(const auto& e : es) {
    if(e.type == 1) {
      id_set.insert({e.uid, -e.qid});
      bt.add(e.qid + 1, 1);
    } else if(e.type == 2) {
      id_set.erase({e.uid, -e.qid});
      bt.add(e.qid + 1, -1);
    } else if(e.type == 3) {
      auto it = id_set.lower_bound({e.uid, -e.qid});
      if(it->first == e.uid) cout << "Yes\n";
      else cout << "No\n";
    } else {
      cout << bt.sum(0, e.qid + 1) << '\n';
    }
  }
}
0