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;
int res[20];
int main(){
int n, m;
cin >> n >> m;
vector <array <int, 3>> v;
for(int i = 0;i < m;i++){
int a, b;
cin >> a >> b;
v.push_back({a, b, i});
}
for(int mask = 0;mask < (1<<m);mask++){
int valores[n+1][2];
for(int i = 1;i <= n;i++){
valores[i][0] = valores[i][1] = 1;
}
for(int i = 0;i < m;i++){
int cor = 0;
if(((1<<i)&m)) cor = 1;
auto [a, b, _] = v[i];
res[_] = cor;
if(a <= b){
for(int j = a;j <= b;j++){
valores[j][cor] = 1;
}
}
else{
for(int j = a;j <= n;j++){
valores[j][cor] = 1;
}
for(int j = 1;j <= b;j++){
valores[j][cor] = 1;
}
}
}
int aux = false;
for(int i = 1;i <= n;i++){
if(valores[i][0] != 1 or valores[i][1] != 1)
aux = true;
}
if(aux) continue;
for(int i = 0;i < m;i++){
cout << res[i];
}
cout << '\n';
return 0;
}
cout << "impossible\n";
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... |