Type: Default 1000ms 256MiB

网格

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

【题目描述】

给出一个 n×mn \times m 的网格,其中小明初始站在 xy(x,y) 这个位置,网格内无障碍,小明可以向上下左右四个方向一步走一格,问小明最少走几步可以走出网格。

【输入格式】

第一行四个整数 nmxyn,m,x,y

【输出格式】

一行一个整数表示答案。

【样例输入】

3 3 2 2

【样例输出】

2

【数据范围】

对于 30%30\% 数据 n,m3n,m\leq 3

对于 50%50\% 数据 n,m1000n,m\leq 1000

对于 100%100\% 数据 n,m1000000000n,m\leq 10000000001xn1\leq x\leq n , 1ym1\leq y \leq m

7.12

Not Attended
Status
Done
Rule
IOI
Problem
5
Start at
2025-7-13 19:00
End at
2025-7-13 20:30
Duration
1.5 hour(s)
Host
Partic.
34