#if __INCLUDE_LEVEL__ == 0 #include __BASE_FILE__ constexpr array DI{0, 1, 0, -1}; constexpr array DJ{1, 0, -1, 0}; void Solve() { int n, h, w; IN(n, h, w); h += 2; w += 2; vector> bs(h); for (int i : Rep(0, h)) { for (int j : Rep(0, w)) { bs[i][j] = true; } } Array2D when(h, w, n); for (int t : Rep(0, n)) { int li, ri, lj, rj; IN(li, ri, lj, rj); ++ri, ++rj; bitset<1024> mask; for (int j : Rep(lj, rj)) { mask[j] = true; } for (int i : Rep(li, ri)) { for (int j : bs[i] & mask) { when[i][j] = t; } } } vector>> lst(n + 1); for (int i : Rep(0, h)) { for (int j : Rep(0, w)) { lst[when[i][j]].emplace_back(i, j); } } atcoder::dsu dsu(h * w); vector cnt(h * w); Array2D vis(h, w); int cc = 0; auto merge = [&](int i, int j) { i = dsu.leader(i); j = dsu.leader(j); if (i == j) { return; } cnt[dsu.merge(i, j)] = cnt[i] + cnt[j]; --cc; }; basic_string ans(n, true); for (int t : Rev(Rep1(1, n))) { for (auto [i, j] : lst[t]) { vis[i][j] = true; cnt[i * w + j] = 1; ++cc; for (int dir : Rep(0, 4)) { int ni = i + DI[dir]; int nj = j + DJ[dir]; if (0 <= ni && ni < h && 0 <= nj && nj < w && vis[ni][nj]) { merge(i * w + j, ni * w + nj); } } } if (cc == 1) { ans[t - 1] = false; } } for (bool e : ans) { OUT(e ? "Yes" : "No"); } } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); Solve(); } #elif __INCLUDE_LEVEL__ == 1 #include #include template class Array2D { public: Array2D() : Array2D(0, 0) {} Array2D(int h, int w, T v = {}) : h_(h), w_(w), data_(h * w, std::move(v)) {} auto operator[](int i) { return std::span(data_.data() + i * w_, w_); } auto operator[](int i) const { return std::span(data_.data() + i * w_, w_); } private: int h_; int w_; std::vector data_; }; namespace std { template auto begin(const bitset& x) { struct I { const bitset* p; size_t i; bool operator!=(int) const { return i < p->size(); } void operator++() { i = p->_Find_next(i); } int operator*() const { return int(i); } }; return I{&x, x._Find_first()}; } template int end(const bitset&) { return 0; } } // namespace std template concept MyRange = std::ranges::range && !std::convertible_to; template concept MyTuple = std::__is_tuple_like::value && !MyRange; namespace std { istream& operator>>(istream& is, MyRange auto&& r) { for (auto&& e : r) is >> e; return is; } istream& operator>>(istream& is, MyTuple auto&& t) { apply([&](auto&... xs) { (is >> ... >> xs); }, t); return is; } ostream& operator<<(ostream& os, MyRange auto&& r) { auto sep = ""; for (auto&& e : r) os << exchange(sep, " ") << e; return os; } ostream& operator<<(ostream& os, MyTuple auto&& t) { auto sep = ""; apply([&](auto&... xs) { ((os << exchange(sep, " ") << xs), ...); }, t); return os; } } // namespace std using namespace std; #define Rev views::reverse #define Rep(...) [](int l, int r) { return views::iota(min(l, r), r); }(__VA_ARGS__) #define Rep1(...) [](int l, int r) { return Rep(l, r + 1); }(__VA_ARGS__) #define IN(...) (cin >> forward_as_tuple(__VA_ARGS__)) #define OUT(...) (cout << forward_as_tuple(__VA_ARGS__) << '\n') #endif // __INCLUDE_LEVEL__ == 1