Masala #0131
Shaxmat
n × n o’lchamli shaxmat doskasida shaxmat figurasi bor. (x0, y0) katakdan (x1, y1) ga borish uchun eng kam yurishlar sonini toping. (imkoni bo’lmasa -1 chiqaring)
shaxmat figurasi quyidagilar bo’lishi mumkin: Ot, Shoh, Fil, To’ra va Farzin.
Birinchi qatorda n(1 ≤ n ≤ 1000) va figuraning nomi. ("Ot", "Shoh", "Farzin", "Fil", "Tora").
Ikkinchi qatorda x0 va y0 (1 ≤ x0, y0 ≤ n) kiritiladi.
Uchinchi qatorda x1 va y1 (1 ≤ x1, y1 ≤ n) kiritiladi.
Bitta qatorda eng kam yurishlar sonini chiqaring.
# | input.txt | output.txt |
---|---|---|
1 |
5 Shoh 4 4 1 5 |
3 |