883M.md (1871B)
1 Source: https://codeforces.com/problemset/problem/883/M 2 3 M. Quadcopter Competition 4 5 time limit per test 6 7 3 seconds 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: 22 23 * start the race from some point of a field, 24 * go around the flag, 25 * close cycle returning back to the starting point. 26 27 Polycarp knows the coordinates of the starting point (*x*1, *y*1) and the coordinates of the point where the flag is situated (*x*2, *y*2). Polycarp’s quadcopter can fly only parallel to the sides of the field each tick changing exactly one coordinate by 1. It means that in one tick the quadcopter can fly from the point (*x*, *y*) to any of four points: (*x* - 1, *y*), (*x* + 1, *y*), (*x*, *y* - 1) or (*x*, *y* + 1). 28 29 Thus the quadcopter path is a closed cycle starting and finishing in (*x*1, *y*1) and containing the point (*x*2, *y*2) strictly inside. 30 31  The picture corresponds to the first example: the starting (and finishing) point is in (1, 5) and the flag is in (5, 2). 32 33 What is the minimal length of the quadcopter path? 34 35 Input 36 37 The first line contains two integer numbers *x*1 and *y*1 ( - 100 ≤ *x*1, *y*1 ≤ 100) — coordinates of the quadcopter starting (and finishing) point. 38 39 The second line contains two integer numbers *x*2 and *y*2 ( - 100 ≤ *x*2, *y*2 ≤ 100) — coordinates of the flag. 40 41 It is guaranteed that the quadcopter starting point and the flag do not coincide. 42 43 Output 44 45 Print the length of minimal path of the quadcopter to surround the flag and return back. 46 47 Examples 48 49 Input 50 51 ``` 52 1 5 53 5 2 54 ``` 55 56 Output 57 58 ``` 59 18 60 ``` 61 62 Input 63 64 ``` 65 0 1 66 0 0 67 ``` 68 69 Output 70 71 ``` 72 8 73 ```