题目链接:http://codeforces.com/group/Us3rfLfgWv/contest/101572
真的是巧。。打场cf做了里面的2道题就知道这题该怎么做了。。
http://codeforces.com/contest/986/problem/C
http://codeforces.com/contest/986/problem/A
其实,给定的m个数其实都在2^n内。。所以只要建个包含这2^n个结点的图,然后对每个点,往变换一次的点连长度为1的边即可。。然后问题就转化为求一个点使它到这m个点的路径的最大值d最小。。
那么就很简单了。。因为在这m个点上的d是n,然后以这m个点为中心往外扩散分别取最大值,这样可以算出每个点的最大值。。所以bfs一遍就完了。。
/**
* ┏┓ ┏┓
* ┏┛┗━━━━━━━┛┗━━━┓
* ┃ ┃
* ┃ ━ ┃
* ┃ > < ┃
* ┃ ┃
* ┃... ⌒ ... ┃
* ┃ ┃
* ┗━┓ ┏━┛
* ┃ ┃ Code is far away from bug with the animal protecting
* ┃ ┃ 神兽保佑,代码无bug
* ┃ ┃
* ┃ ┃
* ┃ ┃
* ┃ ┃
* ┃ ┗━━━┓
* ┃ ┣┓
* ┃ ┏┛
* ┗┓┓┏━━━━━━━━┳┓┏┛
* ┃┫┫ ┃┫┫
* ┗┻┛ ┗┻┛
*/
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<queue>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#define inc(i,l,r) for(int i=l;i<=r;i++)
#define dec(i,l,r) for(int i=l;i>=r;i--)
#define link(x) for(edge *j=h[x];j;j=j->next)
#define mem(a) memset(a,0,sizeof(a))
#define ll long long
#define eps 1e-12
#define succ(x) (1<<x)
#define lowbit(x) (x&(-x))
#define sqr(x) ((x)*(x))
#define mid (x+y>>1)
#define NM 5000005
#define nm 5000005
#define pi 3.1415926535897931
const ll inf=1000000007;
using namespace std;
ll read(){
ll x=0,f=1;char ch=getchar();
while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
return f*x;
}
int n,m,_x,_y,d[NM],ans;
queue<int>q;
int main(){
n=read();m=read();
inc(i,1,n){
_x=0;
inc(i,1,m)scanf("%1d",&_y),_x=_x*2+_y;
q.push(_x);d[_x]=1;
}
while(!q.empty()){
int t=q.front();q.pop();
inc(i,1,m)if(!d[succ(i-1)^t])d[succ(i-1)^t]=d[t]+1,q.push(succ(i-1)^t);
ans=t;
}
dec(i,m,1)printf("%d",!!(succ(i-1)&ans));putchar('\n');
return 0;
}