Submission #316041

# Submission time Handle Problem Language Result Execution time Memory
316041 2020-10-24T22:29:42 Z jungsnow Trampoline (info1cup20_trampoline) C++14
11 / 100
626 ms 39336 KB
#include<bits/stdc++.h>
#define x first
#define y second

using namespace std;

typedef pair<int, int> ii;
typedef pair<ii, int> iii;

const int N = 200100;
const int oo = 2e9;

int n, t, nxt[N][22];
map<int, set<ii>> mp;
vector<ii> v, u;
vector<iii> gr;
ii q[N];

bool proc(int u, int v, int x, int y) {
	if (u > x) return 0;
	if (v > y) return 0;
	if (u == x) return 1;
	
	int len = (x - u - 1);
	if (!mp.count(u)) return 0;
	auto it = mp[u].lower_bound(ii(v, -1));
	if (it == mp[u].end()) return 0;
	int cur = it->y;
	for (int i = 21; i >= 0; --i) if (len >> i & 1) {
		cur = nxt[cur][i];
		if (cur == oo) return 0;
	}
	return q[cur].y <= y;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n >> n >> n;
	for (int a, b, i = 1; i <= n; ++i) {
		cin >> a >> b;
		q[i] = ii(a, b);
		mp[a].insert(ii(b, i));
		gr.push_back(iii(ii(a, b), i));
	}
	sort(gr.begin(), gr.end(), [](const iii& a, const iii& b) {
		return (a.x.x < b.x.x || (a.x.x == b.x.x && a.x.y < b.x.y));
	});
	int pre = oo;
	for (int i = n - 1; i >= 0; --i) {
		int a = gr[i].x.x, b = gr[i].x.y, id = gr[i].y;
		nxt[id][0] = oo;
		if (a + 1 == pre) {
			v = u;
			u.clear();
		} else if (a < pre) {
			v.clear();
			u.clear();
		}
		if (!v.empty()) {
			auto it = lower_bound(v.begin(), v.end(), ii(b, -1));
			if (it != v.end()) {
				nxt[id][0] = it->y;
			}
		}
		u.push_back(ii(b, id));
		pre = a;
	}
	for (int j = 1; j < 22; ++j) {
		for (int i = 1; i <= n; ++i) if (nxt[i][j - 1] != oo) {
			nxt[i][j] = nxt[ nxt[i][j - 1] ][j - 1];
		} else nxt[i][j] = oo;
	}
	cin >> t;
	for (int u, v, x, y, i = 1; i <= t; ++i) {
		cin >> u >> v >> x >> y;
		cout << (proc(u, v, x, y) ? "Yes" : "No") << '\n';
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 1792 KB expected YES, found NO [1st token]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 247 ms 31140 KB expected YES, found NO [3rd token]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 464 ms 34420 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 473 ms 33572 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 474 ms 31904 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 503 ms 31892 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 499 ms 31904 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 578 ms 37928 KB 200000 token(s): yes count is 97163, no count is 102837
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 1152 KB expected YES, found NO [1st token]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 626 ms 39336 KB expected YES, found NO [1st token]
2 Halted 0 ms 0 KB -