답안 #882929

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
882929 2023-12-04T07:35:37 Z tsumondai Curtains (NOI23_curtains) C++14
100 / 100
794 ms 73892 KB
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define foru(i, l, r) for(int i = l; i <= r; i++)
#define ford(i, r, l) for(int i = r; i >= l; i--)
#define __TIME  (1.0 * clock() / CLOCKS_PER_SEC)

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

const int N = 5e5 + 5;

const int oo = 1e9, mod = 1e9 + 7;

int n, m, k, q;
bool res[N];
vector<int> events[N];
vector<ii> queries[N];

void maximize (int &a, int b) {
	a = max(a, b);
}

struct STree {
	int node[N * 4], lazy[N * 4];

	void down (int id, int l, int r) {
		if (lazy[id] == 0) return;
		maximize(node[id], lazy[id]);
		if (l != r) {
			maximize(lazy[id * 2], lazy[id]);
			maximize(lazy[id * 2 + 1], lazy[id]);
		}
		lazy[id] = 0;
	}

	void update (int id, int l, int r, int u, int v, int val) {
		down(id, l, r);
		if (l > v || r < u) return;
		if (l >= u && r <= v) {
			lazy[id] = val;
			down(id, l, r);
			return;
		}
		int mid = l + r >> 1;
		update(id * 2, l, mid, u, v, val);
		update(id * 2 + 1, mid + 1, r, u, v, val);
		node[id] = min(node[id * 2], node[id * 2 + 1]);
	}

	int get (int id, int l, int r, int u, int v) {
		down(id, l, r);
		if (l > v || r < u) return 1e9;
		if (l >= u && r <= v) return node[id];
		int mid = l + r >> 1;
		return min(get(id * 2, l, mid, u, v), get(id * 2 + 1, mid + 1, r, u, v));
	}
} st;

void process() {
	cin >> n >> m >> q;
	foru(i, 1, m) {
		int l, r; cin >> l >> r;
		events[r].push_back(l);
	}
	foru(i, 1, q) {
		int l, r; cin >> l >> r;
		queries[r].push_back({l, i});
	}
	foru(r, 1, n) {
		for (int l : events[r]) {
			st.update(1, 1, n, l, r, l);
		}
		for (ii it : queries[r]) {
			int l = it.fi;
			int id = it.se;
			if (st.get(1, 1, n, l, r) >= l) {
				res[id] = true;
			}
		}
	}
	foru(i, 1, q) {
		cout << (res[i] ? "YES\n" : "NO\n");
	}
	return;
}

signed main() {
	cin.tie(0)->sync_with_stdio(false);
	//freopen(".inp", "r", stdin);
	//freopen(".out", "w", stdout);
	process();
	cerr << "Time elapsed: " << __TIME << " s.\n";
	return 0;
}

/*
Xét các trường hợp đặc biệt
Kiểm tra lại input/output
Cố gắng trâu
Lật ngược bài toán
Keep calm and get VOI
Flow:

*/

Compilation message

curtains.cpp: In member function 'void STree::update(int, int, int, int, int, int)':
curtains.cpp:50:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   50 |   int mid = l + r >> 1;
      |             ~~^~~
curtains.cpp: In member function 'int STree::get(int, int, int, int, int)':
curtains.cpp:60:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   60 |   int mid = l + r >> 1;
      |             ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 24924 KB Output is correct
