#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define int long long
#define itr ::iterator
typedef pair<int,int> pii;
const int MAX=1e5;
int N,M,X[MAX],Y[MAX],mark[MAX][2];
bool ok(int mask)
{
for(int A=0;A<N;A++)
{
mark[A][0]=0;
mark[A][1]=0;
}
for(int A=0;A<M;A++)
{
if(X[A]>Y[A])
{
for(int B=Y[A];B<N;B++)
mark[B][((mask&(1<<A))!=0)]=1;
for(int B=0;B<X[A];B++)
mark[B][((mask&(1<<A))!=0)]=1;
}
else
{
for(int B=X[A];B<=Y[A];B++)
mark[B][((mask&(1<<A))!=0)]=1;
}
}
for(int A=0;A<N;A++)
if(mark[A][0]+mark[A][1]!=2)
return false;
return true;
}
signed main()
{
ios_base::sync_with_stdio(false);
cin>>N>>M;
for(int A=0;A<M;A++)
{
cin>>X[A]>>Y[A];
X[A]--;
Y[A]--;
}
for(int A=0;A<(1<<M);A++)
{
if(ok(A))
{
for(int C=0;C<M;C++)
cout<<(((A&(1<<C))!=0)?1:0);
return 0;
}
}
cout<<"impossible";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
484 KB |
Output is correct |
3 |
Incorrect |
2 ms |
532 KB |
no wires in direction 1 between segments 7 and 12 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
484 KB |
Output is correct |
3 |
Incorrect |
2 ms |
532 KB |
no wires in direction 1 between segments 7 and 12 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
484 KB |
Output is correct |
3 |
Incorrect |
2 ms |
532 KB |
no wires in direction 1 between segments 7 and 12 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3072 ms |
3968 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
484 KB |
Output is correct |
3 |
Incorrect |
2 ms |
532 KB |
no wires in direction 1 between segments 7 and 12 |
4 |
Halted |
0 ms |
0 KB |
- |