Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8549447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:42:54+00:00 2026-06-11T13:42:54+00:00

I have a grid with a start, finish, and some walls. Units take the

  • 0

I have a grid with a start, finish, and some walls. Units take the shortest path (moving only up/down/left/right) from the start to the finish, without passing through walls.

shortest path

The user is allowed to add as many extra walls as they want to change the path.

adding walls

However, notice that no matter how many walls are added or where they’re added, there are some squares that can never be part of the shortest path!

These squares can never be part of the shortest path!
These squares can never be part of the shortest path!

I’m looking for a way to detect which squares can never be part of the shortest path.


The above cases are easy enough to find; but there are more complex cases. Consider:

None of the squares with red-dots can ever be part of the best-path

In the above image, none of the squares with red dots can ever be part of the best path, because there’s only one entrance to that area, and it’s only two spaces wide. If it were three spaces wide, or if any one of the walls were removed, most of those squares could potentially be part of the best path.

I’ve been trying to figure out a way to detect cases like the above (mostly using min-cuts and flood-fills), but without success. Does anyone know of a way to solve this problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T13:42:55+00:00Added an answer on June 11, 2026 at 1:42 pm

    Consider any path from S to F. That path could be a shortest path (if you delete every other square) unless you can take “shortcuts” using only those tiles. This only happens when you have two adjacent squares that aren’t adjacent in the path. So you need to consider all pairs of adjacent squares; anything they disconnect from S or F (without disconnecting S from F) can’t be part of a shortest path. Also, tiles that can be disconnected by a single square can’t be part of any path (that doesn’t repeat vertices) from S to F, so they need to go too.

    Let N be the number of squares in the grid. For any particular pair of squares (there are O(N) of them), what gets disconnected can be computed in O(N) time with a floodfill, so this is O(N^2). Which is cheaper than min-cut, which you mentioned trying, so I assume its cheap enough for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have grid with some textboxes and an image which goes out of grid
I have a grid with some controls inside. I want to hide the grid
Hello i have this grid working fine here: http://tourscript.com/jqueryasp/default2.asp i start adding a pagination
I have selenium grid 2 hub running on one server. I start up another
I have a grid with bunch of columns in it. To start with this
I am about to start a task where I will have a grid of
I have a grid of many 10x10 pixel squares separated only by a pixel
i have a paging grid and some function that load a new store to
We have some columns in a grid that contain numbers, strings, or strings that
I have a JQuery grid which I am reloading everytime when some event occurs

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.