답안 #886074

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
886074 2023-12-11T12:38:57 Z vjudge1 Curtains (NOI23_curtains) C++17
3 / 100
1500 ms 25180 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 100005
#define M 500005

const int INF = 1e9 + 7;

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

	int n, m, q;
	cin>>n>>m>>q;
	if (n <= 100000){
		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";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 19 ms 3164 KB Output is correct
4 Correct 19 ms 3164 KB Output is correct
5 Correct 18 ms 3416 KB Output is correct
6 Correct 16 ms 3164 KB Output is correct
7 Correct 14 ms 3164 KB Output is correct
8 Correct 17 ms 3160 KB Output is correct
9 Correct 3 ms 3164 KB Output is correct
10 Correct 4 ms 3164 KB Output is correct
11 Correct 2 ms 3164 KB Output is correct
12 Correct 4 ms 3164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 19 ms 3164 KB Output is correct
4 Correct 19 ms 3164 KB Output is correct
5 Correct 18 ms 3416 KB Output is correct
6 Correct 16 ms 3164 KB Output is correct
7 Correct 14 ms 3164 KB Output is correct
8 Correct 17 ms 3160 KB Output is correct
9 Correct 3 ms 3164 KB Output is correct
10 Correct 4 ms 3164 KB Output is correct
11 Correct 2 ms 3164 KB Output is correct
12 Correct 4 ms 3164 KB Output is correct
13 Execution timed out 1576 ms 25180 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 19 ms 3164 KB Output is correct
4 Correct 19 ms 3164 KB Output is correct
5 Correct 18 ms 3416 KB Output is correct
6 Correct 16 ms 3164 KB Output is correct
7 Correct 14 ms 3164 KB Output is correct
8 Correct 17 ms 3160 KB Output is correct
9 Correct 3 ms 3164 KB Output is correct
10 Correct 4 ms 3164 KB Output is correct
11 Correct 2 ms 3164 KB Output is correct
12 Correct 4 ms 3164 KB Output is correct
13 Execution timed out 1576 ms 25180 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 604 KB Output is correct
2 Correct 17 ms 3164 KB Output is correct
3 Correct 3 ms 3160 KB Output is correct
4 Correct 3 ms 3164 KB Output is correct
5 Execution timed out 1589 ms 25180 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 19 ms 3164 KB Output is correct
4 Correct 19 ms 3164 KB Output is correct
5 Correct 18 ms 3416 KB Output is correct
6 Correct 16 ms 3164 KB Output is correct
7 Correct 14 ms 3164 KB Output is correct
8 Correct 17 ms 3160 KB Output is correct
9 Correct 3 ms 3164 KB Output is correct
10 Correct 4 ms 3164 KB Output is correct
11 Correct 2 ms 3164 KB Output is correct
12 Correct 4 ms 3164 KB Output is correct
13 Execution timed out 1576 ms 25180 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 19 ms 3164 KB Output is correct
4 Correct 19 ms 3164 KB Output is correct
5 Correct 18 ms 3416 KB Output is correct
6 Correct 16 ms 3164 KB Output is correct
7 Correct 14 ms 3164 KB Output is correct
8 Correct 17 ms 3160 KB Output is correct
9 Correct 3 ms 3164 KB Output is correct
10 Correct 4 ms 3164 KB Output is correct
11 Correct 2 ms 3164 KB Output is correct
12 Correct 4 ms 3164 KB Output is correct
13 Execution timed out 1576 ms 25180 KB Time limit exceeded
14 Halted 0 ms 0 KB -