Advertisement
Guest User

Untitled

a guest
Apr 4th, 2020
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.94 KB | None | 0 0
  1. Task:
  2.  
  3. Two knights are staying in an 8*8 chessboard.
  4.  
  5. Swap their positions.
  6.  
  7. These two knights can’t stay in one cell simultaneously.
  8.  
  9. It is known that at the start the first knight makes a move, and then both go by turns.
  10.  
  11. Input:
  12.  
  13. The first line contains coordinates (x1, y1) of the cell the first knight stands in.
  14.  
  15. The second line contains coordinates (x2, y2) of the cell the second knight stands in.
  16.  
  17. Output:
  18.  
  19. The first line should contain the minimal number of turns k.
  20.  
  21. The next k lines should contain three numbers each – firstly – the number of the knight making his move (either 1 or 2), secondly – the x coordinate of the move, thirdly – the y coordinate of the move.
  22.  
  23. If it’s impossible to swap the knights, write -1.
  24.  
  25. Example:
  26.  
  27. Input
  28.  
  29.  
  30. 3 2
  31.  
  32. 1 1
  33.  
  34. Output
  35.  
  36. 6
  37.  
  38. 1 2 4
  39.  
  40. 2 2 3
  41.  
  42. 1 3 2
  43.  
  44. 2 4 4
  45.  
  46. 1 1 1
  47.  
  48. 2 3 2
  49.  
  50. Input
  51.  
  52. 8 6
  53.  
  54. 8 1
  55.  
  56. Output
  57. 6
  58.  
  59. 1 7 4
  60.  
  61. 2 7 3
  62.  
  63. 1 6 2
  64.  
  65. 2 6 5
  66.  
  67. 1 8 1
  68.  
  69. 2 8 6
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement