# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1051485 |
2024-08-10T07:24:14 Z |
NeroZein |
Fire (BOI24_fire) |
C++17 |
|
312 ms |
432 KB |
#include "bits/stdc++.h"
using namespace std;
#ifdef Nero
#include "Deb.h"
#else
#define debug(...)
#endif
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, m;
cin >> n >> m;
vector<int> s(n), e(n);
for (int i = 0; i < n; ++i) {
cin >> s[i] >> e[i];
}
int ans = n + 1;
for (int mask = 1; mask < (1 << n); ++mask) {
vector<pair<int, int>> ranges;
for (int i = 0; i < n; ++i) {
if (mask >> i & 1) {
if (s[i] <= e[i]) {
ranges.push_back({s[i], e[i]});
} else {
ranges.push_back({s[i], m - 1});
ranges.push_back({0, e[i]});
}
}
}
bool ok = true;
sort(ranges.begin(), ranges.end());
int mx = 0;
for (int i = 0; i < (int) ranges.size(); ++i) {
auto [l, r] = ranges[i];
if (mx < l) {
ok = false;
break;
}
mx = max(mx, r);
}
ok &= mx == m - 1;
if (ok) {
ans = min(ans, __builtin_popcount(mask));
}
}
cout << (ans > n ? -1 : ans) << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
271 ms |
432 KB |
Output is correct |
9 |
Correct |
211 ms |
348 KB |
Output is correct |
10 |
Correct |
218 ms |
348 KB |
Output is correct |
11 |
Correct |
199 ms |
344 KB |
Output is correct |
12 |
Correct |
187 ms |
432 KB |
Output is correct |
13 |
Correct |
194 ms |
344 KB |
Output is correct |
14 |
Correct |
195 ms |
432 KB |
Output is correct |
15 |
Correct |
312 ms |
348 KB |
Output is correct |
16 |
Correct |
208 ms |
348 KB |
Output is correct |
17 |
Correct |
199 ms |
348 KB |
Output is correct |
18 |
Correct |
193 ms |
344 KB |
Output is correct |
19 |
Correct |
196 ms |
348 KB |
Output is correct |
20 |
Correct |
184 ms |
344 KB |
Output is correct |
21 |
Correct |
190 ms |
348 KB |
Output is correct |
22 |
Correct |
196 ms |
348 KB |
Output is correct |
23 |
Correct |
81 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
271 ms |
432 KB |
Output is correct |
9 |
Correct |
211 ms |
348 KB |
Output is correct |
10 |
Correct |
218 ms |
348 KB |
Output is correct |
11 |
Correct |
199 ms |
344 KB |
Output is correct |
12 |
Correct |
187 ms |
432 KB |
Output is correct |
13 |
Correct |
194 ms |
344 KB |
Output is correct |
14 |
Correct |
195 ms |
432 KB |
Output is correct |
15 |
Correct |
312 ms |
348 KB |
Output is correct |
16 |
Correct |
208 ms |
348 KB |
Output is correct |
17 |
Correct |
199 ms |
348 KB |
Output is correct |
18 |
Correct |
193 ms |
344 KB |
Output is correct |
19 |
Correct |
196 ms |
348 KB |
Output is correct |
20 |
Correct |
184 ms |
344 KB |
Output is correct |
21 |
Correct |
190 ms |
348 KB |
Output is correct |
22 |
Correct |
196 ms |
348 KB |
Output is correct |
23 |
Correct |
81 ms |
344 KB |
Output is correct |
24 |
Correct |
102 ms |
432 KB |
Output is correct |
25 |
Incorrect |
7 ms |
348 KB |
Output isn't correct |
26 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
271 ms |
432 KB |
Output is correct |
9 |
Correct |
211 ms |
348 KB |
Output is correct |
10 |
Correct |
218 ms |
348 KB |
Output is correct |
11 |
Correct |
199 ms |
344 KB |
Output is correct |
12 |
Correct |
187 ms |
432 KB |
Output is correct |
13 |
Correct |
194 ms |
344 KB |
Output is correct |
14 |
Correct |
195 ms |
432 KB |
Output is correct |
15 |
Correct |
312 ms |
348 KB |
Output is correct |
16 |
Correct |
208 ms |
348 KB |
Output is correct |
17 |
Correct |
199 ms |
348 KB |
Output is correct |
18 |
Correct |
193 ms |
344 KB |
Output is correct |
19 |
Correct |
196 ms |
348 KB |
Output is correct |
20 |
Correct |
184 ms |
344 KB |
Output is correct |
21 |
Correct |
190 ms |
348 KB |
Output is correct |
22 |
Correct |
196 ms |
348 KB |
Output is correct |
23 |
Correct |
81 ms |
344 KB |
Output is correct |
24 |
Correct |
102 ms |
432 KB |
Output is correct |
25 |
Incorrect |
7 ms |
348 KB |
Output isn't correct |
26 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
264 ms |
344 KB |
Output is correct |
4 |
Correct |
273 ms |
348 KB |
Output is correct |
5 |
Correct |
215 ms |
344 KB |
Output is correct |
6 |
Correct |
185 ms |
348 KB |
Output is correct |
7 |
Correct |
187 ms |
344 KB |
Output is correct |
8 |
Correct |
195 ms |
344 KB |
Output is correct |
9 |
Incorrect |
8 ms |
348 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
198 ms |
424 KB |
Output is correct |
5 |
Correct |
200 ms |
344 KB |
Output is correct |
6 |
Correct |
195 ms |
344 KB |
Output is correct |
7 |
Correct |
188 ms |
428 KB |
Output is correct |
8 |
Incorrect |
8 ms |
344 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
271 ms |
432 KB |
Output is correct |
9 |
Correct |
211 ms |
348 KB |
Output is correct |
10 |
Correct |
218 ms |
348 KB |
Output is correct |
11 |
Correct |
199 ms |
344 KB |
Output is correct |
12 |
Correct |
187 ms |
432 KB |
Output is correct |
13 |
Correct |
194 ms |
344 KB |
Output is correct |
14 |
Correct |
195 ms |
432 KB |
Output is correct |
15 |
Correct |
312 ms |
348 KB |
Output is correct |
16 |
Correct |
208 ms |
348 KB |
Output is correct |
17 |
Correct |
199 ms |
348 KB |
Output is correct |
18 |
Correct |
193 ms |
344 KB |
Output is correct |
19 |
Correct |
196 ms |
348 KB |
Output is correct |
20 |
Correct |
184 ms |
344 KB |
Output is correct |
21 |
Correct |
190 ms |
348 KB |
Output is correct |
22 |
Correct |
196 ms |
348 KB |
Output is correct |
23 |
Correct |
81 ms |
344 KB |
Output is correct |
24 |
Correct |
102 ms |
432 KB |
Output is correct |
25 |
Incorrect |
7 ms |
348 KB |
Output isn't correct |
26 |
Halted |
0 ms |
0 KB |
- |