# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1033861 |
2024-07-25T07:08:59 Z |
변재우(#10974) |
Fire (BOI24_fire) |
C++17 |
|
172 ms |
73628 KB |
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int Nmax=200010;
int N, M, W, P, ans=Nmax, I[20][2*Nmax];
vector<pair<int, int>> V, T;
vector<int> X;
int F(int l, int r) {
int ret=0;
for(int i=19; i>=0; i--) if(I[i][l]<r) ret+=1<<i, l=I[i][l];
if(I[0][l]<r) return Nmax;
return ret+1;
}
signed main() {
ios_base::sync_with_stdio(0); cin.tie(0);
cin>>N>>P;
for(int i=1; i<=N; i++) {
int x, y; cin>>x>>y;
if(x>y) T.push_back({x, y});
else V.push_back({x, y});
X.push_back(x), X.push_back(y);
}
N=V.size(), M=T.size();
X.push_back(0), X.push_back(P);
sort(X.begin(), X.end()); X.erase(unique(X.begin(), X.end()), X.end());
W=X.size();
for(int i=0; i<N; i++) {
V[i].first=lower_bound(X.begin(), X.end(), V[i].first)-X.begin()+1;
V[i].second=lower_bound(X.begin(), X.end(), V[i].second)-X.begin()+1;
}
for(int i=0; i<M; i++) {
T[i].first=lower_bound(X.begin(), X.end(), T[i].first)-X.begin()+1;
T[i].second=lower_bound(X.begin(), X.end(), T[i].second)-X.begin()+1;
}
sort(V.begin(), V.end());
for(int i=1, j=0, mx=i; i<=W; i++) {
while(j<V.size() && V[j].first<=i) mx=max(mx, V[j++].second);
I[0][i]=max(mx, i);
}
for(int i=1; i<20; i++) for(int j=1; j<=W; j++) I[i][j]=I[i-1][I[i-1][j]];
for(auto [r, l]:T) ans=min(ans, 1+F(l, r));
if(ans>N+M) cout<<-1;
else cout<<ans;
return 0;
}
Compilation message
Main.cpp: In function 'int main()':
Main.cpp:40:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
40 | while(j<V.size() && V[j].first<=i) mx=max(mx, V[j++].second);
| ~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
600 KB |
Output is correct |
2 |
Correct |
0 ms |
604 KB |
Output is correct |
3 |
Correct |
0 ms |
604 KB |
Output is correct |
4 |
Correct |
0 ms |
604 KB |
Output is correct |
5 |
Correct |
0 ms |
604 KB |
Output is correct |
6 |
Correct |
0 ms |
604 KB |
Output is correct |
7 |
Correct |
0 ms |
604 KB |
Output is correct |
8 |
Correct |
0 ms |
604 KB |
Output is correct |
9 |
Correct |
0 ms |
604 KB |
Output is correct |
10 |
Correct |
0 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 |
1 ms |
600 KB |
Output is correct |
14 |
Correct |
0 ms |
604 KB |
Output is correct |
15 |
Correct |
0 ms |
604 KB |
Output is correct |
16 |
Correct |
0 ms |
604 KB |
Output is correct |
17 |
Correct |
0 ms |
604 KB |
Output is correct |
18 |
Correct |
0 ms |
604 KB |
Output is correct |
19 |
Correct |
0 ms |
604 KB |
Output is correct |
20 |
Correct |
0 ms |
604 KB |
Output is correct |
21 |
Correct |
0 ms |
604 KB |
Output is correct |
22 |
Correct |
0 ms |
604 KB |
Output is correct |
23 |
Correct |
0 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
600 KB |
Output is correct |
2 |
Correct |
0 ms |
604 KB |
Output is correct |
3 |
Correct |
0 ms |
604 KB |
Output is correct |
4 |
Correct |
0 ms |
604 KB |
Output is correct |
5 |
Correct |
0 ms |
604 KB |
Output is correct |
6 |
Correct |
0 ms |
604 KB |
Output is correct |
7 |
Correct |
0 ms |
604 KB |
Output is correct |
8 |
Correct |
0 ms |
604 KB |
Output is correct |
9 |
Correct |
0 ms |
604 KB |
Output is correct |
10 |
Correct |
0 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 |
1 ms |
600 KB |
Output is correct |
14 |
Correct |
0 ms |
604 KB |
Output is correct |
15 |
Correct |
0 ms |
604 KB |
Output is correct |
16 |
Correct |
0 ms |
604 KB |
Output is correct |
17 |
Correct |
0 ms |
604 KB |
Output is correct |
18 |
Correct |
0 ms |
604 KB |
Output is correct |
19 |
Correct |
0 ms |
604 KB |
Output is correct |
20 |
Correct |
0 ms |
604 KB |
Output is correct |
21 |
Correct |
0 ms |
604 KB |
Output is correct |
22 |
Correct |
0 ms |
604 KB |
Output is correct |
23 |
Correct |
0 ms |
604 KB |
Output is correct |
24 |
Correct |
1 ms |
604 KB |
Output is correct |
25 |
Correct |
0 ms |
604 KB |
Output is correct |
26 |
Correct |
0 ms |
600 KB |
Output is correct |
27 |
Correct |
1 ms |
604 KB |
Output is correct |
28 |
Correct |
1 ms |
600 KB |
Output is correct |
29 |
Correct |
0 ms |
604 KB |
Output is correct |
30 |
Correct |
1 ms |
604 KB |
Output is correct |
31 |
Correct |
0 ms |
604 KB |
Output is correct |
32 |
Correct |
0 ms |
604 KB |
Output is correct |
33 |
Correct |
1 ms |
604 KB |
Output is correct |
34 |
Correct |
0 ms |
604 KB |
Output is correct |
35 |
Correct |
0 ms |
604 KB |
Output is correct |
36 |
Correct |
0 ms |
604 KB |
Output is correct |
37 |
Correct |
1 ms |
604 KB |
Output is correct |
38 |
Correct |
0 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
600 KB |
Output is correct |
2 |
Correct |
0 ms |
604 KB |
Output is correct |
3 |
Correct |
0 ms |
604 KB |
Output is correct |
4 |
Correct |
0 ms |
604 KB |
Output is correct |
5 |
Correct |
0 ms |
604 KB |
Output is correct |
6 |
Correct |
0 ms |
604 KB |
Output is correct |
7 |
Correct |
0 ms |
604 KB |
Output is correct |
8 |
Correct |
0 ms |
604 KB |
Output is correct |
9 |
Correct |
0 ms |
604 KB |
Output is correct |
10 |
Correct |
0 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 |
1 ms |
600 KB |
Output is correct |
14 |
Correct |
0 ms |
604 KB |
Output is correct |
15 |
Correct |
0 ms |
604 KB |
Output is correct |
16 |
Correct |
0 ms |
604 KB |
Output is correct |
17 |
Correct |
0 ms |
604 KB |
Output is correct |
18 |
Correct |
0 ms |
604 KB |
Output is correct |
19 |
Correct |
0 ms |
604 KB |
Output is correct |
20 |
Correct |
0 ms |
604 KB |
Output is correct |
21 |
Correct |
0 ms |
604 KB |
Output is correct |
22 |
Correct |
0 ms |
604 KB |
Output is correct |
23 |
Correct |
0 ms |
604 KB |
Output is correct |
24 |
Correct |
1 ms |
604 KB |
Output is correct |
25 |
Correct |
0 ms |
604 KB |
Output is correct |
26 |
Correct |
0 ms |
600 KB |
Output is correct |
27 |
Correct |
1 ms |
604 KB |
Output is correct |
28 |
Correct |
1 ms |
600 KB |
Output is correct |
29 |
Correct |
0 ms |
604 KB |
Output is correct |
30 |
Correct |
1 ms |
604 KB |
Output is correct |
31 |
Correct |
0 ms |
604 KB |
Output is correct |
32 |
Correct |
0 ms |
604 KB |
Output is correct |
33 |
Correct |
1 ms |
604 KB |
Output is correct |
34 |
Correct |
0 ms |
604 KB |
Output is correct |
35 |
Correct |
0 ms |
604 KB |
Output is correct |
36 |
Correct |
0 ms |
604 KB |
Output is correct |
37 |
Correct |
1 ms |
604 KB |
Output is correct |
38 |
Correct |
0 ms |
604 KB |
Output is correct |
39 |
Correct |
3 ms |
2396 KB |
Output is correct |
40 |
Correct |
3 ms |
2396 KB |
Output is correct |
41 |
Correct |
3 ms |
2396 KB |
Output is correct |
42 |
Correct |
3 ms |
1576 KB |
Output is correct |
43 |
Correct |
3 ms |
1500 KB |
Output is correct |
44 |
Correct |
3 ms |
1628 KB |
Output is correct |
45 |
Correct |
3 ms |
1628 KB |
Output is correct |
46 |
Correct |
3 ms |
1628 KB |
Output is correct |
47 |
Correct |
3 ms |
2396 KB |
Output is correct |
48 |
Correct |
3 ms |
2396 KB |
Output is correct |
49 |
Correct |
2 ms |
2396 KB |
Output is correct |
50 |
Correct |
3 ms |
1628 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
604 KB |
Output is correct |
2 |
Correct |
0 ms |
468 KB |
Output is correct |
3 |
Correct |
0 ms |
604 KB |
Output is correct |
4 |
Correct |
0 ms |
604 KB |
Output is correct |
5 |
Correct |
0 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
600 KB |
Output is correct |
7 |
Correct |
0 ms |
600 KB |
Output is correct |
8 |
Correct |
0 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 |
1 ms |
604 KB |
Output is correct |
12 |
Correct |
0 ms |
604 KB |
Output is correct |
13 |
Correct |
1 ms |
604 KB |
Output is correct |
14 |
Correct |
1 ms |
604 KB |
Output is correct |
15 |
Correct |
5 ms |
2396 KB |
Output is correct |
16 |
Correct |
3 ms |
1628 KB |
Output is correct |
17 |
Correct |
3 ms |
1536 KB |
Output is correct |
18 |
Correct |
3 ms |
1876 KB |
Output is correct |
19 |
Correct |
3 ms |
2396 KB |
Output is correct |
20 |
Correct |
28 ms |
9572 KB |
Output is correct |
21 |
Correct |
154 ms |
73376 KB |
Output is correct |
22 |
Correct |
157 ms |
73184 KB |
Output is correct |
23 |
Correct |
118 ms |
41140 KB |
Output is correct |
24 |
Correct |
145 ms |
73372 KB |
Output is correct |
25 |
Correct |
111 ms |
35984 KB |
Output is correct |
26 |
Correct |
126 ms |
42148 KB |
Output is correct |
27 |
Correct |
123 ms |
42040 KB |
Output is correct |
28 |
Correct |
146 ms |
71864 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
604 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
0 ms |
604 KB |
Output is correct |
4 |
Correct |
0 ms |
604 KB |
Output is correct |
5 |
Correct |
0 ms |
604 KB |
Output is correct |
6 |
Correct |
0 ms |
604 KB |
Output is correct |
7 |
Correct |
0 ms |
604 KB |
Output is correct |
8 |
Correct |
0 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
0 ms |
604 KB |
Output is correct |
11 |
Correct |
0 ms |
604 KB |
Output is correct |
12 |
Correct |
3 ms |
2396 KB |
Output is correct |
13 |
Correct |
3 ms |
1628 KB |
Output is correct |
14 |
Correct |
3 ms |
1628 KB |
Output is correct |
15 |
Correct |
29 ms |
9552 KB |
Output is correct |
16 |
Correct |
124 ms |
41176 KB |
Output is correct |
17 |
Correct |
153 ms |
73364 KB |
Output is correct |
18 |
Correct |
172 ms |
73628 KB |
Output is correct |
19 |
Correct |
138 ms |
73236 KB |
Output is correct |
20 |
Correct |
120 ms |
41124 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
600 KB |
Output is correct |
2 |
Correct |
0 ms |
604 KB |
Output is correct |
3 |
Correct |
0 ms |
604 KB |
Output is correct |
4 |
Correct |
0 ms |
604 KB |
Output is correct |
5 |
Correct |
0 ms |
604 KB |
Output is correct |
6 |
Correct |
0 ms |
604 KB |
Output is correct |
7 |
Correct |
0 ms |
604 KB |
Output is correct |
8 |
Correct |
0 ms |
604 KB |
Output is correct |
9 |
Correct |
0 ms |
604 KB |
Output is correct |
10 |
Correct |
0 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 |
1 ms |
600 KB |
Output is correct |
14 |
Correct |
0 ms |
604 KB |
Output is correct |
15 |
Correct |
0 ms |
604 KB |
Output is correct |
16 |
Correct |
0 ms |
604 KB |
Output is correct |
17 |
Correct |
0 ms |
604 KB |
Output is correct |
18 |
Correct |
0 ms |
604 KB |
Output is correct |
19 |
Correct |
0 ms |
604 KB |
Output is correct |
20 |
Correct |
0 ms |
604 KB |
Output is correct |
21 |
Correct |
0 ms |
604 KB |
Output is correct |
22 |
Correct |
0 ms |
604 KB |
Output is correct |
23 |
Correct |
0 ms |
604 KB |
Output is correct |
24 |
Correct |
1 ms |
604 KB |
Output is correct |
25 |
Correct |
0 ms |
604 KB |
Output is correct |
26 |
Correct |
0 ms |
600 KB |
Output is correct |
27 |
Correct |
1 ms |
604 KB |
Output is correct |
28 |
Correct |
1 ms |
600 KB |
Output is correct |
29 |
Correct |
0 ms |
604 KB |
Output is correct |
30 |
Correct |
1 ms |
604 KB |
Output is correct |
31 |
Correct |
0 ms |
604 KB |
Output is correct |
32 |
Correct |
0 ms |
604 KB |
Output is correct |
33 |
Correct |
1 ms |
604 KB |
Output is correct |
34 |
Correct |
0 ms |
604 KB |
Output is correct |
35 |
Correct |
0 ms |
604 KB |
Output is correct |
36 |
Correct |
0 ms |
604 KB |
Output is correct |
37 |
Correct |
1 ms |
604 KB |
Output is correct |
38 |
Correct |
0 ms |
604 KB |
Output is correct |
39 |
Correct |
3 ms |
2396 KB |
Output is correct |
40 |
Correct |
3 ms |
2396 KB |
Output is correct |
41 |
Correct |
3 ms |
2396 KB |
Output is correct |
42 |
Correct |
3 ms |
1576 KB |
Output is correct |
43 |
Correct |
3 ms |
1500 KB |
Output is correct |
44 |
Correct |
3 ms |
1628 KB |
Output is correct |
45 |
Correct |
3 ms |
1628 KB |
Output is correct |
46 |
Correct |
3 ms |
1628 KB |
Output is correct |
47 |
Correct |
3 ms |
2396 KB |
Output is correct |
48 |
Correct |
3 ms |
2396 KB |
Output is correct |
49 |
Correct |
2 ms |
2396 KB |
Output is correct |
50 |
Correct |
3 ms |
1628 KB |
Output is correct |
51 |
Correct |
1 ms |
604 KB |
Output is correct |
52 |
Correct |
0 ms |
468 KB |
Output is correct |
53 |
Correct |
0 ms |
604 KB |
Output is correct |
54 |
Correct |
0 ms |
604 KB |
Output is correct |
55 |
Correct |
0 ms |
604 KB |
Output is correct |
56 |
Correct |
1 ms |
600 KB |
Output is correct |
57 |
Correct |
0 ms |
600 KB |
Output is correct |
58 |
Correct |
0 ms |
604 KB |
Output is correct |
59 |
Correct |
1 ms |
604 KB |
Output is correct |
60 |
Correct |
1 ms |
604 KB |
Output is correct |
61 |
Correct |
1 ms |
604 KB |
Output is correct |
62 |
Correct |
0 ms |
604 KB |
Output is correct |
63 |
Correct |
1 ms |
604 KB |
Output is correct |
64 |
Correct |
1 ms |
604 KB |
Output is correct |
65 |
Correct |
5 ms |
2396 KB |
Output is correct |
66 |
Correct |
3 ms |
1628 KB |
Output is correct |
67 |
Correct |
3 ms |
1536 KB |
Output is correct |
68 |
Correct |
3 ms |
1876 KB |
Output is correct |
69 |
Correct |
3 ms |
2396 KB |
Output is correct |
70 |
Correct |
28 ms |
9572 KB |
Output is correct |
71 |
Correct |
154 ms |
73376 KB |
Output is correct |
72 |
Correct |
157 ms |
73184 KB |
Output is correct |
73 |
Correct |
118 ms |
41140 KB |
Output is correct |
74 |
Correct |
145 ms |
73372 KB |
Output is correct |
75 |
Correct |
111 ms |
35984 KB |
Output is correct |
76 |
Correct |
126 ms |
42148 KB |
Output is correct |
77 |
Correct |
123 ms |
42040 KB |
Output is correct |
78 |
Correct |
146 ms |
71864 KB |
Output is correct |
79 |
Correct |
0 ms |
604 KB |
Output is correct |
80 |
Correct |
1 ms |
604 KB |
Output is correct |
81 |
Correct |
0 ms |
604 KB |
Output is correct |
82 |
Correct |
0 ms |
604 KB |
Output is correct |
83 |
Correct |
0 ms |
604 KB |
Output is correct |
84 |
Correct |
0 ms |
604 KB |
Output is correct |
85 |
Correct |
0 ms |
604 KB |
Output is correct |
86 |
Correct |
0 ms |
604 KB |
Output is correct |
87 |
Correct |
1 ms |
604 KB |
Output is correct |
88 |
Correct |
0 ms |
604 KB |
Output is correct |
89 |
Correct |
0 ms |
604 KB |
Output is correct |
90 |
Correct |
3 ms |
2396 KB |
Output is correct |
91 |
Correct |
3 ms |
1628 KB |
Output is correct |
92 |
Correct |
3 ms |
1628 KB |
Output is correct |
93 |
Correct |
29 ms |
9552 KB |
Output is correct |
94 |
Correct |
124 ms |
41176 KB |
Output is correct |
95 |
Correct |
153 ms |
73364 KB |
Output is correct |
96 |
Correct |
172 ms |
73628 KB |
Output is correct |
97 |
Correct |
138 ms |
73236 KB |
Output is correct |
98 |
Correct |
120 ms |
41124 KB |
Output is correct |
99 |
Correct |
151 ms |
73268 KB |
Output is correct |
100 |
Correct |
149 ms |
73372 KB |
Output is correct |
101 |
Correct |
142 ms |
73368 KB |
Output is correct |
102 |
Correct |
144 ms |
73292 KB |
Output is correct |
103 |
Correct |
129 ms |
42144 KB |
Output is correct |
104 |
Correct |
141 ms |
70304 KB |
Output is correct |
105 |
Correct |
76 ms |
72088 KB |
Output is correct |