Submission #886091

# Submission time Handle Problem Language Result Execution time Memory
886091 2023-12-11T12:54:34 Z vjudge1 Curtains (NOI23_curtains) C++17
0 / 100
9 ms 17244 KB
#include <bits/stdc++.h>
using namespace std;
#define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define fastio() cin.tie(0), ios_base::sync_with_stdio(0)
#define sp " "
//#define endl "\n"
#define pii pair<int, int>
#define st first
#define nd second
#define pb push_back
#define N 500005
#define M 500005
#define L(node) node * 2
#define R(node) node * 2 + 1

const int INF = 1e9 + 7;
int lazy[4 * N];
pii tree[4 * N];

void push(int node, int l, int r){
	tree[node].st += lazy[node];
	if (l != r){
		lazy[L(node)] += lazy[node];
		lazy[R(node)] += lazy[node];
	}
	lazy[node] = 0;
}

pii merge(pii a, pii b){
	if (a.st == b.st) return {a.st, a.nd + b.nd};
	return min(a, b);
}

void update(int node, int l, int r, int sl, int sr, int val){
	push(node, l, r);
	if (l > sr || r < sl) return;
	if (l >= sl && r <= sr){
		lazy[node] += val;
		push(node, l, r);
		return;
	}
	int mid = (l + r) / 2;
	update(L(node), l, mid, sl, sr, val);
	update(R(node), mid + 1, r, sl, sr, val);
	tree[node] = merge(tree[L(node)], tree[R(node)]);
}


void build(int node, int l, int r){
	tree[node] = {0, r - l + 1};
	if (l == r) return;
	int mid = (l + r) / 2;
	build(L(node), l, mid);
	build(R(node), mid + 1, r);
}

pii query(int node, int l, int r, int sl, int sr){
	push(node, l, r);
	if (l > sr || r < sl) return {INF, 0};
	if (l >= sl && r <= sr) return tree[node];
	int mid = (l + r) / 2;
	return merge(query(L(node), l, mid, sl, sr), query(R(node), mid + 1, r, sl, sr));
}


int32_t main(){
	fileio();
	fastio();

	int n, m, q;
	cin>>n>>m>>q;
	build(1, 1, n);

	vector<int> l(m + 5, 0), r(m + 5, 0), ans(q + 5, 0);
	vector<vector<int>> ex(n + 5);
	vector<vector<pii>> todo(n + 5);
	for (int i = 1; i <= m; i++){
		cin>>l[i]>>r[i];
		ex[r[i]].pb(l[i]);
	}

	for (int i = 1; i <= q; i++){
		int s, e;
		cin>>s>>e;
		todo[e].pb({s, i});
	}

	for (int i = 1; i <= n; i++){
		for (auto j : ex[i]){
			update(1, 1, n, j, i, 1);
		}
		
		for (auto j : todo[i]){
			if (query(1, 1, n, j.st, i).st != 0) ans[j.nd] = 1;
		}
	}
	
	for (int i = 1; i <= q; i++) {
		if (ans[i]) cout<<"YES\n";
		else cout<<"NO\n";
	}

	cerr<<"time taken : "<<(float)clock() / CLOCKS_PER_SEC<<" seconds\n";
}

Compilation message

curtains.cpp: In function 'int32_t main()':
curtains.cpp:3:25: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    3 | #define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
      |                  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
curtains.cpp:67:2: note: in expansion of macro 'fileio'
   67 |  fileio();
      |  ^~~~~~
curtains.cpp:3:59: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    3 | #define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
      |                                                    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
curtains.cpp:67:2: note: in expansion of macro 'fileio'
   67 |  fileio();
      |  ^~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 9 ms 17244 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 9 ms 17244 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 9 ms 17244 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 9 ms 17244 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 9 ms 17244 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 9 ms 17244 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -