結果

問題 No.2220 Range Insert & Point Mex
ユーザー rabimearabimea
提出日時 2023-02-17 22:26:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 265 ms / 2,000 ms
コード長 1,115 bytes
コンパイル時間 2,394 ms
コンパイル使用メモリ 211,752 KB
実行使用メモリ 10,396 KB
最終ジャッジ日時 2023-09-28 18:07:09
合計ジャッジ時間 9,597 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 208 ms
6,340 KB
testcase_14 AC 205 ms
6,444 KB
testcase_15 AC 205 ms
6,996 KB
testcase_16 AC 204 ms
7,200 KB
testcase_17 AC 206 ms
6,340 KB
testcase_18 AC 206 ms
6,156 KB
testcase_19 AC 206 ms
6,204 KB
testcase_20 AC 180 ms
4,380 KB
testcase_21 AC 180 ms
4,376 KB
testcase_22 AC 180 ms
4,376 KB
testcase_23 AC 249 ms
10,276 KB
testcase_24 AC 158 ms
10,128 KB
testcase_25 AC 211 ms
6,560 KB
testcase_26 AC 265 ms
10,260 KB
testcase_27 AC 58 ms
10,396 KB
testcase_28 AC 141 ms
4,500 KB
testcase_29 AC 145 ms
4,376 KB
testcase_30 AC 146 ms
4,376 KB
testcase_31 AC 177 ms
6,276 KB
testcase_32 AC 171 ms
4,996 KB
testcase_33 AC 172 ms
4,708 KB
testcase_34 AC 186 ms
4,848 KB
testcase_35 AC 187 ms
6,340 KB
testcase_36 AC 190 ms
6,148 KB
testcase_37 AC 184 ms
7,076 KB
testcase_38 AC 215 ms
7,916 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
 
#define fi first
#define se second
#define pb push_back
using vi = vector <int>;
using ll = long long;
using vl = vector <ll>;
using pii = pair <int, int>;
const ll mod = 998244353;
//~ const ll mod = 1e9 + 7;
ll qpow(ll a, ll b, ll m = mod) { ll r = 1, t = a;
	for(; b; b /= 2) { if(b & 1) r = r * t % m; t = t * t % m; } return r; }

const int N = 2e5 + 11;

struct event {
	int x, a, type;
	bool operator <(const event &o) const {
		return x < o.x;
	}
};

int main() {
	ios::sync_with_stdio(0);
	int n; cin >> n;
	
	vector <event> es;
	for(int i = 1; i <= n; i ++) {
		int l, r, a;
		cin >> l >> r >> a;
		
		if(a <= n) {
			es.pb({l, a, 1});
			es.pb({r + 1, a, -1});
		}
	}
	sort(es.begin(), es.end());
	
	map <int, int> cnt;
	bitset <N> bs; bs.set();
	
	int p = 0;
	int q; cin >> q;
	while(q --) {
		int x; cin >> x;
		while(p < es.size() && es[p].x <= x) {
			auto e = es[p];
			if(e.type == 1) {
				cnt[e.a] ++;
				bs[e.a] = 0;
			} else {
				cnt[e.a] --;
				if(cnt[e.a] == 0)
					bs[e.a] = 1;
			}
			p ++;
		}
		cout << bs._Find_first() << '\n';
	}
}

0