#include #include #include #include using namespace std; struct Rect { int x1,y1,x2,y2; Rect(int x1, int y1, int x2, int y2) { this->x1 = min(x1, x2); this->x2 = max(x1, x2); this->y1 = min(y1, y2); this->y2 = max(y1, y2); } bool contains(int x, int y) { return x1 <= x && x <= x2 && y1 <= y && y <= y2; } }; vector hits; set > visited; bool isWater(int x, int y) { for(Rect& hit : hits) { if(hit.contains(x, y)) return true; } return false; } bool isReachable(int x1, int y1, int x2, int y2) { pair current; current.first = x1; current.second = y1; if(visited.find(current) != visited.end()) return 0; visited.insert(current); if(!isWater(x1, y1)) { return 0; } if(x1 == x2 && y1 == y2) return 1; return isReachable(x1+1, y1, x2, y2) || isReachable(x1-1, y1, x2, y2) || isReachable(x1, y1+1, x2, y2) || isReachable(x1 , y1-1, x2, y2); } int main() { int L; cin >> L; int t,x1,y1,x2,y2; for(int l = 0; l < L; l++) { cin >> t >> x1 >> y1 >> x2 >> y2; if(t == 0) { hits.push_back(Rect(x1,y1,x2,y2)); } else { visited.clear(); cout << (isReachable(x1,y1,x2,y2) ? 1 : 0) << endl; } } //for(Rect r : hits) { //cout << r.x1 << ' ' << r.y1 << ' ' << r.x2 << ' ' << r.y2 << endl; //} return 0; }