#include #include #include #include using namespace std ; int w, h, a ; typedef long long ll ; typedef unsigned long long ull ; vector moves ; vector q ; set seen ; int main() { cin >> w >> h ; int a = w * h ; if (a > 64) { // dummy loop to make it TLE even when we can't handle the input while (a > 60) a |= 1 ; cout << "Limits too large for this program." << endl ; } for (int m=0; m ends ; string row ; for (int i=0; i<2; i++) { ull v = 0 ; for (int y=0; y> row ; for (int x=0; x> m) & 1) == 0) continue ; ull t = (moves[m] | v) & ~(1LL << m) ; if (seen.find(t) == seen.end()) { seen.insert(t) ; q.push_back(t) ; if (t == target) { cout << 1 << endl ; exit(0) ; } } } } cout << 0 << endl ; }