This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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=X[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]--;
}
string res="";
for(int A=0;A<(1<<M);A++)
{
if(ok(A))
{
for(int C=0;C<M;C++)
res+=(char)(((A&(1<<C))!=0)?1:0)+'0';
cout<<res;
return 0;
}
}
cout<<"impossible";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |