| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 | 512 MB | 5 | 4 | 4 | 80.000% |
You are using an editor to type in a program that you hope solves another problem on this contest. Instead of thinking about solving this problem, you look at your editor and start to think of how to edit your program more quickly.
Your editor has the following characteristics:
You would like to find the least number of key presses that will cause you to move between positions in your editor in a given program which you are editing.
The first line of input is N, the number of lines of your program (1 ≤ N ≤ 100000). The next N lines contain the number of characters on each line: you can assume there is at least one character per line, and at most 80 characters per line. The next line contains two integers RS CS, indicating the starting row and column of the cursor (1 ≤ RS ≤ N, 1 ≤ CS, and CS is at most the number of characters in row RS). The last line contains two integers RF CF , indicating the finishing row and column of the cursor (1 ≤ RF ≤ N, 1 ≤ CF , and CF is at most the number of characters in row RF).
Output the minimum number of key presses that are required to move the cursor from row RS and column CS to row RF and column CF .
4 40 10 4 80 4 78 1 35
10