답안 #921040

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
921040 2024-02-03T09:05:51 Z yhkhoo Trampoline (info1cup20_trampoline) C++17
100 / 100
309 ms 24220 KB
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second

typedef pair<int, int> pii;

const int MAXN = 200005;
const int INF = 2e9;

int twok[MAXN][19];

int kpar(int x, int k){
	for(int i=0; i<19; i++){
		if(x == -1) return -1;
		if(k & (1<<i)) x = twok[x][i];
	}
	return x;
}

int main(){
	cin.tie(0); ios_base::sync_with_stdio(0);
	int X, Y, n;
	cin >> X >> Y >> n;
	pii gt[n];
	for(int i=0; i<n; i++){
		cin >> gt[i].fi >> gt[i].se;
		/*gt[i].fi--;
		gt[i].se--;*/
	}
	sort(gt, gt+n);
	for(int i=0; i<n; i++){
		int nx = lower_bound(gt, gt+n, make_pair(gt[i].fi+1, gt[i].se)) - gt;
		if(nx != n && gt[nx].fi == gt[i].fi+1){
			twok[i][0] = nx;
		}
		else{
			twok[i][0] = -1;
		}
		//cout << twok[i][0] << ' ';
	}
	//cout << '\n';
	for(int k=1; k<19; k++){
		for(int i=0; i<n; i++){
			if(twok[i][k-1] == -1){
				twok[i][k] = -1;
			}
			else{
				twok[i][k] = twok[twok[i][k-1]][k-1];
			}
			//cout << twok[i][k] << ' ';
		}
		//cout << '\n';
	}
	int t;
	cin >> t;
	while(t--){
		int x1, x2, y1, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		if(x1 > x2 || y1 > y2){
			cout << "No\n";
			continue;
		}
		if(x1 == x2){
			cout << "Yes\n";
			continue;
		}
		if(x2 - x1 > n){
			cout << "No\n";
			continue;
		}
		int cg = lower_bound(gt, gt+n, make_pair(x1, y1)) - gt;
		if(cg == n || gt[cg].fi != x1){
			cout << "No\n";
			continue;
		}
		int ym = kpar(cg, x2-x1-1);
		if(ym == -1){
			cout << "No\n";
		}
		else if(gt[ym].se <= y2){
			//cout << cg << ' ' << ym << ' ';
			cout << "Yes\n";
		}
		else{
			cout << "No\n";
		}
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2648 KB 200 token(s): yes count is 21, no count is 179
2 Correct 3 ms 2652 KB 200 token(s): yes count is 70, no count is 130
3 Correct 2 ms 2652 KB 197 token(s): yes count is 25, no count is 172
# 결과 실행 시간 메모리 Grader output
1 Correct 72 ms 16872 KB 4000 token(s): yes count is 99, no count is 3901
2 Correct 64 ms 16844 KB 4000 token(s): yes count is 91, no count is 3909
3 Correct 61 ms 16724 KB 4000 token(s): yes count is 4000, no count is 0
4 Correct 65 ms 16720 KB 4000 token(s): yes count is 1991, no count is 2009
# 결과 실행 시간 메모리 Grader output
1 Correct 183 ms 18008 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 174 ms 17556 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 155 ms 17492 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 167 ms 17648 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 164 ms 17396 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 163 ms 17344 KB 200000 token(s): yes count is 97163, no count is 102837
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2652 KB 5000 token(s): yes count is 3238, no count is 1762
2 Correct 4 ms 2652 KB 5000 token(s): yes count is 3837, no count is 1163
3 Correct 4 ms 2652 KB 5000 token(s): yes count is 4104, no count is 896
4 Correct 4 ms 2664 KB 5000 token(s): yes count is 3934, no count is 1066
5 Correct 5 ms 2652 KB 5000 token(s): yes count is 3384, no count is 1616
6 Correct 4 ms 2648 KB 5000 token(s): yes count is 3390, no count is 1610
# 결과 실행 시간 메모리 Grader output
1 Correct 232 ms 17492 KB 200000 token(s): yes count is 171404, no count is 28596
2 Correct 305 ms 23812 KB 200000 token(s): yes count is 161254, no count is 38746
3 Correct 180 ms 23876 KB 200000 token(s): yes count is 117455, no count is 82545
4 Correct 309 ms 24220 KB 200000 token(s): yes count is 182118, no count is 17882
5 Correct 191 ms 23892 KB 200000 token(s): yes count is 167565, no count is 32435
6 Correct 211 ms 24068 KB 200000 token(s): yes count is 156797, no count is 43203
7 Correct 205 ms 23888 KB 200000 token(s): yes count is 156797, no count is 43203
8 Correct 195 ms 23796 KB 200000 token(s): yes count is 122100, no count is 77900
9 Correct 225 ms 23924 KB 200000 token(s): yes count is 139670, no count is 60330
10 Correct 284 ms 23856 KB 200000 token(s): yes count is 165806, no count is 34194
11 Correct 301 ms 23976 KB 200000 token(s): yes count is 175646, no count is 24354
12 Correct 161 ms 23836 KB 200000 token(s): yes count is 134695, no count is 65305
13 Correct 176 ms 24004 KB 200000 token(s): yes count is 126733, no count is 73267
14 Correct 199 ms 23820 KB 200000 token(s): yes count is 155290, no count is 44710
15 Correct 178 ms 23980 KB 200000 token(s): yes count is 129674, no count is 70326