結果

問題 No.2421 entersys?
ユーザー siro53siro53
提出日時 2023-08-12 16:00:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,975 bytes
コンパイル時間 2,533 ms
コンパイル使用メモリ 235,384 KB
実行使用メモリ 18,048 KB
最終ジャッジ日時 2024-04-30 10:39:33
合計ジャッジ時間 10,931 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 3 ms
6,940 KB
testcase_02 AC 4 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 3 ms
6,944 KB
testcase_05 AC 4 ms
6,940 KB
testcase_06 AC 3 ms
6,940 KB
testcase_07 AC 3 ms
6,940 KB
testcase_08 AC 4 ms
6,944 KB
testcase_09 AC 5 ms
6,940 KB
testcase_10 AC 3 ms
6,944 KB
testcase_11 AC 370 ms
15,552 KB
testcase_12 AC 366 ms
15,956 KB
testcase_13 AC 381 ms
15,556 KB
testcase_14 AC 388 ms
15,412 KB
testcase_15 AC 378 ms
15,564 KB
testcase_16 AC 401 ms
16,860 KB
testcase_17 AC 387 ms
17,496 KB
testcase_18 AC 395 ms
17,580 KB
testcase_19 AC 396 ms
17,748 KB
testcase_20 AC 401 ms
17,516 KB
testcase_21 AC 398 ms
17,340 KB
testcase_22 AC 302 ms
15,580 KB
testcase_23 AC 481 ms
17,188 KB
testcase_24 AC 483 ms
18,048 KB
testcase_25 AC 484 ms
17,452 KB
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);
  vector<tuple<int, int, int>> ans;
  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(e.qid != -1) {
      	if(it->first == e.uid) ans.emplace_back(e.qid, 1, 1);
      	else ans.emplace_back(e.qid, 1, 0);
      }
    } else {
      if(e.qid != -1) ans.emplace_back(e.qid, 2, bt.sum(0, e.qid + 1));
    }
  }
  sort(ans.begin(), ans.end());
  for(const auto& [_, t, v] : ans) {
    if(t == 1) cout << (v ? "Yes" : "No") << '\n';
    else cout << v << '\n';
  }
}
0