-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathh.cpp
46 lines (43 loc) · 1.09 KB
/
h.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <bits/stdc++.h>
#define endl "\n"
#define eat cin
#define moo cout
using namespace std;
int T, N, M;
int32_t main(){
eat.tie(0) -> sync_with_stdio(0);
eat >> T;
while(T--){
eat >> N >> M;
long long ans = (1LL<<(M-1))-1;
int b = -1;
set<long long> vis;
for(int i = 0; i < N; i++){
string s; eat >> s;
long long x = stoll(s, 0, 2);
vis.insert(x);
if(x == ans){
if(b == 0){
b = -1;
while(vis.count(--ans)){}
}else{
b = 0;
while(vis.count(++ans)){}
}
}else if(x < ans){
b--;
if(b < -1){
b = 0;
while(vis.count(++ans)){}
}
}else{
b++;
if(b > 0){
b = -1;
while(vis.count(--ans)){}
}
}
}
moo << bitset<60>(ans).to_string().substr(60-M) << endl;
}
}