#BS0000396. Nhìn qua khu rừng (Forest for the Trees)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Nhìn qua khu rừng (Forest for the Trees)
Forest for the Trees
Source: Kattis
Version: Phuoc Hung OJ Extended
Problem Statement
You and Belle play hide-and-seek in a forest. Initially every point with two positive integer coordinates contains a tree, treated as a point. A logging company removes all trees in an axis-aligned rectangle, including its boundary. You stand at and Belle at . Belle is visible exactly when no remaining tree lies strictly between you on the connecting segment. If a tree stands at her location, she stands on its side facing you, so it does not block the view. Determine whether she is visible and, if not, find the nearest blocking tree.

Input
The first line contains integers . The second line contains integers , the opposite corners of the cleared rectangle.
Output
If Belle is visible, print Yes. Otherwise print No on the first line and the two integer coordinates of the nearest blocking tree on the second line.
Subtasks
- Subtask 1 (20 points): ; ; . ; .
- Subtask 2 (30 points): ; ; . .
- Subtask 3 (50 points): ; ; .
Examples
Input
2 6
1 1 5 4
Output
Yes
Explanation
The only intermediate positive lattice point is . It is inside the cleared rectangle, so Belle is visible.
Input
2 6
3 5 5 7
Output
No
1 3
Explanation
The tree at is outside the cleared region and blocks the view. No positive lattice point lies closer on the segment.
Input
6 9
2 3 2 3
Output
No
4 6
Explanation
The intermediate trees are and . Only the first is removed; the second is the closest blocker.
Input
830844890448 39710592053
821266 42860 402207107926 423171345006
Output
No
402207964848 19223704203
Explanation
The gcd is , so consecutive lattice points differ by . The first point is inside the cleared rectangle. Point has x-coordinate , within the right boundary . All these points satisfy the vertical bounds. Point is , beyond the right boundary and before Belle. It is the first blocking tree.