#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
#define INF 1000000019
#define POT (1<<20)
#define INFL 1000000000000000099LL
ll n,m,a,b;
vector<pair<ll,ll>>v;
bool czy[16][2];
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);
cin>>n>>m;
for(ll i=0;i<m;i++){
cin>>a>>b;
a--;
b--;
v.pb({a,b});
}
for(ll i=0;i<(1<<m);i++){
for(ll j=0;j<16;j++){
czy[j][0]=czy[j][1]=0;
}
for(ll j=0;j<m;j++){
if((1<<j) & i){
for(ll k=v[j].ff;k!=v[j].ss;k=(k+1)%n){
czy[k][0]=1;
}
czy[v[j].ss][0]=1;
}
else{
for(ll k=v[j].ff;k!=v[j].ss;k=(k+1)%n){
czy[k][1]=1;
}
czy[v[j].ss][1]=1;
}
}
bool bl=1;
for(ll j=0;j<n;j++){
bl&=czy[j][0]&czy[j][1];
}
if(bl){
for(ll j=0;j<m;j++){
if(i&(1<<j))cout<<1;
else cout<<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... |