기출 문제 / 삼성 2024 Second Half Afternoon Problem 1

Medusa and the Warriors

Medusa lives in a village represented by an N×N grid, where N ranges from 0 to N−1. The village has roads, which are denoted by 0, and non-road areas, which are denoted by 1.

Medusa decides to take a walk from her house to the park. Her house is located at coordinates (Sr,Sc), and the park is located at coordinates (Er,Ec).