結果

問題 No.1982 [Cherry 4th Tune B] 絶険
ユーザー kwm_tkwm_t
提出日時 2022-06-17 22:30:40
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,209 ms / 3,000 ms
コード長 2,933 bytes
コンパイル時間 2,898 ms
コンパイル使用メモリ 204,232 KB
実行使用メモリ 23,204 KB
最終ジャッジ日時 2024-04-17 14:43:51
合計ジャッジ時間 23,688 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 5 ms
7,552 KB
testcase_03 AC 230 ms
13,716 KB
testcase_04 AC 378 ms
12,408 KB
testcase_05 AC 526 ms
11,008 KB
testcase_06 AC 663 ms
15,920 KB
testcase_07 AC 862 ms
17,276 KB
testcase_08 AC 441 ms
13,384 KB
testcase_09 AC 580 ms
16,112 KB
testcase_10 AC 687 ms
14,264 KB
testcase_11 AC 417 ms
9,492 KB
testcase_12 AC 580 ms
15,504 KB
testcase_13 AC 246 ms
10,220 KB
testcase_14 AC 579 ms
11,220 KB
testcase_15 AC 286 ms
10,360 KB
testcase_16 AC 646 ms
14,148 KB
testcase_17 AC 1,050 ms
20,436 KB
testcase_18 AC 860 ms
18,360 KB
testcase_19 AC 1,051 ms
19,852 KB
testcase_20 AC 84 ms
10,004 KB
testcase_21 AC 250 ms
10,484 KB
testcase_22 AC 331 ms
11,396 KB
testcase_23 AC 174 ms
8,880 KB
testcase_24 AC 360 ms
9,436 KB
testcase_25 AC 889 ms
18,960 KB
testcase_26 AC 893 ms
20,104 KB
testcase_27 AC 173 ms
6,944 KB
testcase_28 AC 55 ms
7,936 KB
testcase_29 AC 674 ms
23,204 KB
testcase_30 AC 585 ms
22,308 KB
testcase_31 AC 72 ms
12,756 KB
testcase_32 AC 1,209 ms
23,180 KB
testcase_33 AC 1,120 ms
22,748 KB
testcase_34 AC 1,147 ms
22,272 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, S op(S l, S r), S e()>
struct DualSegtree {
private:
	int mn = 0;
	int mN = 0;
	int mlogN = 0;
	std::vector<S> A;
	void propagate(int i) {
		if (i >= mN) return;
		A[i * 2] = op(A[i * 2], A[i]);
		A[i * 2 + 1] = op(A[i * 2 + 1], A[i]);
		A[i] = e();
	}
	void full_propagate(int i) {
		for (int d = mlogN; d > 0; d--) propagate(i >> d);
	}
public:
	DualSegtree(int n = 0) {
		mn = n;
		mlogN = 0; mN = 1;
		while (mN < n) { mN *= 2; mlogN++; }
		A.assign(mN * 2, e());
	}
	void point_init(int p) {
		assert(0 <= p); assert(p < mn);
		p += mN;
		full_propagate(p);
		A[p] = e();
	}
	S get(int p) {
		assert(0 <= p); assert(p < mn);
		p += mN;
		full_propagate(p);
		return A[p];
	}
	void apply(int l, int r, S x) {
		l += mN;
		r += mN;
		if (l != mN) full_propagate(l - 1);
		if (r != mN * 2) full_propagate(r);
		while (l < r) {
			if (l & 1) { A[l] = op(A[l], x); l++; }
			if (r & 1) { r--; A[r] = op(A[r], x); }
			l /= 2; r /= 2;
		}
	}
};
//区間加算、一点取得
using S = long long;
S op(S x, S f) { return { x + f }; }
S e() { return { 0 }; }
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, k, q; cin >> n >> k >> q;
	vector<int>l(k), r(k), c(k);
	vector<long long>h(k);
	rep(i, k) {
		cin >> l[i] >> r[i] >> c[i] >> h[i];
		l[i]--, r[i]--;
	}
	vector<int>ans(q, -1);
	vector<int>x(q);
	vector<long long>y(q);
	rep(i, q) {
		cin >> x[i] >> y[i];
		x[i]--;
	}
	vector<int>ok(q, k), ng(q, -1);
	while (true) {
		bool fin = true;
		vector<vector<int>>mid(k);
		rep(i, q) {
			if (abs(ok[i] - ng[i]) > 1) {
				fin = false;
				int m = (ok[i] + ng[i]) / 2;
				mid[m].push_back(i);
			}
		}
		if (fin)break;
		//cout << ng[0] << " " << ok[0] << endl;
		DualSegtree<S, op, e>seg(n);
		rep(i, k) {
			seg.apply(l[i], r[i] + 1, h[i]);
			rep(j, mid[i].size()) {
				long long get = seg.get(x[mid[i][j]]);
				//cout << i << "?" << x[mid[i][j]] << "_" << get << endl;
				if (get >= y[mid[i][j]])ok[mid[i][j]] = i;
				else ng[mid[i][j]] = i;
			}
		}
	}
	rep(i, q) {
		if (k == ok[i])cout << -1 << endl;
		else cout << c[ok[i]] << endl;
	}
	return 0;
}
0