Submission #692336

# Submission time Handle Problem Language Result Execution time Memory
692336 2023-02-01T11:00:08 Z NeroZein Trampoline (info1cup20_trampoline) C++14
11 / 100
710 ms 40904 KB
/*
 *    author: NeroZein
 *    created: 01.02.2023 13:03:54
*/
#include <bits/stdc++.h>
#define int long long 
using namespace std;

#ifdef Nero
#include "Deb.h"
#else
#define deb(...)
#endif

const int Log = 50;

map<pair<int,int>, pair<int,int>> dp[Log]; 

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int r, c, n;
	cin >> r >> c >> n;
	map<int, set<int>> se; 
	vector<pair<int,int>> p(n); 
	for (int i = 0; i < n; ++i) {
		pair<int,int> pp;
		cin >> pp.first >> pp.second;
		p[i] = pp;
		se[pp.first].insert(pp.second); 
	}
	sort(p.begin(), p.end()); 
	map<pair<int,int>, int> convert; 
	for (int i = 0; i < n; ++i) {
		int x = p[i].first;
		int y = p[i].second;
		if (se[x-1].empty()) {
			continue; 
		}
		auto it = se[x-1].upper_bound(y); 
		if (it == se[x-1].begin()) {
			continue; 
		}
		--it; 
		dp[0][p[i]] = {x-1, *it}; 
	}
	auto jump = [&](int x, int y, int k) {
		for (int j = 0; j < Log; ++j) {
			if ((k >> j) & 1) {
				auto pp = dp[j][{x, y}];
				x = pp.first, y = pp.second;
			}
		}
		return make_pair(x, y); 
	};
	int q;
	cin >> q; 
	while(q--) {
		int xs, ys, xf, yf;
		cin >> xs >> ys >> xf >> yf; 
		if (xf < xs || yf < ys) {
			cout << "NO" << '\n';
			continue;
		}
		if (xf == xs) {
			cout << "YES" << '\n';
			continue; 
		}
		auto it = se[xf-1].upper_bound(yf); 
		if (se[xf-1].empty() || it == se[xf-1].begin()) {
			cout << "NO" << '\n';
			continue; 
		}
		--it; 
		xf--; 
		yf = *it; 
		int dis = xf - xs; 
		auto pp = jump(xf, yf, dis); 
		xf = pp.first, yf = pp.second; 
		cout << (xf == xs && yf >= ys ? "YES" : "NO") << '\n';
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 1492 KB expected YES, found NO [1st token]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 224 ms 28768 KB expected YES, found NO [3rd token]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 318 ms 24388 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 363 ms 25940 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 432 ms 29120 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 443 ms 29196 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 453 ms 29292 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 523 ms 29900 KB 200000 token(s): yes count is 97163, no count is 102837
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 1108 KB expected YES, found NO [1st token]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 710 ms 40904 KB expected YES, found NO [1st token]
2 Halted 0 ms 0 KB -