#include <bits/stdc++.h>
#define stop system("pause")
#define INP freopen("input.txt","r",stdin)
#define OUTP freopen("solve1.txt","w",stdout)
#define int long long
using namespace std;
typedef long long ll;
bool c1[1000],c2[1000];
int n,m;
void clean(int n){
for(int i(0); i < n;i++)c1[i] = c2[i] = 0;
}
void set_color(int x,int y,int c){
if(x <= y ){
for(int i(x);i<=y;i++){
if(c == 0)c1[i] = 1;
else c2[i] = 1;
}
}
else{
for(int i(x);i<n;i++){
if(c == 0)c1[i] = 1;
else c2[i] = 1;
}
for(int i(0);i<=y;i++){
if(c == 0)c1[i] = 1;
else c2[i] = 1;
}
}
}
bool check(){
for(int i(0); i < n;i++){
if(!c1[i] || !c2[i])return 0;
}
return 1;
}
main()
{
ios_base::sync_with_stdio(0);
cin >> n >> m;
vector<pair<int,int> > v;
for(int i(0); i < m;i++){
int a,b; cin >> a >> b;
v.push_back({a,b});
}
for(int mask(0); mask < (1<<m);mask++){
clean(n);
for(int j(0); j < m;j++){
if(mask&(1<<j))set_color(v[j].first,v[j].second,1);
else set_color(v[j].first,v[j].second,0);
}
if(check()){
for(int j(0); j < m;j++){
if(mask&(1<<j))cout << 1;
else cout << 0;
}
return 0;
}
}
cout << "impossible";
return 0;
}
/*
*/
Compilation message
alternating.cpp:43:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main()
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
380 KB |
'impossible' claimed, but there is a solution |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
380 KB |
'impossible' claimed, but there is a solution |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
380 KB |
'impossible' claimed, but there is a solution |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
27 ms |
4944 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
380 KB |
'impossible' claimed, but there is a solution |
2 |
Halted |
0 ms |
0 KB |
- |