#include <iostream>
#include <vector>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
vector<int> a(M), b(M);
for (int i = 0; i < M; i++) {
cin >> a[i] >> b[i];
--a[i]; --b[i];
}
for (int i = 0; i < (1<<M); i++) {
for (int direction = 0; direction < 2; direction++) {
for (int k = 0; k < N; k++) {
bool ok = false;
for (int j = 0; j < M; j++) {
if (((i&(1<<j)) == 0) == direction) {
if ((k >= a[j] && k <= b[j]) || (a[j] > b[j] && (k <= b[j] || k >= a[j]))) {
ok = true;
break;
}
}
}
if (!ok)
goto failed;
}
}
for (int j = 0; j < M; j++) {
if (i&(1<<j)) {
cout << "1";
}
else {
cout << "0";
}
}
cout << endl;
return 0;
failed:;
}
cout << "IMPOSSIBLE" << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
356 KB |
Output is correct |
3 |
Correct |
2 ms |
496 KB |
Output is correct |
4 |
Correct |
2 ms |
496 KB |
Output is correct |
5 |
Correct |
3 ms |
496 KB |
Output is correct |
6 |
Correct |
3 ms |
504 KB |
Output is correct |
7 |
Correct |
3 ms |
504 KB |
Output is correct |
8 |
Correct |
3 ms |
556 KB |
Output is correct |
9 |
Correct |
2 ms |
556 KB |
Output is correct |
10 |
Correct |
2 ms |
556 KB |
Output is correct |
11 |
Correct |
2 ms |
556 KB |
Output is correct |
12 |
Correct |
2 ms |
556 KB |
Output is correct |
13 |
Correct |
3 ms |
576 KB |
Output is correct |
14 |
Correct |
2 ms |
576 KB |
Output is correct |
15 |
Correct |
2 ms |
576 KB |
Output is correct |
16 |
Correct |
3 ms |
576 KB |
Output is correct |
17 |
Correct |
3 ms |
644 KB |
Output is correct |
18 |
Correct |
3 ms |
644 KB |
Output is correct |
19 |
Correct |
2 ms |
644 KB |
Output is correct |
20 |
Correct |
3 ms |
644 KB |
Output is correct |
21 |
Correct |
2 ms |
644 KB |
Output is correct |
22 |
Correct |
3 ms |
644 KB |
Output is correct |
23 |
Correct |
2 ms |
644 KB |
Output is correct |
24 |
Correct |
3 ms |
644 KB |
Output is correct |
25 |
Correct |
3 ms |
644 KB |
Output is correct |
26 |
Correct |
2 ms |
644 KB |
Output is correct |
27 |
Correct |
4 ms |
644 KB |
Output is correct |
28 |
Correct |
2 ms |
644 KB |
Output is correct |
29 |
Correct |
2 ms |
644 KB |
Output is correct |
30 |
Correct |
2 ms |
644 KB |
Output is correct |
31 |
Correct |
3 ms |
644 KB |
Output is correct |
32 |
Correct |
2 ms |
644 KB |
Output is correct |
33 |
Correct |
2 ms |
644 KB |
Output is correct |
34 |
Correct |
2 ms |
644 KB |
Output is correct |
35 |
Correct |
15 ms |
644 KB |
Output is correct |
36 |
Correct |
2 ms |
644 KB |
Output is correct |
37 |
Correct |
2 ms |
644 KB |
Output is correct |
38 |
Correct |
11 ms |
644 KB |
Output is correct |
39 |
Correct |
6 ms |
644 KB |
Output is correct |
40 |
Correct |
2 ms |
644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
644 KB |
Output is correct |
2 |
Correct |
3 ms |
644 KB |
Output is correct |
3 |
Incorrect |
2 ms |
644 KB |
'impossible' claimed, but there is a solution |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
644 KB |
Output is correct |
2 |
Execution timed out |
3043 ms |
644 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
69 ms |
1404 KB |
'impossible' claimed, but there is a solution |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
418 ms |
1404 KB |
'impossible' claimed, but there is a solution |
2 |
Halted |
0 ms |
0 KB |
- |