message: Update minimum-obstacle-removal-to-reach-corner.cpp
diff: @@ -18,25 +18,25 @@ private:
  {1, 0}, {-1, 0}};
  int f = 0, dh = 1;
  vector<pair<int, int>> closer = {b}, detour;
  - vector<vector<bool>> lookup(size(grid), vector<bool>(size(grid[0])));
  + unordered_set<int> lookup;
  while (!closer.empty() || !detour.empty()) {
  if (closer.empty()) {
  f += dh;
  swap(closer, detour);
  }
  const auto b = closer.back(); closer.pop_back();
  + if (lookup.count(b.first * size(grid[0]) + b.second)) {
  + continue;
  + }
  + lookup.emplace(b.first * size(grid[0]) + b.second);
  if (b == t) {
  return f;
  }
  - if (lookup[b.first][b.second]) {
  - continue;
  - }
  - lookup[b.first][b.second] = true;
  for (const auto& [dr, dc] : directions) {
  const pair<int, int>& nb = {b.first + dr, b.second + dc};
  if (!(0 <= nb.first && nb.first < grid.size() &&
  0 <= nb.second && nb.second < grid[0].size() &&
  - !lookup[nb.first][nb.second])) {
  + !lookup.count(nb.first * size(grid[0]) + nb.second))) {
  continue;
  }
  if (!grid[b.first][b.second]) {
  @@ -60,21 +60,21 @@ public:
  {1, 0}, {-1, 0}};
  const pair<int, int> b = {0, 0}, t = {grid.size() - 1, grid[0].size() - 1};
  deque<pair<pair<int, int>, int>> dq = {{b, 0}};
  - vector<vector<bool>> lookup(size(grid), vector<bool>(size(grid[0])));
  + unordered_set<int> lookup;
  while (!dq.empty()) {
  const auto [b, d] = dq.front(); dq.pop_front();
  if (b == t) {
  return d;
  }
  - if (lookup[b.first][b.second]) {
  + if (lookup.count(b.first * size(grid[0]) + b.second)) {
  continue;
  }
  - lookup[b.first][b.second] = true;
  + lookup.emplace(b.first * size(grid[0]) + b.second);
  for (const auto& [dr, dc] : directions) {
  const auto& nb = make_pair(b.first + dr, b.second + dc);
  if (!(0 <= nb.first && nb.first < grid.size() &&
  0 <= nb.second && nb.second < grid[0].size() &&
  - !lookup[nb.first][nb.second])) {
  + !lookup.count(nb.first * size(grid[0]) + nb.second))) {
  continue;
  }
  if (!grid[nb.first][nb.second]) {
  