#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;
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);
}
}
for (int i = 1; i <= m; ++i) {
printf("%d", color[i]);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
no wires in direction 0 between segments 1 and 15 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
no wires in direction 0 between segments 1 and 15 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
no wires in direction 0 between segments 1 and 15 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
30 ms |
3020 KB |
no wires in direction 0 between segments 1 and 100000 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
no wires in direction 0 between segments 1 and 15 |
2 |
Halted |
0 ms |
0 KB |
- |