#include #include #include #include #include #include #include using namespace std; typedef bitset<62750> bits; int h,w; int main_(){ scanf("%d%d", &h,&w); vector> a(h, vector(w)); for(int i=0; i>1) | (z<<(w+1)) | (z>>(w+1))) & s; if(z == last) break; } }else{ bits ns = (~s & filter); while(1){ bits last = z; z |= ((z<<1) | (z>>1) | (z<<(w+1)) | (z>>(w+1))) & ns; if(z == last) break; } } s ^= z; int cnt = s.count(); filled = cnt == 0 || cnt == h*w; //dbg(); } if(filled){ s.reset(); if(last == 1) s.flip(); } string tmp = s.to_string(); reverse(tmp.begin(), tmp.end()); for(int i=0; i