結果
問題 | No.2220 Range Insert & Point Mex |
ユーザー | karinohito |
提出日時 | 2023-02-17 22:04:24 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 5,243 bytes |
コンパイル時間 | 4,930 ms |
コンパイル使用メモリ | 282,468 KB |
実行使用メモリ | 44,032 KB |
最終ジャッジ日時 | 2024-07-19 13:15:58 |
合計ジャッジ時間 | 17,086 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | WA | - |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | AC | 2 ms
5,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 | 566 ms
43,904 KB |
testcase_21 | AC | 550 ms
43,904 KB |
testcase_22 | AC | 554 ms
44,032 KB |
testcase_23 | AC | 337 ms
22,016 KB |
testcase_24 | AC | 257 ms
21,632 KB |
testcase_25 | AC | 259 ms
16,512 KB |
testcase_26 | AC | 299 ms
22,016 KB |
testcase_27 | AC | 79 ms
14,464 KB |
testcase_28 | AC | 189 ms
11,008 KB |
testcase_29 | AC | 198 ms
11,008 KB |
testcase_30 | AC | 198 ms
11,008 KB |
testcase_31 | AC | 275 ms
20,460 KB |
testcase_32 | AC | 245 ms
17,264 KB |
testcase_33 | AC | 252 ms
17,264 KB |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | AC | 385 ms
28,084 KB |
ソースコード
#include <bits/stdc++.h> #include <cassert> #include <cmath> #include <complex> using namespace std; #include <atcoder/all> using namespace atcoder; using ll = long long; using vll = vector<ll>; using vvll = vector<vll>; using vvvll = vector<vvll>; #define all(A) A.begin(),A.end() #define rep(i, n) for (ll i = 0; i < (ll) (n); i++) template<class T> bool chmax(T& p, T q, bool C = 1) { if (C == 0 && p == q) { return 1; } if (p < q) { p = q; return 1; } else { return 0; } } template<class T> bool chmin(T& p, T q, bool C = 1) { if (C == 0 && p == q) { return 1; } if (p > q) { p = q; return 1; } else { return 0; } } ll gcd(ll(a), ll(b)) { if (a == 0)return b; if (b == 0)return a; ll c = a; while (a % b != 0) { c = a % b; a = b; b = c; } return b; } ll sqrtz(ll N) { ll L = 0; ll R = sqrt(N) + 10000; while (abs(R - L) > 1) { ll mid = (R + L) / 2; if (mid * mid <= N)L = mid; else R = mid; } return L; } using mint = modint998244353; /* 区間をsetで管理するテク 区間は半開区間で持たせる[L,R) */ ll cnt=0; vll AN; ll cm = 0; template<class T> struct rangeset { set<pair<T, T>> S; T INF; rangeset() { INF = 2e18;; S.insert({ INF,INF }); S.insert({ -INF,-INF }); } bool iscovered(T L, T R) { //assert(L<=R); auto itr = S.lower_bound({ L + 1,L + 1 }); itr = prev(itr); auto st = *itr; return (itr->first <= L && R <= itr->second); } bool iscovered(T x) { return iscovered(x, x + 1); } pair<T, T> covered(T L, T R) { //assert(L<=R); auto itr = S.lower_bound({ L + 1,L + 1 }); itr--; auto st = *itr; if (itr->first <= L && R <= itr->second) { return st; } else { return { INF,INF }; } } pair<T, T> covered(T x) { return covered(x, x + 1); } T insert(T L, T R) { if (iscovered(L, R))return T(0); auto itr = S.lower_bound({ L + 1,L + 1 }); itr = prev(itr); T res = T(0); auto st = *itr; if (itr->first <= L && L <= itr->second) { L = st.first; res -= itr->second - itr->first; itr = S.erase(itr); } else itr = next(itr); while (R > itr->second) { res -= itr->second - itr->first; itr = S.erase(itr); } if (itr->first <= R && R <= itr->second) { res -= itr->second - itr->first; R = itr->second; itr = S.erase(itr); } S.insert({ L,R }); res += R - L; return res; } T insert(T x) { return insert(x, x + 1); } T erase(T L, T R) { auto itr = S.lower_bound({ L + 1,L + 1 }); itr = prev(itr); T res = T(0); auto st = *itr; if (itr->first <= L && R <= itr->second) { if (itr->first < L)S.insert({ itr->first,L }); if (R < itr->second)S.insert({ R,itr->second }); for (ll p = L; p < R; p++) { AN[p] = cm; cnt++; } S.erase(itr); return R - L; } if (itr->first <= L && L < itr->second) { res += itr->second - L; if (itr->first < L)S.insert({ itr->first,L }); for (ll p = L; p < itr->second; p++) { AN[p] = cm; cnt++; } itr = S.erase(itr); } else itr = next(itr); while (itr->second <= R) { res += itr->second - itr->first; for (ll p = itr->first; p < itr->second; p++) { AN[p] = cm; cnt++; } itr = S.erase(itr); } if (itr->first < R && R <= itr->second) { res += R - itr->first; if (R < itr->second)S.insert({ R,itr->second }); for (ll p = itr->first; p < R; p++) { AN[p] = cm; cnt++; } S.erase(itr); } return res; } T erase(T x) { return erase(x, x + 1); } }; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); rangeset<ll> S; map<ll, vector<pair<ll, ll>>> P; ll N; cin >> N; map<ll, ll> M; rep(i, N) { ll L, R, A; cin >> L >> R >> A; M[L] = M[R] = 1; P[A].push_back({ L,R }); } ll Q; cin >> Q; vll X(Q); rep(i, Q) { ll x; cin >> x; M[x] = 1; X[i] = x; } ll m = 0; for (auto mm : M) { M[mm.first] = m; m++; } AN.assign(m, N); S.insert(0, m); rep(i, N + 1) { ll LL = 0; cm = i; for (auto lr : P[i]) { ll L = M[lr.first]; ll R = M[lr.second]; if (LL < L)S.erase(LL, L); LL = R + 1; } S.erase(LL, m + 1); } rep(q, Q) { cout << AN[M[X[q]]] << endl; } //cout<<cnt<<endl; }