PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#FW0000031. Đến lễ hội bằng các điểm tiếp tế (Kastenlauf)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Đến lễ hội bằng các điểm tiếp tế (Kastenlauf)
Kastenlauf
Source: Kattis
Version: Phuoc Hung OJ Extended
Problem Statement
Starting at home with supplies for 1000 meters of Manhattan travel, replenishing at shops, determine whether the festival is reachable.
Input
Integer stores, followed by coordinate pairs: home, the stores, and the festival.
Output
Print happy if the festival is reachable, otherwise sad.
Subtasks
- Subtask 1 (40 points): ; , ; Manhattan distance, each hop at most .
- Subtask 2 (60 points): , ; Manhattan distance, each hop at most .
Examples
Input
2
0 0
1000 0
1000 1000
2000 1000
Output
happy
Explanation
There are three successive Manhattan hops of meters: home to first store, first to second store, then second store to festival. Refilling at each store makes arrival possible.