#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define F first
#define S second
using namespace std;
ll N, M;
vector<pii> v;
signed main()
{
ios::sync_with_stdio(0), cin.tie(0);
cin >> N >> M;
for (int i = 1; i <= M; i++)
{
int a, b;
cin >> a >> b;
v.emplace_back(pii{a, b});
}
if (N <= 15)
{
for (int mask = 0; mask < (1 << M); mask++)
{
bool valid[2] = {1, 1};
for (int i = 1; i <= N; i++)
{
bool exist[2] = {0, 0};
for (int j = 0; j < M; j++)
{
if ((v[j].F <= i && i <= v[j].S) || (v[j].F > v[j].S && !(v[j].S < i && i < v[j].F)))
exist[(mask >> j) & 1] = 1;
}
valid[0] &= exist[0];
valid[1] &= exist[1];
}
if (valid[0] && valid[1])
{
for (int j = M - 1; j >= 0; j--)
cout << ((mask >> j) & 1);
cout << '\n';
return 0;
}
}
cout << "impossible\n";
}
else
{
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Incorrect |
1 ms |
208 KB |
no wires in direction 0 between segments 11 and 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Incorrect |
1 ms |
208 KB |
no wires in direction 0 between segments 11 and 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Incorrect |
1 ms |
208 KB |
no wires in direction 0 between segments 11 and 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
16 ms |
2144 KB |
Unexpected end of file - token expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Incorrect |
1 ms |
208 KB |
no wires in direction 0 between segments 11 and 11 |
4 |
Halted |
0 ms |
0 KB |
- |