codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

370A.md (2072B)


      1 Source: https://codeforces.com/problemset/problem/370/A
      2 
      3 A. Rook, Bishop and King
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 Little Petya is learning to play chess. He has already learned how to move a king, a rook and a bishop. Let us remind you the rules of moving chess pieces. A chessboard is 64 square fields organized into an 8 × 8 table. A field is represented by a pair of integers (*r*, *c*) — the number of the row and the number of the column (in a classical game the columns are traditionally indexed by letters). Each chess piece takes up exactly one field. To make a move is to move a chess piece, the pieces move by the following rules:
     22 
     23 * A rook moves any number of fields horizontally or vertically.
     24 * A bishop moves any number of fields diagonally.
     25 * A king moves one field in any direction — horizontally, vertically or diagonally.
     26 
     27  ![](https://espresso.codeforces.com/463df410b49bbc811afc7291771c0af80a152085.png) The pieces move like that 
     28 
     29 Petya is thinking about the following problem: what minimum number of moves is needed for each of these pieces to move from field (*r*1, *c*1) to field (*r*2, *c*2)? At that, we assume that there are no more pieces besides this one on the board. Help him solve this problem.
     30 
     31 Input
     32 
     33 The input contains four integers *r*1, *c*1, *r*2, *c*2 (1 ≤ *r*1, *c*1, *r*2, *c*2 ≤ 8) — the coordinates of the starting and the final field. The starting field doesn't coincide with the final one.
     34 
     35 You can assume that the chessboard rows are numbered from top to bottom 1 through 8, and the columns are numbered from left to right 1 through 8.
     36 
     37 Output
     38 
     39 Print three space-separated integers: the minimum number of moves the rook, the bishop and the king (in this order) is needed to move from field (*r*1, *c*1) to field (*r*2, *c*2). If a piece cannot make such a move, print a 0 instead of the corresponding number.
     40 
     41 Examples
     42 
     43 Input
     44 
     45 ```
     46 4 3 1 6
     47 ```
     48 
     49 Output
     50 
     51 ```
     52 2 1 3
     53 ```
     54 
     55 Input
     56 
     57 ```
     58 5 5 5 6
     59 ```
     60 
     61 Output
     62 
     63 ```
     64 1 0 1
     65 ```