結果

問題 No.2421 entersys?
ユーザー LaFolia13LaFolia13
提出日時 2023-07-29 18:34:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,861 ms / 3,000 ms
コード長 1,964 bytes
コンパイル時間 2,916 ms
コンパイル使用メモリ 198,544 KB
実行使用メモリ 73,800 KB
最終ジャッジ日時 2024-04-16 23:38:50
合計ジャッジ時間 31,702 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 4 ms
5,376 KB
testcase_02 AC 6 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 3 ms
5,376 KB
testcase_05 AC 5 ms
5,376 KB
testcase_06 AC 5 ms
5,376 KB
testcase_07 AC 5 ms
5,376 KB
testcase_08 AC 5 ms
5,376 KB
testcase_09 AC 8 ms
5,376 KB
testcase_10 AC 4 ms
5,376 KB
testcase_11 AC 1,513 ms
59,884 KB
testcase_12 AC 1,447 ms
59,884 KB
testcase_13 AC 1,483 ms
59,912 KB
testcase_14 AC 1,456 ms
59,876 KB
testcase_15 AC 1,474 ms
59,892 KB
testcase_16 AC 1,509 ms
63,084 KB
testcase_17 AC 1,541 ms
63,096 KB
testcase_18 AC 1,473 ms
63,084 KB
testcase_19 AC 1,471 ms
63,064 KB
testcase_20 AC 1,515 ms
63,216 KB
testcase_21 AC 1,417 ms
58,560 KB
testcase_22 AC 1,279 ms
56,380 KB
testcase_23 AC 1,861 ms
73,796 KB
testcase_24 AC 1,805 ms
73,800 KB
testcase_25 AC 1,758 ms
73,800 KB
testcase_26 AC 1,111 ms
50,756 KB
testcase_27 AC 1,129 ms
50,756 KB
testcase_28 AC 1,114 ms
50,756 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:58:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
   58 |   for (auto &[x, l, r]: xlr) {
      |              ^
main.cpp:65:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
   65 |   for (auto &[id, ti, xlr]: que) {
      |              ^
main.cpp:87:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
   87 |   for (auto &[x, l, r]: xlr) {
      |              ^
main.cpp:92:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
   92 |   for (auto &[id, ti, xlr]: que) {
      |              ^
main.cpp:93:10: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
   93 |     auto [x, l, r] = xlr;
      |          ^

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/lazysegtree>

using namespace std;
using namespace atcoder;
using llong = long long;
using ldbl = long double;
using p = pair<int, int>;

#define ALL(x) x.begin(), x.end()

constexpr llong mod = 1e9+7;
constexpr llong inf = mod * mod;

struct S {
    int a;
};

struct F {
    int a;
};

S op(S l, S r) { return S{min(l.a, r.a)}; }

S e() { return S{0}; }

S mapping(F l, S r) { return S{r.a + l.a}; }

F composition(F l, F r) { return F{r.a + l.a}; }

F id() { return F{0}; }

struct node {
  string x;
  int l = 0;
  int r = 0;
};

struct query {
  int id;
  int t = 0;
  node xlr;
};

map<int, int> zaatsu;
int z(int x) {
  return zaatsu[x];
}

int main() {
  int n, q;
  vector<node> xlr;
  vector<query> que;
  set<int> t;

  cin >> n;
  xlr.resize(n);
  for (auto &[x, l, r]: xlr) {
    cin >> x >> l >> r;
    t.insert(l);
    t.insert(r);
  }
  cin >> q;
  que.resize(q);
  for (auto &[id, ti, xlr]: que) {
    cin >> id;
    if (id == 1) {
      cin >> xlr.x >> ti;
    }
    else if (id == 2) {
      cin >> ti;
    }
    else if (id == 3) {
      cin >> xlr.x >> xlr.l >> xlr.r;
    }
    t.insert(ti);
    t.insert(xlr.l);
    t.insert(xlr.r);
  }

  for (auto &s: t) {
    zaatsu[s] = zaatsu.size();
  }
  map<string, set<p>> st;
  lazy_segtree<S, op, e, F, mapping, composition, id> seg(zaatsu.size() + 1);
  xlr.resize(n);
  for (auto &[x, l, r]: xlr) {
    st[x].insert(p(z(r), z(l)));
    seg.apply(z(l), z(r) + 1, F{1});
  }

  for (auto &[id, ti, xlr]: que) {
    auto [x, l, r] = xlr;
    if (id == 1) {
      auto it = st[x].lower_bound(p(z(ti), 0));
      if (it == st[x].end()) {
        cout << "No" << endl;
      }
      else {
        cout << (it->second <= z(ti) ? "Yes": "No") << endl;
      }
    }
    else if (id == 2) {
      cout << seg.get(z(ti)).a << endl;
    }
    else if (id == 3) {
      st[x].insert(p(z(r), z(l)));
      seg.apply(z(l), z(r) + 1, F{1});
    }
  }

  return 0;
}
0