#SRD0000145. Rào chắn đàn bò (Fencing the Herd)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Rào chắn đàn bò (Fencing the Herd)
Fencing the Herd
Source: USACO
Version: Phuoc Hung OJ Extended
Problem Statement
Farmer John wishes to construct a straight fence that keeps all existing cows strictly on the same side. Initially there are cows, each at a distinct integer-coordinate point . Process events in chronological order:
1 x yadds a cow at .2 A B Cconsiders the line . The fence is valid if every current cow is strictly on the same side (inside the same open half-plane). A cow lying directly on the line invalidates the fence.
All cow coordinates throughout the input are distinct. Evaluate each fence query using the herd that exists at that moment.
Input
- The first line contains .
- The following lines contain the coordinates of the initial cows.
- Each of the next lines starts with an operation type : either
1 x yfor a new cow, or2 A B Cfor a fence query.
Output
For each type 2 event, print YES if all current cows lie strictly on one side, otherwise NO. Type 1 events produce no output.
Subtasks
- Subtask 1 (20 points): ; ; all cow positions distinct; ; ; type
2has . - Subtask 2 (30 points): ; ; all cow positions distinct; ; ; type
2has . - Subtask 3 (50 points): ; ; all cow positions distinct; ; ; type
2has .
Examples
Example 1
Input
3 4
0 0
0 1
1 0
2 2 2 3
1 1 1
2 2 2 3
2 0 1 1
Output
YES
NO
NO
Explanation
Initially equals at the three cow positions, all below : YES. Adding introduces the value , so the same fence is invalid: NO. The final line contains existing cows, so NO.