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 ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fs first
#define sc second
#define tlll tuple<ll,ll,ll>
const int mxn = 16;
int N,M;
pii arr[mxn];
int ans = -1;
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>N>>M;
for(int i = 0;i<M;i++){
cin>>arr[i].fs>>arr[i].sc;
arr[i].fs--,arr[i].sc--;
}
for(int i = 0;i<(1<<M);i++){
int dp[mxn] = {};
for(int j = 0;j<M;j++){
int k;
for(k = arr[j].fs;k != arr[j].sc;k = (k+1)%N){
dp[k] |= 1<<(i&(1<<j)?1:0);
}
dp[k] |= 1<<(i&(1<<j)?1:0);
}
if(*min_element(dp,dp+N) == 3)ans = i;
}
if(ans == -1)cout<<"impossible\n";
else{
for(int i = 0;i<M;i++){
if(ans&(1<<i))cout<<1;
else cout<<0;
}
}
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... |