結果
| 問題 |
No.3369 Find MyakuMyaku
|
| コンテスト | |
| ユーザー |
risujiroh
|
| 提出日時 | 2025-11-17 23:48:28 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 87 ms / 2,000 ms |
| コード長 | 3,509 bytes |
| コンパイル時間 | 3,428 ms |
| コンパイル使用メモリ | 305,856 KB |
| 実行使用メモリ | 25,448 KB |
| 最終ジャッジ日時 | 2025-11-17 23:48:35 |
| 合計ジャッジ時間 | 6,812 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 40 |
ソースコード
#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<bitset<1024>> bs(h);
for (int i : Rep(0, h)) {
for (int j : Rep(0, w)) {
bs[i][j] = true;
}
}
Array2D<int> 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;
}
bs[i] &= ~mask;
}
}
vector<vector<pair<int, int>>> 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);
Array2D<int> vis(h, w);
int cc = 0;
auto merge = [&](int i, int j) {
if (dsu.same(i, j)) {
return;
}
dsu.merge(i, j);
--cc;
};
basic_string<bool> ans(n, true);
for (int t : Rev(Rep1(1, n))) {
for (auto [i, j] : lst[t]) {
vis[i][j] = true;
++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 <bits/stdc++.h>
#include <atcoder/dsu.hpp>
template <class T>
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<T>(data_.data() + i * w_, w_); }
auto operator[](int i) const { return std::span<const T>(data_.data() + i * w_, w_); }
private:
int h_;
int w_;
std::vector<T> data_;
};
namespace std {
template <size_t N>
auto begin(const bitset<N>& x) {
struct I {
const bitset<N>* 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 <size_t N>
int end(const bitset<N>&) {
return 0;
}
} // namespace std
template <class T> concept MyRange = std::ranges::range<T> && !std::convertible_to<T, std::string_view>;
template <class T> concept MyTuple = std::__is_tuple_like<T>::value && !MyRange<T>;
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
risujiroh