답안 #339083

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
339083 2020-12-24T14:48:26 Z cheissmart Trampoline (info1cup20_trampoline) C++14
100 / 100
1477 ms 53592 KB
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << "Line(" << __LINE__ << ") -> " << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7, N = 2e5 + 7;

map<int, V<pi>> mp; 

int st[N][20];

signed main()
{
	IO_OP;
	
	memset(st, -1, sizeof st);

	int r, c, n;
	cin >> r >> c >> n;
	V<array<int, 3>> v(n);
	for(int i = 0; i < n; i++)
		cin >> v[i][0] >> v[i][1], v[i][2] = i;
	sort(ALL(v));
	vi yyy(n);
	for(auto p:v) {
		yyy[p[2]] = p[1];
		mp[p[0]].EB(p[1], p[2]);
	}

	for(auto& tt:mp) {
		int row = tt.F;
		for(pi p:tt.S) {
			int col = p.F, id = p.S;
			if(mp.count(row + 1) == 0) continue;
			auto it = lower_bound(ALL(mp[row+1]), MP(col, -INF));
			if(it != mp[row+1].end()) {
				int idd = it -> S;
				// id -> idd
				st[id][0] = idd;
			}
		}
	}
	for(int j = 1; j < 20; j++) {
		for(int i = 0; i < n; i++)
			if(st[i][j - 1] != -1) {
				st[i][j] = st[st[i][j - 1]][j - 1];
			}
	}
	int t;
	cin >> t;
	while(t--) {
		int x, y, xx, yy;
		cin >> x >> y >> xx >> yy;
		if(xx < x || yy < y) {
			cout << "No" << endl;
			continue;
		}
		if(x == xx) {
			cout << "Yes" << endl;
			continue;
		}
		xx--;
		auto it = lower_bound(ALL(mp[x]), MP(y, -INF));
		auto itt = upper_bound(ALL(mp[xx]), MP(yy, INF));
		if(it != mp[x].end() && itt != mp[xx].begin()) {
			itt--;
			int u = it -> S, v = itt -> S;
			int step = xx - x;
			for(int j = 0; j < 20; j++) {
				if(u == -1) break;
				if(step >> j & 1) {
					u = st[u][j];
				}
			}
			if(u != -1 && yyy[u] <= yyy[v]) cout << "Yes" << endl;
			else cout << "No" << endl;
		} else {
			cout << "No" << endl;
		}
	}
}

# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 16236 KB 200 token(s): yes count is 21, no count is 179
2 Correct 13 ms 16364 KB 200 token(s): yes count is 70, no count is 130
3 Correct 12 ms 16236 KB 197 token(s): yes count is 25, no count is 172
# 결과 실행 시간 메모리 Grader output
1 Correct 148 ms 22124 KB 4000 token(s): yes count is 99, no count is 3901
2 Correct 155 ms 23660 KB 4000 token(s): yes count is 91, no count is 3909
3 Correct 149 ms 22888 KB 4000 token(s): yes count is 4000, no count is 0
4 Correct 154 ms 23660 KB 4000 token(s): yes count is 1991, no count is 2009
# 결과 실행 시간 메모리 Grader output
1 Correct 739 ms 22252 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 764 ms 33640 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 782 ms 33252 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 828 ms 33900 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 829 ms 34028 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 966 ms 39788 KB 200000 token(s): yes count is 97163, no count is 102837
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 16236 KB 5000 token(s): yes count is 3238, no count is 1762
2 Correct 25 ms 16492 KB 5000 token(s): yes count is 3837, no count is 1163
3 Correct 27 ms 17004 KB 5000 token(s): yes count is 4104, no count is 896
4 Correct 25 ms 16620 KB 5000 token(s): yes count is 3934, no count is 1066
5 Correct 28 ms 16620 KB 5000 token(s): yes count is 3384, no count is 1616
6 Correct 24 ms 16620 KB 5000 token(s): yes count is 3390, no count is 1610
# 결과 실행 시간 메모리 Grader output
1 Correct 1168 ms 29612 KB 200000 token(s): yes count is 171404, no count is 28596
2 Correct 1080 ms 35816 KB 200000 token(s): yes count is 161254, no count is 38746
3 Correct 790 ms 33396 KB 200000 token(s): yes count is 117455, no count is 82545
4 Correct 1477 ms 53592 KB 200000 token(s): yes count is 182118, no count is 17882
5 Correct 1043 ms 40628 KB 200000 token(s): yes count is 167565, no count is 32435
6 Correct 809 ms 33768 KB 200000 token(s): yes count is 156797, no count is 43203
7 Correct 804 ms 33932 KB 200000 token(s): yes count is 156797, no count is 43203
8 Correct 774 ms 33424 KB 200000 token(s): yes count is 122100, no count is 77900
9 Correct 1178 ms 40000 KB 200000 token(s): yes count is 139670, no count is 60330
10 Correct 1217 ms 39916 KB 200000 token(s): yes count is 165806, no count is 34194
11 Correct 1383 ms 46188 KB 200000 token(s): yes count is 175646, no count is 24354
12 Correct 742 ms 33416 KB 200000 token(s): yes count is 134695, no count is 65305
13 Correct 748 ms 33900 KB 200000 token(s): yes count is 126733, no count is 73267
14 Correct 915 ms 34028 KB 200000 token(s): yes count is 155290, no count is 44710
15 Correct 751 ms 33760 KB 200000 token(s): yes count is 129674, no count is 70326