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>
#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
signed main(){
//fastio
int n,m;
cin >> n >> m;
vector<pair<int,int>> v;
for(int i = 0;i < m;i++){
int l,r;
cin >> l >> r;
l--, r--;
v.push_back({l,r});
}
for(int i = 0;i < (1<<m);i++){
int cnt[n] = {};
for(int j = 0;j < m;j++){
if(i&(1<<j)){
int l = v[j].first, r = v[j].second;
while(true){
cnt[l] |= 2;
if(l==r) break;
l = (l+1)%n;
}
}else{
int l = v[j].first, r = v[j].second;
while(true){
cnt[l] |= 1;
if(l==r) break;
l = (l+1)%n;
}
}
}
bool check = true;
for(int j = 0;j < n;j++){
if(cnt[j]!=3){
check = false;
}
}
if(check){
for(int j = 0;j < m;j++){
if(i&(1<<j)) cout << 0;
else cout << 1;
}
cout << "\n";
return 0;
}
}
cout << "impossible\n";
}
# | 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... |