# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
893838 |
2023-12-27T14:16:37 Z |
kh0i |
Curtains (NOI23_curtains) |
C++17 |
|
236 ms |
55244 KB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 5e5 + 3;
int n, m, q;
pair<int, int> a[N], d[N];
namespace Sub12{
bool valid_input(){ return n <= 2000 and m <= 2000 and q <= 2000; }
void solve(){
for(int i = 1; i <= q; ++i){
vector<int> ck(n + 2, 0);
for(int j = 1; j <= m; ++j){
if(d[i].first <= a[j].first and a[j].second <= d[i].second)
++ck[a[j].first], --ck[a[j].second + 1];
}
for(int j = 1; j <= n; ++j)
ck[j] += ck[j - 1];
bool ok = 1;
for(int j = d[i].first; j <= d[i].second; ++j)
ok &= (ck[j] > 0);
cout << (ok ? "YES\n" : "NO\n");
}
}
}
namespace Sub3{
bool valid_input(){ return n <= 2000; }
bool has[2003][2003], ok[2003][2003];
int p[2003][2003];
void solve(){
for(int i = 1; i <= m; ++i){
has[a[i].first][a[i].second] = 1;
p[a[i].first][a[i].second] = 1;
}
for(int i = 1; i <= n; ++i)
for(int j = 1; j <= i; ++j)
p[j][i] += p[j - 1][i];
for(int i = 1; i <= n; ++i){
int cur = i - 1;
for(int j = i; j <= n; ++j){
if(has[i][j])
ok[i][j] = 1;
else
ok[i][j] = (cur >= i ? p[cur + 1][j] - p[i - 1][j] : 0);
cur = (ok[i][j] ? j : cur);
}
}
for(int i = 1; i <= q; ++i)
cout << (ok[d[i].first][d[i].second] ? "YES\n" : "NO\n");
}
}
namespace Sub4{
bool valid_input(){
bool ok = 1;
for(int i = 1; i <= q; ++i)
ok &= (d[i].first == 1);
return ok;
}
bool has[N], f[N];
vector<int> rv[N];
void solve(){
for(int i = 1; i <= m; ++i){
if(a[i].first == 1)
has[a[i].second] = 1;
rv[a[i].second].push_back(i);
}
int cur = 0;
for(int i = 1; i <= n; ++i){
if(has[i])
f[i] = 1;
else{
for(int x : rv[i])
f[i] |= (a[x].first <= cur);
}
if(f[i])
cur = i + 1;
}
for(int i = 1; i <= q; ++i)
cout << (f[d[i].second] ? "YES\n" : "NO\n");
}
}
signed main(){
cin.tie(nullptr)->sync_with_stdio(false);
cin >> n >> m >> q;
for(int i = 1; i <= m; ++i)
cin >> a[i].first >> a[i].second;
for(int i = 1; i <= q; ++i)
cin >> d[i].first >> d[i].second;
if(Sub12::valid_input())
Sub12::solve();
else if(Sub3::valid_input())
Sub3::solve();
else if(Sub4::valid_input())
Sub4::solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
16984 KB |
Output is correct |
2 |
Correct |
3 ms |
16988 KB |
Output is correct |
3 |
Correct |
4 ms |
16988 KB |
Output is correct |
4 |
Correct |
4 ms |
16988 KB |
Output is correct |
5 |
Correct |
4 ms |
16988 KB |
Output is correct |
6 |
Correct |
4 ms |
16988 KB |
Output is correct |
7 |
Correct |
5 ms |
16988 KB |
Output is correct |
8 |
Correct |
4 ms |
16988 KB |
Output is correct |
9 |
Correct |
4 ms |
16984 KB |
Output is correct |
10 |
Correct |
4 ms |
16988 KB |
Output is correct |
11 |
Correct |
4 ms |
16888 KB |
Output is correct |
12 |
Correct |
4 ms |
16988 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
16984 KB |
Output is correct |
2 |
Correct |
3 ms |
16988 KB |
Output is correct |
3 |
Correct |
4 ms |
16988 KB |
Output is correct |
4 |
Correct |
4 ms |
16988 KB |
Output is correct |
5 |
Correct |
4 ms |
16988 KB |
Output is correct |
6 |
Correct |
4 ms |
16988 KB |
Output is correct |
7 |
Correct |
5 ms |
16988 KB |
Output is correct |
8 |
Correct |
4 ms |
16988 KB |
Output is correct |
9 |
Correct |
4 ms |
16984 KB |
Output is correct |
10 |
Correct |
4 ms |
16988 KB |
Output is correct |
11 |
Correct |
4 ms |
16888 KB |
Output is correct |
12 |
Correct |
4 ms |
16988 KB |
Output is correct |
13 |
Correct |
32 ms |
17108 KB |
Output is correct |
14 |
Correct |
33 ms |
17092 KB |
Output is correct |
15 |
Correct |
34 ms |
17008 KB |
Output is correct |
16 |
Correct |
29 ms |
17104 KB |
Output is correct |
17 |
Correct |
23 ms |
16988 KB |
Output is correct |
18 |
Correct |
29 ms |
16988 KB |
Output is correct |
19 |
Correct |
25 ms |
16984 KB |
Output is correct |
20 |
Correct |
28 ms |
17108 KB |
Output is correct |
21 |
Correct |
29 ms |
16988 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
16984 KB |
Output is correct |
2 |
Correct |
3 ms |
16988 KB |
Output is correct |
3 |
Correct |
4 ms |
16988 KB |
Output is correct |
4 |
Correct |
4 ms |
16988 KB |
Output is correct |
5 |
Correct |
4 ms |
16988 KB |
Output is correct |
6 |
Correct |
4 ms |
16988 KB |
Output is correct |
7 |
Correct |
5 ms |
16988 KB |
Output is correct |
8 |
Correct |
4 ms |
16988 KB |
Output is correct |
9 |
Correct |
4 ms |
16984 KB |
Output is correct |
10 |
Correct |
4 ms |
16988 KB |
Output is correct |
11 |
Correct |
4 ms |
16888 KB |
Output is correct |
12 |
Correct |
4 ms |
16988 KB |
Output is correct |
13 |
Correct |
32 ms |
17108 KB |
Output is correct |
14 |
Correct |
33 ms |
17092 KB |
Output is correct |
15 |
Correct |
34 ms |
17008 KB |
Output is correct |
16 |
Correct |
29 ms |
17104 KB |
Output is correct |
17 |
Correct |
23 ms |
16988 KB |
Output is correct |
18 |
Correct |
29 ms |
16988 KB |
Output is correct |
19 |
Correct |
25 ms |
16984 KB |
Output is correct |
20 |
Correct |
28 ms |
17108 KB |
Output is correct |
21 |
Correct |
29 ms |
16988 KB |
Output is correct |
22 |
Correct |
74 ms |
45452 KB |
Output is correct |
23 |
Correct |
98 ms |
46032 KB |
Output is correct |
24 |
Correct |
108 ms |
48720 KB |
Output is correct |
25 |
Correct |
149 ms |
55124 KB |
Output is correct |
26 |
Correct |
87 ms |
47632 KB |
Output is correct |
27 |
Correct |
135 ms |
55108 KB |
Output is correct |
28 |
Correct |
133 ms |
55244 KB |
Output is correct |
29 |
Correct |
82 ms |
47368 KB |
Output is correct |
30 |
Correct |
90 ms |
46596 KB |
Output is correct |
31 |
Correct |
81 ms |
47120 KB |
Output is correct |
32 |
Correct |
137 ms |
53800 KB |
Output is correct |
33 |
Correct |
75 ms |
46728 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
16984 KB |
Output is correct |
2 |
Correct |
4 ms |
16988 KB |
Output is correct |
3 |
Correct |
4 ms |
16988 KB |
Output is correct |
4 |
Correct |
4 ms |
16988 KB |
Output is correct |
5 |
Correct |
25 ms |
17012 KB |
Output is correct |
6 |
Correct |
25 ms |
17100 KB |
Output is correct |
7 |
Correct |
28 ms |
17104 KB |
Output is correct |
8 |
Correct |
74 ms |
45192 KB |
Output is correct |
9 |
Correct |
83 ms |
47200 KB |
Output is correct |
10 |
Correct |
125 ms |
54028 KB |
Output is correct |
11 |
Correct |
73 ms |
46868 KB |
Output is correct |
12 |
Correct |
34 ms |
21072 KB |
Output is correct |
13 |
Correct |
33 ms |
21080 KB |
Output is correct |
14 |
Correct |
32 ms |
21128 KB |
Output is correct |
15 |
Correct |
32 ms |
20816 KB |
Output is correct |
16 |
Correct |
32 ms |
21072 KB |
Output is correct |
17 |
Correct |
33 ms |
20748 KB |
Output is correct |
18 |
Correct |
207 ms |
45608 KB |
Output is correct |
19 |
Correct |
182 ms |
43604 KB |
Output is correct |
20 |
Correct |
208 ms |
44028 KB |
Output is correct |
21 |
Correct |
181 ms |
43348 KB |
Output is correct |
22 |
Correct |
236 ms |
42500 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
16984 KB |
Output is correct |
2 |
Correct |
3 ms |
16988 KB |
Output is correct |
3 |
Correct |
4 ms |
16988 KB |
Output is correct |
4 |
Correct |
4 ms |
16988 KB |
Output is correct |
5 |
Correct |
4 ms |
16988 KB |
Output is correct |
6 |
Correct |
4 ms |
16988 KB |
Output is correct |
7 |
Correct |
5 ms |
16988 KB |
Output is correct |
8 |
Correct |
4 ms |
16988 KB |
Output is correct |
9 |
Correct |
4 ms |
16984 KB |
Output is correct |
10 |
Correct |
4 ms |
16988 KB |
Output is correct |
11 |
Correct |
4 ms |
16888 KB |
Output is correct |
12 |
Correct |
4 ms |
16988 KB |
Output is correct |
13 |
Correct |
32 ms |
17108 KB |
Output is correct |
14 |
Correct |
33 ms |
17092 KB |
Output is correct |
15 |
Correct |
34 ms |
17008 KB |
Output is correct |
16 |
Correct |
29 ms |
17104 KB |
Output is correct |
17 |
Correct |
23 ms |
16988 KB |
Output is correct |
18 |
Correct |
29 ms |
16988 KB |
Output is correct |
19 |
Correct |
25 ms |
16984 KB |
Output is correct |
20 |
Correct |
28 ms |
17108 KB |
Output is correct |
21 |
Correct |
29 ms |
16988 KB |
Output is correct |
22 |
Incorrect |
24 ms |
18304 KB |
Output isn't correct |
23 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
16984 KB |
Output is correct |
2 |
Correct |
3 ms |
16988 KB |
Output is correct |
3 |
Correct |
4 ms |
16988 KB |
Output is correct |
4 |
Correct |
4 ms |
16988 KB |
Output is correct |
5 |
Correct |
4 ms |
16988 KB |
Output is correct |
6 |
Correct |
4 ms |
16988 KB |
Output is correct |
7 |
Correct |
5 ms |
16988 KB |
Output is correct |
8 |
Correct |
4 ms |
16988 KB |
Output is correct |
9 |
Correct |
4 ms |
16984 KB |
Output is correct |
10 |
Correct |
4 ms |
16988 KB |
Output is correct |
11 |
Correct |
4 ms |
16888 KB |
Output is correct |
12 |
Correct |
4 ms |
16988 KB |
Output is correct |
13 |
Correct |
32 ms |
17108 KB |
Output is correct |
14 |
Correct |
33 ms |
17092 KB |
Output is correct |
15 |
Correct |
34 ms |
17008 KB |
Output is correct |
16 |
Correct |
29 ms |
17104 KB |
Output is correct |
17 |
Correct |
23 ms |
16988 KB |
Output is correct |
18 |
Correct |
29 ms |
16988 KB |
Output is correct |
19 |
Correct |
25 ms |
16984 KB |
Output is correct |
20 |
Correct |
28 ms |
17108 KB |
Output is correct |
21 |
Correct |
29 ms |
16988 KB |
Output is correct |
22 |
Correct |
74 ms |
45452 KB |
Output is correct |
23 |
Correct |
98 ms |
46032 KB |
Output is correct |
24 |
Correct |
108 ms |
48720 KB |
Output is correct |
25 |
Correct |
149 ms |
55124 KB |
Output is correct |
26 |
Correct |
87 ms |
47632 KB |
Output is correct |
27 |
Correct |
135 ms |
55108 KB |
Output is correct |
28 |
Correct |
133 ms |
55244 KB |
Output is correct |
29 |
Correct |
82 ms |
47368 KB |
Output is correct |
30 |
Correct |
90 ms |
46596 KB |
Output is correct |
31 |
Correct |
81 ms |
47120 KB |
Output is correct |
32 |
Correct |
137 ms |
53800 KB |
Output is correct |
33 |
Correct |
75 ms |
46728 KB |
Output is correct |
34 |
Correct |
4 ms |
16984 KB |
Output is correct |
35 |
Correct |
4 ms |
16988 KB |
Output is correct |
36 |
Correct |
4 ms |
16988 KB |
Output is correct |
37 |
Correct |
4 ms |
16988 KB |
Output is correct |
38 |
Correct |
25 ms |
17012 KB |
Output is correct |
39 |
Correct |
25 ms |
17100 KB |
Output is correct |
40 |
Correct |
28 ms |
17104 KB |
Output is correct |
41 |
Correct |
74 ms |
45192 KB |
Output is correct |
42 |
Correct |
83 ms |
47200 KB |
Output is correct |
43 |
Correct |
125 ms |
54028 KB |
Output is correct |
44 |
Correct |
73 ms |
46868 KB |
Output is correct |
45 |
Correct |
34 ms |
21072 KB |
Output is correct |
46 |
Correct |
33 ms |
21080 KB |
Output is correct |
47 |
Correct |
32 ms |
21128 KB |
Output is correct |
48 |
Correct |
32 ms |
20816 KB |
Output is correct |
49 |
Correct |
32 ms |
21072 KB |
Output is correct |
50 |
Correct |
33 ms |
20748 KB |
Output is correct |
51 |
Correct |
207 ms |
45608 KB |
Output is correct |
52 |
Correct |
182 ms |
43604 KB |
Output is correct |
53 |
Correct |
208 ms |
44028 KB |
Output is correct |
54 |
Correct |
181 ms |
43348 KB |
Output is correct |
55 |
Correct |
236 ms |
42500 KB |
Output is correct |
56 |
Incorrect |
24 ms |
18304 KB |
Output isn't correct |
57 |
Halted |
0 ms |
0 KB |
- |