/* Author : Mychecksdead */
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define MOD (1000000000+7)
#define MOD1 (998244353)
#define PI 3.1415926535
#define pb push_back
#define setp() cout << setprecision(15)
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " is " << x << '\n';
const int N = 1e6+100, M = 1e5+10, F = 2147483646, K = 20;
int n, m;
vector<int> v[N];
void solve(){
cin >> n >> m;
for(int i = 0; i < m; ++i){
int x, y; cin >> x >> y;
x--, y--;
if(x>y){
for(int j = x; j < n; ++j) v[j].pb(i);
for(int j = 0; j <= y; ++j) v[j].pb(i);
}else{
for(int j = x; j <= y; ++j) v[j].pb(i);
}
}
for(int mask = 0; mask < (1<<m); ++mask){
bool ok = 1;
for(int i = 0; i < n; ++i){
bool a = 0, b = 0;
for(int x: v[i]){
a |= (mask&(1<<x)) > 0;
b |= (mask&(1<<x)) == 0;
}
if(!(a && b)){
ok = 0;
}
}
if(ok){
for(int i = 0; i < m; ++i) cout << ((mask&(1<<i))>0);
return;
}
}
cout << "impossible";
}
int main(){
cin.tie(0); ios::sync_with_stdio(0);
int T = 1, aa;
// cin >> T;aa=T;
while(T--){
// cout << "Case #" << aa-T << ": ";
solve();
cout << '\n';
}
return 0;
}
Compilation message
alternating.cpp: In function 'int main()':
alternating.cpp:57:16: warning: unused variable 'aa' [-Wunused-variable]
57 | int T = 1, aa;
| ^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
23764 KB |
Output is correct |
2 |
Correct |
12 ms |
23764 KB |
Output is correct |
3 |
Correct |
14 ms |
23808 KB |
Output is correct |
4 |
Correct |
12 ms |
23804 KB |
Output is correct |
5 |
Correct |
12 ms |
23764 KB |
Output is correct |
6 |
Correct |
12 ms |
23880 KB |
Output is correct |
7 |
Correct |
13 ms |
23764 KB |
Output is correct |
8 |
Correct |
13 ms |
23812 KB |
Output is correct |
9 |
Correct |
11 ms |
23764 KB |
Output is correct |
10 |
Correct |
11 ms |
23764 KB |
Output is correct |
11 |
Correct |
13 ms |
23764 KB |
Output is correct |
12 |
Correct |
13 ms |
23732 KB |
Output is correct |
13 |
Correct |
13 ms |
23676 KB |
Output is correct |
14 |
Correct |
13 ms |
23812 KB |
Output is correct |
15 |
Correct |
11 ms |
23704 KB |
Output is correct |
16 |
Correct |
12 ms |
23764 KB |
Output is correct |
17 |
Correct |
12 ms |
23776 KB |
Output is correct |
18 |
Correct |
12 ms |
23764 KB |
Output is correct |
19 |
Correct |
12 ms |
23736 KB |
Output is correct |
20 |
Correct |
13 ms |
23764 KB |
Output is correct |
21 |
Correct |
12 ms |
23780 KB |
Output is correct |
22 |
Correct |
13 ms |
23808 KB |
Output is correct |
23 |
Correct |
12 ms |
23764 KB |
Output is correct |
24 |
Correct |
12 ms |
23808 KB |
Output is correct |
25 |
Correct |
13 ms |
23808 KB |
Output is correct |
26 |
Correct |
12 ms |
23764 KB |
Output is correct |
27 |
Correct |
13 ms |
23764 KB |
Output is correct |
28 |
Correct |
11 ms |
23764 KB |
Output is correct |
29 |
Correct |
11 ms |
23720 KB |
Output is correct |
30 |
Correct |
11 ms |
23764 KB |
Output is correct |
31 |
Correct |
12 ms |
23744 KB |
Output is correct |
32 |
Correct |
12 ms |
23764 KB |
Output is correct |
33 |
Correct |
12 ms |
23764 KB |
Output is correct |
34 |
Correct |
12 ms |
23804 KB |
Output is correct |
35 |
Correct |
15 ms |
23764 KB |
Output is correct |
36 |
Correct |
12 ms |
23764 KB |
Output is correct |
37 |
Correct |
15 ms |
23736 KB |
Output is correct |
38 |
Correct |
15 ms |
23816 KB |
Output is correct |
39 |
Correct |
13 ms |
23808 KB |
Output is correct |
40 |
Correct |
12 ms |
23764 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
23764 KB |
Output is correct |
2 |
Correct |
12 ms |
23764 KB |
Output is correct |
3 |
Correct |
14 ms |
23808 KB |
Output is correct |
4 |
Correct |
12 ms |
23804 KB |
Output is correct |
5 |
Correct |
12 ms |
23764 KB |
Output is correct |
6 |
Correct |
12 ms |
23880 KB |
Output is correct |
7 |
Correct |
13 ms |
23764 KB |
Output is correct |
8 |
Correct |
13 ms |
23812 KB |
Output is correct |
9 |
Correct |
11 ms |
23764 KB |
Output is correct |
10 |
Correct |
11 ms |
23764 KB |
Output is correct |
11 |
Correct |
13 ms |
23764 KB |
Output is correct |
12 |
Correct |
13 ms |
23732 KB |
Output is correct |
13 |
Correct |
13 ms |
23676 KB |
Output is correct |
14 |
Correct |
13 ms |
23812 KB |
Output is correct |
15 |
Correct |
11 ms |
23704 KB |
Output is correct |
16 |
Correct |
12 ms |
23764 KB |
Output is correct |
17 |
Correct |
12 ms |
23776 KB |
Output is correct |
18 |
Correct |
12 ms |
23764 KB |
Output is correct |
19 |
Correct |
12 ms |
23736 KB |
Output is correct |
20 |
Correct |
13 ms |
23764 KB |
Output is correct |
21 |
Correct |
12 ms |
23780 KB |
Output is correct |
22 |
Correct |
13 ms |
23808 KB |
Output is correct |
23 |
Correct |
12 ms |
23764 KB |
Output is correct |
24 |
Correct |
12 ms |
23808 KB |
Output is correct |
25 |
Correct |
13 ms |
23808 KB |
Output is correct |
26 |
Correct |
12 ms |
23764 KB |
Output is correct |
27 |
Correct |
13 ms |
23764 KB |
Output is correct |
28 |
Correct |
11 ms |
23764 KB |
Output is correct |
29 |
Correct |
11 ms |
23720 KB |
Output is correct |
30 |
Correct |
11 ms |
23764 KB |
Output is correct |
31 |
Correct |
12 ms |
23744 KB |
Output is correct |
32 |
Correct |
12 ms |
23764 KB |
Output is correct |
33 |
Correct |
12 ms |
23764 KB |
Output is correct |
34 |
Correct |
12 ms |
23804 KB |
Output is correct |
35 |
Correct |
15 ms |
23764 KB |
Output is correct |
36 |
Correct |
12 ms |
23764 KB |
Output is correct |
37 |
Correct |
15 ms |
23736 KB |
Output is correct |
38 |
Correct |
15 ms |
23816 KB |
Output is correct |
39 |
Correct |
13 ms |
23808 KB |
Output is correct |
40 |
Correct |
12 ms |
23764 KB |
Output is correct |
41 |
Correct |
12 ms |
23812 KB |
Output is correct |
42 |
Correct |
12 ms |
23764 KB |
Output is correct |
43 |
Incorrect |
12 ms |
23764 KB |
'impossible' claimed, but there is a solution |
44 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
23764 KB |
Output is correct |
2 |
Correct |
12 ms |
23764 KB |
Output is correct |
3 |
Correct |
14 ms |
23808 KB |
Output is correct |
4 |
Correct |
12 ms |
23804 KB |
Output is correct |
5 |
Correct |
12 ms |
23764 KB |
Output is correct |
6 |
Correct |
12 ms |
23880 KB |
Output is correct |
7 |
Correct |
13 ms |
23764 KB |
Output is correct |
8 |
Correct |
13 ms |
23812 KB |
Output is correct |
9 |
Correct |
11 ms |
23764 KB |
Output is correct |
10 |
Correct |
11 ms |
23764 KB |
Output is correct |
11 |
Correct |
13 ms |
23764 KB |
Output is correct |
12 |
Correct |
13 ms |
23732 KB |
Output is correct |
13 |
Correct |
13 ms |
23676 KB |
Output is correct |
14 |
Correct |
13 ms |
23812 KB |
Output is correct |
15 |
Correct |
11 ms |
23704 KB |
Output is correct |
16 |
Correct |
12 ms |
23764 KB |
Output is correct |
17 |
Correct |
12 ms |
23776 KB |
Output is correct |
18 |
Correct |
12 ms |
23764 KB |
Output is correct |
19 |
Correct |
12 ms |
23736 KB |
Output is correct |
20 |
Correct |
13 ms |
23764 KB |
Output is correct |
21 |
Correct |
12 ms |
23780 KB |
Output is correct |
22 |
Correct |
13 ms |
23808 KB |
Output is correct |
23 |
Correct |
12 ms |
23764 KB |
Output is correct |
24 |
Correct |
12 ms |
23808 KB |
Output is correct |
25 |
Correct |
13 ms |
23808 KB |
Output is correct |
26 |
Correct |
12 ms |
23764 KB |
Output is correct |
27 |
Correct |
13 ms |
23764 KB |
Output is correct |
28 |
Correct |
11 ms |
23764 KB |
Output is correct |
29 |
Correct |
11 ms |
23720 KB |
Output is correct |
30 |
Correct |
11 ms |
23764 KB |
Output is correct |
31 |
Correct |
12 ms |
23744 KB |
Output is correct |
32 |
Correct |
12 ms |
23764 KB |
Output is correct |
33 |
Correct |
12 ms |
23764 KB |
Output is correct |
34 |
Correct |
12 ms |
23804 KB |
Output is correct |
35 |
Correct |
15 ms |
23764 KB |
Output is correct |
36 |
Correct |
12 ms |
23764 KB |
Output is correct |
37 |
Correct |
15 ms |
23736 KB |
Output is correct |
38 |
Correct |
15 ms |
23816 KB |
Output is correct |
39 |
Correct |
13 ms |
23808 KB |
Output is correct |
40 |
Correct |
12 ms |
23764 KB |
Output is correct |
41 |
Correct |
12 ms |
23812 KB |
Output is correct |
42 |
Correct |
12 ms |
23764 KB |
Output is correct |
43 |
Incorrect |
12 ms |
23764 KB |
'impossible' claimed, but there is a solution |
44 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3087 ms |
827568 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
23764 KB |
Output is correct |
2 |
Correct |
12 ms |
23764 KB |
Output is correct |
3 |
Correct |
14 ms |
23808 KB |
Output is correct |
4 |
Correct |
12 ms |
23804 KB |
Output is correct |
5 |
Correct |
12 ms |
23764 KB |
Output is correct |
6 |
Correct |
12 ms |
23880 KB |
Output is correct |
7 |
Correct |
13 ms |
23764 KB |
Output is correct |
8 |
Correct |
13 ms |
23812 KB |
Output is correct |
9 |
Correct |
11 ms |
23764 KB |
Output is correct |
10 |
Correct |
11 ms |
23764 KB |
Output is correct |
11 |
Correct |
13 ms |
23764 KB |
Output is correct |
12 |
Correct |
13 ms |
23732 KB |
Output is correct |
13 |
Correct |
13 ms |
23676 KB |
Output is correct |
14 |
Correct |
13 ms |
23812 KB |
Output is correct |
15 |
Correct |
11 ms |
23704 KB |
Output is correct |
16 |
Correct |
12 ms |
23764 KB |
Output is correct |
17 |
Correct |
12 ms |
23776 KB |
Output is correct |
18 |
Correct |
12 ms |
23764 KB |
Output is correct |
19 |
Correct |
12 ms |
23736 KB |
Output is correct |
20 |
Correct |
13 ms |
23764 KB |
Output is correct |
21 |
Correct |
12 ms |
23780 KB |
Output is correct |
22 |
Correct |
13 ms |
23808 KB |
Output is correct |
23 |
Correct |
12 ms |
23764 KB |
Output is correct |
24 |
Correct |
12 ms |
23808 KB |
Output is correct |
25 |
Correct |
13 ms |
23808 KB |
Output is correct |
26 |
Correct |
12 ms |
23764 KB |
Output is correct |
27 |
Correct |
13 ms |
23764 KB |
Output is correct |
28 |
Correct |
11 ms |
23764 KB |
Output is correct |
29 |
Correct |
11 ms |
23720 KB |
Output is correct |
30 |
Correct |
11 ms |
23764 KB |
Output is correct |
31 |
Correct |
12 ms |
23744 KB |
Output is correct |
32 |
Correct |
12 ms |
23764 KB |
Output is correct |
33 |
Correct |
12 ms |
23764 KB |
Output is correct |
34 |
Correct |
12 ms |
23804 KB |
Output is correct |
35 |
Correct |
15 ms |
23764 KB |
Output is correct |
36 |
Correct |
12 ms |
23764 KB |
Output is correct |
37 |
Correct |
15 ms |
23736 KB |
Output is correct |
38 |
Correct |
15 ms |
23816 KB |
Output is correct |
39 |
Correct |
13 ms |
23808 KB |
Output is correct |
40 |
Correct |
12 ms |
23764 KB |
Output is correct |
41 |
Correct |
12 ms |
23812 KB |
Output is correct |
42 |
Correct |
12 ms |
23764 KB |
Output is correct |
43 |
Incorrect |
12 ms |
23764 KB |
'impossible' claimed, but there is a solution |
44 |
Halted |
0 ms |
0 KB |
- |