Submission #533271

# Submission time Handle Problem Language Result Execution time Memory
533271 2022-03-05T08:22:32 Z hhhhaura Trampoline (info1cup20_trampoline) C++14
73 / 100
930 ms 67392 KB
#define wiwihorz
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse")
#pragma loop-opt(on)
#define rep(i, a, b) for(int i = a; i <= b; i ++)
#define rrep(i, a, b) for(int i = b; i >= a; i--)
#define ceil(a, b) ((a + b - 1) / (b))
#define all(x) x.begin(), x.end()
#define int long long int
#define lld long double
#define pii pair<int, int>
#define random mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count())
using namespace std;
#define INF 1000000000000000000
#define MOD 1000000007
#define eps (1e-9)

#ifdef wiwihorz
#define print(a...) cerr<<"Line "<<__LINE__<<":",kout("[" + string(#a) + "] = ", a)
void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L)==R], ++L;}
void kout() { cerr << endl; }
template<class T1, class ... T2> void kout(T1 a, T2 ... e) { cerr << a << " ", kout(e...);} 
#else
#define print(...) 0
#define vprint(...) 0
#endif
#define x first
#define y second 
namespace solver {
	int r, c, n, lg, ii;
	vector<vector<int>> to;
	vector<pii> a;
	map<int, int> mp;
	vector<set<pii>> s;
	void init_(int _r, int _c, int _n) {
		ii = 0, r = _r, c = _c, n = _n;
		lg = 31 - __builtin_clz(n);
		to.assign(lg + 1, vector<int>(n + 2, 0));
		a.assign(n + 1, {0, 0});
		s.assign(n + 1, set<pii>());
	}
	void solve() {
		rep(i, 1, n) {
			int x, y; 
			tie(x, y) = a[i];
			if(mp.find(x) == mp.end()) mp[x] = ++ii;
			s[mp[x]].insert({y, i});
		}
		rep(i, 1, n) {
			int x, y;
			tie(x, y) = a[i];
			if(mp.find(x + 1) == mp.end()) continue;
			int id = mp[x + 1];
			auto it = s[id].lower_bound({y, 0});
			if(it == s[id].end()) to[0][i] = n + 1;
			else to[0][i] = it -> y;
		}
		to[0][n + 1] = n + 1;
		rep(i, 1, lg) rep(j, 1, n + 1) {
			to[i][j] = to[i - 1][to[i - 1][j]];
		}
	}
	int gogo(int x, int v) {
		rrep(i, 0, lg) if((v >> i) & 1)
			x = to[i][x];
		if(x == n + 1) return INF;
		else return a[x].y;
	}
};
using namespace solver;
signed main() {
	ios::sync_with_stdio(false), cin.tie(0);
	int r, c, n;
	cin >> r >> c >> n;
	init_(r, c, n);
	rep(i, 1, n) cin >> a[i].x >> a[i].y;
	solve();
	int t; cin >> t;
	while(t--) {
		int x, y, x1, y1;
		cin >> x >> y;
		cin >> x1 >> y1;
		if(x1 < x || y1 < y) cout << "No\n";
		else if(x1 - x > n) cout << "No\n";
		else if(x1 == x) cout << "Yes\n";
		else if(mp.find(x) == mp.end()) cout << "No\n";
		else {
			auto it = s[mp[x]].lower_bound({y, 0});
			if(it == s[mp[x]].end()) cout << "No\n";
			else {
				int cur = gogo(it -> y, x1 - x - 1);
				if(cur <= y1) cout << "Yes\n";
				else cout << "No\n";
			}
		}
	}
	return 0;
}

Compilation message

trampoline.cpp:5: warning: ignoring '#pragma loop ' [-Wunknown-pragmas]
    5 | #pragma loop-opt(on)
      | 
trampoline.cpp:21:13: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   21 | void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L)==R], ++L;}
      |             ^~~~
trampoline.cpp:21:21: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   21 | void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L)==R], ++L;}
      |                     ^~~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2380 KB 200 token(s): yes count is 21, no count is 179
2 Correct 10 ms 2628 KB 200 token(s): yes count is 70, no count is 130
3 Correct 5 ms 1868 KB 197 token(s): yes count is 25, no count is 172
# Verdict Execution time Memory Grader output
1 Correct 270 ms 53836 KB 4000 token(s): yes count is 99, no count is 3901
2 Correct 264 ms 55496 KB 4000 token(s): yes count is 91, no count is 3909
3 Correct 294 ms 55112 KB 4000 token(s): yes count is 4000, no count is 0
4 Correct 299 ms 55580 KB 4000 token(s): yes count is 1991, no count is 2009
# Verdict Execution time Memory Grader output
1 Correct 408 ms 54444 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 395 ms 54336 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 479 ms 54296 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 529 ms 54472 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 488 ms 54600 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 626 ms 59012 KB 200000 token(s): yes count is 97163, no count is 102837
# Verdict Execution time Memory Grader output
1 Correct 8 ms 1740 KB 5000 token(s): yes count is 3238, no count is 1762
2 Correct 7 ms 1740 KB 5000 token(s): yes count is 3837, no count is 1163
3 Correct 10 ms 1992 KB 5000 token(s): yes count is 4104, no count is 896
4 Correct 20 ms 1680 KB 5000 token(s): yes count is 3934, no count is 1066
5 Correct 8 ms 1868 KB 5000 token(s): yes count is 3384, no count is 1616
6 Correct 6 ms 1772 KB 5000 token(s): yes count is 3390, no count is 1610
# Verdict Execution time Memory Grader output
1 Correct 811 ms 59952 KB 200000 token(s): yes count is 171404, no count is 28596
2 Correct 806 ms 56196 KB 200000 token(s): yes count is 161254, no count is 38746
3 Correct 534 ms 54868 KB 200000 token(s): yes count is 117455, no count is 82545
4 Correct 930 ms 67392 KB 200000 token(s): yes count is 182118, no count is 17882
5 Correct 629 ms 59360 KB 200000 token(s): yes count is 167565, no count is 32435
6 Correct 471 ms 54896 KB 200000 token(s): yes count is 156797, no count is 43203
7 Correct 497 ms 54880 KB 200000 token(s): yes count is 156797, no count is 43203
8 Correct 474 ms 54900 KB 200000 token(s): yes count is 122100, no count is 77900
9 Correct 720 ms 59128 KB 200000 token(s): yes count is 139670, no count is 60330
10 Correct 773 ms 59148 KB 200000 token(s): yes count is 165806, no count is 34194
11 Correct 842 ms 63340 KB 200000 token(s): yes count is 175646, no count is 24354
12 Correct 458 ms 54844 KB 200000 token(s): yes count is 134695, no count is 65305
13 Correct 428 ms 55024 KB 200000 token(s): yes count is 126733, no count is 73267
14 Incorrect 533 ms 55008 KB expected NO, found YES [36443rd token]
15 Halted 0 ms 0 KB -