2 Correct 6 ms 25084 KB Output is correct
3 Correct 6 ms 25180 KB Output is correct
4 Correct 5 ms 25092 KB Output is correct
5 Correct 5 ms 25044 KB Output is correct
6 Correct 6 ms 24924 KB Output is correct
7 Correct 5 ms 25088 KB Output is correct
8 Correct 6 ms 24924 KB Output is correct
9 Correct 6 ms 24992 KB Output is correct
10 Correct 5 ms 24924 KB Output is correct
11 Correct 5 ms 25036 KB Output is correct
12 Correct 5 ms 24924 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 24924 KB Output is correct
2 Correct 6 ms 25084 KB Output is correct
3 Correct 6 ms 25180 KB Output is correct
4 Correct 5 ms 25092 KB Output is correct
5 Correct 5 ms 25044 KB Output is correct
6 Correct 6 ms 24924 KB Output is correct
7 Correct 5 ms 25088 KB Output is correct
8 Correct 6 ms 24924 KB Output is correct
9 Correct 6 ms 24992 KB Output is correct
10 Correct 5 ms 24924 KB Output is correct
11 Correct 5 ms 25036 KB Output is correct
12 Correct 5 ms 24924 KB Output is correct
13 Correct 7 ms 25180 KB Output is correct
14 Correct 8 ms 25180 KB Output is correct
15 Correct 8 ms 25116 KB Output is correct
16 Correct 7 ms 25180 KB Output is correct
17 Correct 7 ms 25176 KB Output is correct
18 Correct 6 ms 25176 KB Output is correct
19 Correct 7 ms 25176 KB Output is correct
20 Correct 7 ms 25180 KB Output is correct
21 Correct 7 ms 25020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 24924 KB Output is correct
2 Correct 6 ms 25084 KB Output is correct
3 Correct 6 ms 25180 KB Output is correct
4 Correct 5 ms 25092 KB Output is correct
5 Correct 5 ms 25044 KB Output is correct
6 Correct 6 ms 24924 KB Output is correct
7 Correct 5 ms 25088 KB Output is correct
8 Correct 6 ms 24924 KB Output is correct
9 Correct 6 ms 24992 KB Output is correct
10 Correct 5 ms 24924 KB Output is correct
11 Correct 5 ms 25036 KB Output is correct
12 Correct 5 ms 24924 KB Output is correct
13 Correct 7 ms 25180 KB Output is correct
14 Correct 8 ms 25180 KB Output is correct
15 Correct 8 ms 25116 KB Output is correct
16 Correct 7 ms 25180 KB Output is correct
17 Correct 7 ms 25176 KB Output is correct
18 Correct 6 ms 25176 KB Output is correct
19 Correct 7 ms 25176 KB Output is correct
20 Correct 7 ms 25180 KB Output is correct
21 Correct 7 ms 25020 KB Output is correct
22 Correct 149 ms 37692 KB Output is correct
23 Correct 149 ms 38120 KB Output is correct
24 Correct 174 ms 39344 KB Output is correct
25 Correct 300 ms 45204 KB Output is correct
26 Correct 156 ms 37968 KB Output is correct
27 Correct 304 ms 45176 KB Output is correct
28 Correct 334 ms 45136 KB Output is correct
29 Correct 139 ms 36764 KB Output is correct
30 Correct 110 ms 36856 KB Output is correct
31 Correct 106 ms 37716 KB Output is correct
32 Correct 264 ms 44368 KB Output is correct
33 Correct 94 ms 36940 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 24924 KB Output is correct
2 Correct 6 ms 24920 KB Output is correct
3 Correct 8 ms 24920 KB Output is correct
4 Correct 7 ms 24924 KB Output is correct
5 Correct 7 ms 25180 KB Output is correct
6 Correct 7 ms 25264 KB Output is correct
7 Correct 6 ms 25432 KB Output is correct
8 Correct 93 ms 36928 KB Output is correct
9 Correct 114 ms 37668 KB Output is correct
10 Correct 262 ms 44388 KB Output is correct
11 Correct 91 ms 36952 KB Output is correct
12 Correct 98 ms 34208 KB Output is correct
13 Correct 116 ms 34224 KB Output is correct
14 Correct 79 ms 34156 KB Output is correct
15 Correct 94 ms 33916 KB Output is correct
16 Correct 88 ms 34108 KB Output is correct
17 Correct 78 ms 33872 KB Output is correct
18 Correct 680 ms 70840 KB Output is correct
19 Correct 692 ms 70864 KB Output is correct
20 Correct 554 ms 71272 KB Output is correct
21 Correct 516 ms 70164 KB Output is correct
22 Correct 521 ms 69496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 24924 KB Output is correct
2 Correct 6 ms 25084 KB Output is correct
3 Correct 6 ms 25180 KB Output is correct
4 Correct 5 ms 25092 KB Output is correct
5 Correct 5 ms 25044 KB Output is correct
6 Correct 6 ms 24924 KB Output is correct
7 Correct 5 ms 25088 KB Output is correct
8 Correct 6 ms 24924 KB Output is correct
9 Correct 6 ms 24992 KB Output is correct
10 Correct 5 ms 24924 KB Output is correct
11 Correct 5 ms 25036 KB Output is correct
12 Correct 5 ms 24924 KB Output is correct
13 Correct 7 ms 25180 KB Output is correct
14 Correct 8 ms 25180 KB Output is correct
15 Correct 8 ms 25116 KB Output is correct
16 Correct 7 ms 25180 KB Output is correct
17 Correct 7 ms 25176 KB Output is correct
18 Correct 6 ms 25176 KB Output is correct
19 Correct 7 ms 25176 KB Output is correct
20 Correct 7 ms 25180 KB Output is correct
21 Correct 7 ms 25020 KB Output is correct
22 Correct 95 ms 29732 KB Output is correct
23 Correct 83 ms 29780 KB Output is correct
24 Correct 118 ms 33616 KB Output is correct
25 Correct 115 ms 33448 KB Output is correct
26 Correct 88 ms 34600 KB Output is correct
27 Correct 104 ms 34896 KB Output is correct
28 Correct 70 ms 32488 KB Output is correct
29 Correct 86 ms 34056 KB Output is correct
30 Correct 112 ms 33580 KB Output is correct
31 Correct 130 ms 33456 KB Output is correct
32 Correct 102 ms 33932 KB Output is correct
33 Correct 110 ms 34360 KB Output is correct
34 Correct 106 ms 33068 KB Output is correct
35 Correct 112 ms 33224 KB Output is correct
36 Correct 104 ms 33872 KB Output is correct
37 Correct 108 ms 34384 KB Output is correct
38 Correct 93 ms 34384 KB Output is correct
39 Correct 78 ms 34256 KB Output is correct
40 Correct 76 ms 33936 KB Output is correct
41 Correct 83 ms 34128 KB Output is correct
42 Correct 84 ms 33784 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 24924 KB Output is correct
2 Correct 6 ms 25084 KB Output is correct
3 Correct 6 ms 25180 KB Output is correct
4 Correct 5 ms 25092 KB Output is correct
5 Correct 5 ms 25044 KB Output is correct
6 Correct 6 ms 24924 KB Output is correct
7 Correct 5 ms 25088 KB Output is correct
8 Correct 6 ms 24924 KB Output is correct
9 Correct 6 ms 24992 KB Output is correct
10 Correct 5 ms 24924 KB Output is correct
11 Correct 5 ms 25036 KB Output is correct
12 Correct 5 ms 24924 KB Output is correct
13 Correct 7 ms 25180 KB Output is correct
14 Correct 8 ms 25180 KB Output is correct
15 Correct 8 ms 25116 KB Output is correct
16 Correct 7 ms 25180 KB Output is correct
17 Correct 7 ms 25176 KB Output is correct
18 Correct 6 ms 25176 KB Output is correct
19 Correct 7 ms 25176 KB Output is correct
20 Correct 7 ms 25180 KB Output is correct
21 Correct 7 ms 25020 KB Output is correct
22 Correct 149 ms 37692 KB Output is correct
23 Correct 149 ms 38120 KB Output is correct
24 Correct 174 ms 39344 KB Output is correct
25 Correct 300 ms 45204 KB Output is correct
26 Correct 156 ms 37968 KB Output is correct
27 Correct 304 ms 45176 KB Output is correct
28 Correct 334 ms 45136 KB Output is correct
29 Correct 139 ms 36764 KB Output is correct
30 Correct 110 ms 36856 KB Output is correct
31 Correct 106 ms 37716 KB Output is correct
32 Correct 264 ms 44368 KB Output is correct
33 Correct 94 ms 36940 KB Output is correct
34 Correct 7 ms 24924 KB Output is correct
35 Correct 6 ms 24920 KB Output is correct
36 Correct 8 ms 24920 KB Output is correct
37 Correct 7 ms 24924 KB Output is correct
38 Correct 7 ms 25180 KB Output is correct
39 Correct 7 ms 25264 KB Output is correct
40 Correct 6 ms 25432 KB Output is correct
41 Correct 93 ms 36928 KB Output is correct
42 Correct 114 ms 37668 KB Output is correct
43 Correct 262 ms 44388 KB Output is correct
44 Correct 91 ms 36952 KB Output is correct
45 Correct 98 ms 34208 KB Output is correct
46 Correct 116 ms 34224 KB Output is correct
47 Correct 79 ms 34156 KB Output is correct
48 Correct 94 ms 33916 KB Output is correct
49 Correct 88 ms 34108 KB Output is correct
50 Correct 78 ms 33872 KB Output is correct
51 Correct 680 ms 70840 KB Output is correct
52 Correct 692 ms 70864 KB Output is correct
53 Correct 554 ms 71272 KB Output is correct
54 Correct 516 ms 70164 KB Output is correct
55 Correct 521 ms 69496 KB Output is correct
56 Correct 95 ms 29732 KB Output is correct
57 Correct 83 ms 29780 KB Output is correct
58 Correct 118 ms 33616 KB Output is correct
59 Correct 115 ms 33448 KB Output is correct
60 Correct 88 ms 34600 KB Output is correct
61 Correct 104 ms 34896 KB Output is correct
62 Correct 70 ms 32488 KB Output is correct
63 Correct 86 ms 34056 KB Output is correct
64 Correct 112 ms 33580 KB Output is correct
65 Correct 130 ms 33456 KB Output is correct
66 Correct 102 ms 33932 KB Output is correct
67 Correct 110 ms 34360 KB Output is correct
68 Correct 106 ms 33068 KB Output is correct
69 Correct 112 ms 33224 KB Output is correct
70 Correct 104 ms 33872 KB Output is correct
71 Correct 108 ms 34384 KB Output is correct
72 Correct 93 ms 34384 KB Output is correct
73 Correct 78 ms 34256 KB Output is correct
74 Correct 76 ms 33936 KB Output is correct
75 Correct 83 ms 34128 KB Output is correct
76 Correct 84 ms 33784 KB Output is correct
77 Correct 790 ms 67412 KB Output is correct
78 Correct 768 ms 67412 KB Output is correct
79 Correct 652 ms 72984 KB Output is correct
80 Correct 651 ms 73892 KB Output is correct
81 Correct 619 ms 71300 KB Output is correct
82 Correct 589 ms 72064 KB Output is correct
83 Correct 794 ms 67620 KB Output is correct
84 Correct 743 ms 67444 KB Output is correct
85 Correct 734 ms 68984 KB Output is correct
86 Correct 701 ms 65528 KB Output is correct
87 Correct 641 ms 65440 KB Output is correct
88 Correct 635 ms 72020 KB Output is correct