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;
const int nx=20;
int n, m, a[nx], b[nx], dp[nx], vl;
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n>>m;
for (int i=0; i<m; i++) cin>>a[i]>>b[i];
for (int msk=0; msk<(1<<m); msk++)
{
for (int i=0; i<n; i++) dp[i]=0;
for (int i=0; i<m; i++)
{
if (msk&(1<<i)) vl=2;
else vl=1;
if (a[i]<=b[i])
{
for (int j=a[i]; j<=b[i]; j++) dp[j]|=vl;
}
else
{
for (int j=1; j<=b[i]; j++) dp[j]|=vl;
for (int j=a[i]; j<=n; j++) dp[j]|=vl;
}
}
int f=0;
for (int i=1; i<=n; i++) if (dp[i]!=3) f=1;
if (!f)
{
for (int i=0; i<m;i ++) cout<<((msk&(1<<i))>0);
return 0;
}
}
cout<<"impossible";
}
# | 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... |