답안 #887050

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
887050 2023-12-13T14:40:43 Z fanwen Curtains (NOI23_curtains) C++17
45 / 100
153 ms 28816 KB
/* author : bo may can 5 */

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define endl '\n'
#define file(name)                  \
    if(fopen(name".inp", "r"))      \
        freopen(name".inp", "r", stdin), freopen(name".out", "w", stdout); 

const int MAX = 1e5 + 5;

int n, m, q;
vector <pair <int, int>> queries[MAX];
vector <int> events[MAX];

int ans[MAX], it[MAX << 2], lazy[MAX << 2];

void down(int idx) {
	if(lazy[idx] == 0) return;
	for (int i = 2 * idx; i <= 2 * idx + 1; ++i) {
		it[i] = max(it[i], lazy[idx]);
		lazy[i] = max(lazy[i], lazy[idx]);
	}
	lazy[idx] = 0;
}

void update(int idx, int l, int r, int u, int v, int val) {
	if(l > v || r < u) return;
	if(l >= u && r <= v) {
		it[idx] = max(it[idx], val);
		lazy[idx] = max(lazy[idx], val);
		return;
	}

	down(idx);

	int mid = l + r >> 1;
	update(idx << 1, l, mid, u, v, val);
	update(idx << 1 | 1, mid + 1, r, u, v, val);

	it[idx] = min(it[idx << 1], it[idx << 1 | 1]);
}

int get(int idx, int l, int r, int u, int v) {
	if(l > v || r < u) return 1e9;

	if(l >= u && r <= v) return it[idx];

	down(idx);

	int mid = l + r >> 1;

	return min(get(idx << 1, l, mid, u, v), get(idx << 1 | 1, mid + 1, r, u, v));
}

void you_make_it(void) {
    cin >> n >> m >> q;
    for (int i = 1; i <= m; ++i) {
    	int l, r; cin >> l >> r;
    	events[r].emplace_back(l);
    }

    for (int i = 1; i <= q; ++i) {
    	int l, r; cin >> l >> r;
    	queries[r].emplace_back(l, i);
    }
    for (int r = 1; r <= n; ++r) {
    	for (auto l : events[r]) update(1, 1, n, l, r, l);
    	for (auto [l, i] : queries[r]) {
    		if(get(1, 1, n, l, r) >= l) ans[i] = 1;
    	}
    }
    for (int i = 1; i <= q; ++i) cout << (ans[i] ? "YES\n" : "NO\n");
}

signed main() {

#ifdef LOCAL
    freopen("TASK.inp", "r", stdin);
    freopen("TASK.out", "w", stdout);
#endif
    file("curtains");
    auto start_time = chrono::steady_clock::now();

    cin.tie(0), cout.tie(0) -> sync_with_stdio(0);

    you_make_it();

    auto end_time = chrono::steady_clock::now();

    cerr << "\nExecution time : " << chrono::duration_cast <chrono::milliseconds> (end_time - start_time).count() << "[ms]" << endl;

    return (0 ^ 0);
}

// Dream it. Wish it. Do it.

Compilation message

curtains.cpp: In function 'void update(int, int, int, int, int, int)':
curtains.cpp:41:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   41 |  int mid = l + r >> 1;
      |            ~~^~~
curtains.cpp: In function 'int get(int, int, int, int, int)':
curtains.cpp:55:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   55 |  int mid = l + r >> 1;
      |            ~~^~~
curtains.cpp: In function 'int main()':
curtains.cpp:12:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |         freopen(name".inp", "r", stdin), freopen(name".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
curtains.cpp:86:5: note: in expansion of macro 'file'
   86 |     file("curtains");
      |     ^~~~
curtains.cpp:12:49: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |         freopen(name".inp", "r", stdin), freopen(name".out", "w", stdout);
      |                                          ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
curtains.cpp:86:5: note: in expansion of macro 'file'
   86 |     file("curtains");
      |     ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6236 KB Output is correct
2 Correct 2 ms 6236 KB Output is correct
3 Correct 2 ms 6488 KB Output is correct
4 Correct 2 ms 6236 KB Output is correct
5 Correct 2 ms 6236 KB Output is correct
6 Correct 2 ms 6236 KB Output is correct
7 Correct 2 ms 6448 KB Output is correct
8 Correct 2 ms 6236 KB Output is correct
9 Correct 2 ms 6236 KB Output is correct
10 Correct 3 ms 6488 KB Output is correct
11 Correct 2 ms 6488 KB Output is correct
12 Correct 2 ms 6236 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6236 KB Output is correct
2 Correct 2 ms 6236 KB Output is correct
3 Correct 2 ms 6488 KB Output is correct
4 Correct 2 ms 6236 KB Output is correct
5 Correct 2 ms 6236 KB Output is correct
6 Correct 2 ms 6236 KB Output is correct
7 Correct 2 ms 6448 KB Output is correct
8 Correct 2 ms 6236 KB Output is correct
9 Correct 2 ms 6236 KB Output is correct
10 Correct 3 ms 6488 KB Output is correct
11 Correct 2 ms 6488 KB Output is correct
12 Correct 2 ms 6236 KB Output is correct
13 Correct 3 ms 6488 KB Output is correct
14 Correct 3 ms 6744 KB Output is correct
15 Correct 3 ms 6520 KB Output is correct
16 Correct 4 ms 6492 KB Output is correct
17 Correct 3 ms 6516 KB Output is correct
18 Correct 3 ms 6492 KB Output is correct
19 Correct 3 ms 6492 KB Output is correct
20 Correct 3 ms 6492 KB Output is correct
21 Correct 3 ms 6492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6236 KB Output is correct
2 Correct 2 ms 6236 KB Output is correct
3 Correct 2 ms 6488 KB Output is correct
4 Correct 2 ms 6236 KB Output is correct
5 Correct 2 ms 6236 KB Output is correct
6 Correct 2 ms 6236 KB Output is correct
7 Correct 2 ms 6448 KB Output is correct
8 Correct 2 ms 6236 KB Output is correct
9 Correct 2 ms 6236 KB Output is correct
10 Correct 3 ms 6488 KB Output is correct
11 Correct 2 ms 6488 KB Output is correct
12 Correct 2 ms 6236 KB Output is correct
13 Correct 3 ms 6488 KB Output is correct
14 Correct 3 ms 6744 KB Output is correct
15 Correct 3 ms 6520 KB Output is correct
16 Correct 4 ms 6492 KB Output is correct
17 Correct 3 ms 6516 KB Output is correct
18 Correct 3 ms 6492 KB Output is correct
19 Correct 3 ms 6492 KB Output is correct
20 Correct 3 ms 6492 KB Output is correct
21 Correct 3 ms 6492 KB Output is correct
22 Runtime error 76 ms 28816 KB Execution killed with signal 11
23 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6232 KB Output is correct
2 Correct 2 ms 6236 KB Output is correct
3 Correct 2 ms 6232 KB Output is correct
4 Correct 2 ms 6236 KB Output is correct
5 Correct 3 ms 6492 KB Output is correct
6 Correct 3 ms 6492 KB Output is correct
7 Correct 3 ms 6492 KB Output is correct
8 Runtime error 68 ms 25664 KB Execution killed with signal 11
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6236 KB Output is correct
2 Correct 2 ms 6236 KB Output is correct
3 Correct 2 ms 6488 KB Output is correct
4 Correct 2 ms 6236 KB Output is correct
5 Correct 2 ms 6236 KB Output is correct
6 Correct 2 ms 6236 KB Output is correct
7 Correct 2 ms 6448 KB Output is correct
8 Correct 2 ms 6236 KB Output is correct
9 Correct 2 ms 6236 KB Output is correct
10 Correct 3 ms 6488 KB Output is correct
11 Correct 2 ms 6488 KB Output is correct
12 Correct 2 ms 6236 KB Output is correct
13 Correct 3 ms 6488 KB Output is correct
14 Correct 3 ms 6744 KB Output is correct
15 Correct 3 ms 6520 KB Output is correct
16 Correct 4 ms 6492 KB Output is correct
17 Correct 3 ms 6516 KB Output is correct
18 Correct 3 ms 6492 KB Output is correct
19 Correct 3 ms 6492 KB Output is correct
20 Correct 3 ms 6492 KB Output is correct
21 Correct 3 ms 6492 KB Output is correct
22 Correct 97 ms 10832 KB Output is correct
23 Correct 86 ms 10836 KB Output is correct
24 Correct 123 ms 14148 KB Output is correct
25 Correct 115 ms 14112 KB Output is correct
26 Correct 123 ms 15440 KB Output is correct
27 Correct 95 ms 15796 KB Output is correct
28 Correct 73 ms 13136 KB Output is correct
29 Correct 100 ms 14784 KB Output is correct
30 Correct 153 ms 14368 KB Output is correct
31 Correct 127 ms 14296 KB Output is correct
32 Correct 98 ms 14528 KB Output is correct
33 Correct 92 ms 14928 KB Output is correct
34 Correct 127 ms 14144 KB Output is correct
35 Correct 102 ms 13908 KB Output is correct
36 Correct 95 ms 14516 KB Output is correct
37 Correct 87 ms 14960 KB Output is correct
38 Correct 90 ms 15136 KB Output is correct
39 Correct 69 ms 15228 KB Output is correct
40 Correct 67 ms 14716 KB Output is correct
41 Correct 69 ms 15184 KB Output is correct
42 Correct 67 ms 14676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6236 KB Output is correct
2 Correct 2 ms 6236 KB Output is correct
3 Correct 2 ms 6488 KB Output is correct
4 Correct 2 ms 6236 KB Output is correct
5 Correct 2 ms 6236 KB Output is correct
6 Correct 2 ms 6236 KB Output is correct
7 Correct 2 ms 6448 KB Output is correct
8 Correct 2 ms 6236 KB Output is correct
9 Correct 2 ms 6236 KB Output is correct
10 Correct 3 ms 6488 KB Output is correct
11 Correct 2 ms 6488 KB Output is correct
12 Correct 2 ms 6236 KB Output is correct
13 Correct 3 ms 6488 KB Output is correct
14 Correct 3 ms 6744 KB Output is correct
15 Correct 3 ms 6520 KB Output is correct
16 Correct 4 ms 6492 KB Output is correct
17 Correct 3 ms 6516 KB Output is correct
18 Correct 3 ms 6492 KB Output is correct
19 Correct 3 ms 6492 KB Output is correct
20 Correct 3 ms 6492 KB Output is correct
21 Correct 3 ms 6492 KB Output is correct
22 Runtime error 76 ms 28816 KB Execution killed with signal 11
23 Halted 0 ms 0 KB -