#P1746. 离开中山路
离开中山路
Description
After shopping, Aiyuchou plans to take a bus to leave Zhongshan Road. He is at , and the station is at . You are given an map, where represents road and represents shop (cannot pass through shops). Aiyuchou can move only vertically or horizontally along roads. To save time, he wants the shortest distance to the destination (the distance between two adjacent coordinates is ). Can you help him?
Input Format
Line contains an integer .
Lines to : the entire map description ( represents road, represents shop; note there are no spaces between numbers).
Line : four integers .
Output Format
Only line, the shortest distance to the destination.
3
001
101
100
1 1 3 3
4
Hint
For of the testdata, .
For of the testdata, .
Translated by ChatGPT 5
京公网安备 11011102002149号