結果

問題 No.2421 entersys?
ユーザー kwm_tkwm_t
提出日時 2023-08-12 16:45:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 489 ms / 3,000 ms
コード長 2,861 bytes
コンパイル時間 5,483 ms
コンパイル使用メモリ 291,384 KB
実行使用メモリ 35,300 KB
最終ジャッジ日時 2024-04-30 11:44:03
合計ジャッジ時間 14,415 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 3 ms
6,944 KB
testcase_02 AC 3 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 3 ms
6,944 KB
testcase_06 AC 3 ms
6,944 KB
testcase_07 AC 3 ms
6,940 KB
testcase_08 AC 3 ms
6,944 KB
testcase_09 AC 4 ms
6,940 KB
testcase_10 AC 3 ms
6,940 KB
testcase_11 AC 384 ms
27,748 KB
testcase_12 AC 380 ms
29,408 KB
testcase_13 AC 389 ms
29,412 KB
testcase_14 AC 398 ms
27,820 KB
testcase_15 AC 394 ms
27,976 KB
testcase_16 AC 387 ms
29,132 KB
testcase_17 AC 384 ms
29,984 KB
testcase_18 AC 371 ms
29,344 KB
testcase_19 AC 381 ms
28,948 KB
testcase_20 AC 372 ms
29,660 KB
testcase_21 AC 368 ms
28,316 KB
testcase_22 AC 271 ms
24,064 KB
testcase_23 AC 489 ms
35,200 KB
testcase_24 AC 487 ms
35,300 KB
testcase_25 AC 483 ms
34,428 KB
testcase_26 AC 295 ms
25,568 KB
testcase_27 AC 292 ms
25,180 KB
testcase_28 AC 296 ms
26,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
//using mint = modint1000000007;
//const int mod = 1000000007;
//using mint = modint998244353;
//const int mod = 998244353;
//const int INF = 1e9;
//const long long LINF = 1e18;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i,l,r)for(int i=(l);i<(r);++i)
#define rrep(i, n) for (int i = (n-1); i >= 0; --i)
#define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i)
#define all(x) (x).begin(),(x).end()
#define allR(x) (x).rbegin(),(x).rend()
#define endl "\n"
#define P pair<int,int>
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }
template <class S>
struct value_compression : vector<S> {
	bool built = false;
	using VS = vector<S>;
	using VS::VS;
	value_compression(vector<S> v = {}) : vector<S>(move(v)) {}
	void build() {
		sort(this->begin(), this->end());
		this->erase(unique(this->begin(), this->end()), this->end());
		built = true;
	}
	template <class T>
	void convert(T first, T last) {
		assert(built);
		for (; first != last; ++first) *first = (*this)(*first);
	}
	int operator()(S x) {
		assert(built);
		return lower_bound(this->begin(), this->end(), x) - this->begin();
	}
	void clear() {
		this->clear();
		built = false;
	}
};
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n; cin >> n;
	vector<tuple<string, int, int>> inp(n);
	value_compression<string> name;
	value_compression<int> time;
	for (auto&[x, l, r] : inp) {
		cin >> x >> l >> r, l--;
		name.emplace_back(x);
		time.emplace_back(l);
		time.emplace_back(r);
	}
	int q; cin >> q;
	struct Q {
		int type;
		string x;
		int l, r;
	};
	vector<Q>query(q);
	for (auto &[type, x, l, r] : query) {
		cin >> type;
		if (1 == type) {
			cin >> x >> l;
			l--;
			name.push_back(x);
			time.push_back(l);
		}
		else if (2 == type) {
			cin >> l;
			l--;
			time.push_back(l);
		}
		else {
			cin >> x >> l >> r;
			l--;
			name.push_back(x);
			time.push_back(l);
			time.push_back(r);
		}
	}
	name.build();
	time.build();
	vector<map<int, int>> memo(name.size());
	fenwick_tree<int> ft(time.size());
	for (auto&[x, l, r] : inp) {
		int p = name(x);
		l = time(l);
		r = time(r);
		memo[p][r] = l;
		ft.add(l, 1);
		ft.add(r, -1);
	}
	for (auto &[type, x, l, r] : query) {
		if (1 == type) {
			int p = name(x);
			l = time(l);
			auto it = memo[p].upper_bound(l);
			bool ok = it != memo[p].end() && it->second <= l;
			cout << (ok ? "Yes\n" : "No\n");
		}
		else if (2 == type) {
			l = time(l);
			cout << ft.sum(0, l + 1) << endl;
		}
		else {
			int p = name(x);
			l = time(l);
			r = time(r);
			memo[p][r] = l;
			ft.add(l, 1);
			ft.add(r, -1);
		}
	}
	return 0;
}
0