#include <bits/stdc++.h>
using namespace std;
const int N = 100100;
int color[N];
int main() {
ios_base::sync_with_stdio(false);
int n, m;
cin >> n >> m;
vector<tuple<int, int, int>> vals;
for (int i = 1; i <= m; ++i) {
int l, r;
cin >> l >> r;
assert(l <= r);
vals.emplace_back(l, -r, i);
}
sort(vals.begin(), vals.end());
int gol = 0;
int gor = 0;
for (auto v : vals) {
int l, r, id;
tie(l, r, id) = v;
r = -r;
if (gol < gor) {
if (l > gol + 1) {
puts("impossible");
return 0;
}
color[id] = 0;
gol = max(gol, r);
} else {
if (l > gor + 1) {
puts("impossible");
return 0;
}
color[id] = 1;
gor = max(gor, r);
}
}
if (min(gol, gor) < n) {
puts("impossible");
return 0;
}
for (int i = 1; i <= m; ++i) {
printf("%d", color[i]);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Runtime error |
3 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Runtime error |
3 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Runtime error |
3 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
29 ms |
2212 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
12 ms |
1276 KB |
Output is correct |
4 |
Correct |
15 ms |
1276 KB |
Output is correct |
5 |
Correct |
37 ms |
2072 KB |
Output is correct |
6 |
Correct |
31 ms |
2040 KB |
Output is correct |
7 |
Correct |
33 ms |
2040 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
36 ms |
2156 KB |
Output is correct |
11 |
Correct |
28 ms |
2040 KB |
Output is correct |
12 |
Correct |
33 ms |
2040 KB |
Output is correct |
13 |
Correct |
2 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
39 ms |
3308 KB |
Output is correct |
16 |
Correct |
13 ms |
1788 KB |
Output is correct |
17 |
Correct |
36 ms |
3304 KB |
Output is correct |
18 |
Correct |
36 ms |
3052 KB |
Output is correct |
19 |
Correct |
3 ms |
512 KB |
Output is correct |
20 |
Correct |
36 ms |
3180 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Runtime error |
3 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |