Submission #886075

# Submission time Handle Problem Language Result Execution time Memory
886075 2023-12-11T12:40:23 Z vjudge1 Curtains (NOI23_curtains) C++17
24 / 100
1500 ms 1048580 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 2005
#define M 500005

const int INF = 1e9 + 7;

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

	int n, m, q;
	cin>>n>>m>>q;
	if (n <= 2000){
		vector<bitset<N>> dp(n + 5, 0);
		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[l[i]].pb(r[i]);
		}

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

		for (int i = n; i >= 1; i--){
			sort(ex[i].begin(), ex[i].end());
			int last = i;
			bitset<N> all(0);
			all = ~all;
			for (auto j : ex[i]){
				dp[i][j] = 1;
				for (int k = last; k < j; k++) all[k] = 0;
				while(last <= j){
					last++;
					//cout<<last<<sp<<all<<endl;
					dp[i] |= dp[last] & all;
				}
				last--;
			}
			//cout<<i<<": "<<dp[i]<<endl;
			for (auto j : todo[i]){
				if (dp[i][j.st]) ans[j.nd] = 1;
			}
		}
		for (int i = 1; i <= q; i++) {
			if (ans[i]) cout<<"YES\n";
			else cout<<"NO\n";
		}
	}
	
	else{
		vector<bitset<M>> dp(n + 5, 0);

		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[l[i]].pb(r[i]);
		}

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

		for (int i = n; i >= 1; i--){
			sort(ex[i].begin(), ex[i].end());
			int last = i;
			bitset<M> all(0);
			all = ~all;
			for (auto j : ex[i]){
				dp[i][j] = 1;
				for (int k = last; k < j; k++) all[k] = 0;
				while(last <= j){
					last++;
					//cout<<last<<sp<<all<<endl;
					dp[i] |= dp[last] & all;
				}
				last--;
			}
			//cout<<i<<": "<<dp[i]<<endl;
			for (auto j : todo[i]){
				if (dp[i][j.st]) 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";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 604 KB Output is correct
2 Correct 0 ms 408 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 0 ms 604 KB Output is correct
12 Correct 0 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 604 KB Output is correct
2 Correct 0 ms 408 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 0 ms 604 KB Output is correct
12 Correct 0 ms 604 KB Output is correct
13 Correct 27 ms 1116 KB Output is correct
14 Correct 31 ms 1116 KB Output is correct
15 Correct 27 ms 1116 KB Output is correct
16 Correct 26 ms 1116 KB Output is correct
17 Correct 29 ms 1336 KB Output is correct
18 Correct 2 ms 1116 KB Output is correct
19 Correct 2 ms 1116 KB Output is correct
20 Correct 2 ms 1372 KB Output is correct
21 Correct 3 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 604 KB Output is correct
2 Correct 0 ms 408 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 0 ms 604 KB Output is correct
12 Correct 0 ms 604 KB Output is correct
13 Correct 27 ms 1116 KB Output is correct
14 Correct 31 ms 1116 KB Output is correct
15 Correct 27 ms 1116 KB Output is correct
16 Correct 26 ms 1116 KB Output is correct
17 Correct 29 ms 1336 KB Output is correct
18 Correct 2 ms 1116 KB Output is correct
19 Correct 2 ms 1116 KB Output is correct
20 Correct 2 ms 1372 KB Output is correct
21 Correct 3 ms 1116 KB Output is correct
22 Correct 92 ms 10792 KB Output is correct
23 Correct 133 ms 11344 KB Output is correct
24 Correct 150 ms 12624 KB Output is correct
25 Correct 219 ms 17912 KB Output is correct
26 Correct 116 ms 10964 KB Output is correct
27 Correct 221 ms 18032 KB Output is correct
28 Correct 214 ms 18000 KB Output is correct
29 Correct 87 ms 11088 KB Output is correct
30 Correct 99 ms 9152 KB Output is correct
31 Correct 122 ms 9912 KB Output is correct
32 Correct 206 ms 16324 KB Output is correct
33 Correct 72 ms 9408 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 604 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 34 ms 1116 KB Output is correct
6 Correct 2 ms 1112 KB Output is correct
7 Correct 2 ms 1116 KB Output is correct
8 Correct 99 ms 9072 KB Output is correct
9 Correct 131 ms 9924 KB Output is correct
10 Correct 259 ms 16376 KB Output is correct
11 Correct 62 ms 9408 KB Output is correct
12 Runtime error 516 ms 1048580 KB Execution killed with signal 9
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 604 KB Output is correct
2 Correct 0 ms 408 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 0 ms 604 KB Output is correct
12 Correct 0 ms 604 KB Output is correct
13 Correct 27 ms 1116 KB Output is correct
14 Correct 31 ms 1116 KB Output is correct
15 Correct 27 ms 1116 KB Output is correct
16 Correct 26 ms 1116 KB Output is correct
17 Correct 29 ms 1336 KB Output is correct
18 Correct 2 ms 1116 KB Output is correct
19 Correct 2 ms 1116 KB Output is correct
20 Correct 2 ms 1372 KB Output is correct
21 Correct 3 ms 1116 KB Output is correct
22 Execution timed out 1549 ms 617476 KB Time limit exceeded
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 604 KB Output is correct
2 Correct 0 ms 408 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 0 ms 604 KB Output is correct
12 Correct 0 ms 604 KB Output is correct
13 Correct 27 ms 1116 KB Output is correct
14 Correct 31 ms 1116 KB Output is correct
15 Correct 27 ms 1116 KB Output is correct
16 Correct 26 ms 1116 KB Output is correct
17 Correct 29 ms 1336 KB Output is correct
18 Correct 2 ms 1116 KB Output is correct
19 Correct 2 ms 1116 KB Output is correct
20 Correct 2 ms 1372 KB Output is correct
21 Correct 3 ms 1116 KB Output is correct
22 Correct 92 ms 10792 KB Output is correct
23 Correct 133 ms 11344 KB Output is correct
24 Correct 150 ms 12624 KB Output is correct
25 Correct 219 ms 17912 KB Output is correct
26 Correct 116 ms 10964 KB Output is correct
27 Correct 221 ms 18032 KB Output is correct
28 Correct 214 ms 18000 KB Output is correct
29 Correct 87 ms 11088 KB Output is correct
30 Correct 99 ms 9152 KB Output is correct
31 Correct 122 ms 9912 KB Output is correct
32 Correct 206 ms 16324 KB Output is correct
33 Correct 72 ms 9408 KB Output is correct
34 Correct 0 ms 604 KB Output is correct
35 Correct 2 ms 604 KB Output is correct
36 Correct 1 ms 604 KB Output is correct
37 Correct 1 ms 604 KB Output is correct
38 Correct 34 ms 1116 KB Output is correct
39 Correct 2 ms 1112 KB Output is correct
40 Correct 2 ms 1116 KB Output is correct
41 Correct 99 ms 9072 KB Output is correct
42 Correct 131 ms 9924 KB Output is correct
43 Correct 259 ms 16376 KB Output is correct
44 Correct 62 ms 9408 KB Output is correct
45 Runtime error 516 ms 1048580 KB Execution killed with signal 9
46 Halted 0 ms 0 KB -