#DSU0000020. Mạng không dây (Wireless Network)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Mạng không dây (Wireless Network)
Wireless Network
Source: POJ
Version: Phuoc Hung OJ Extended
Problem Statement
There are computers, all initially broken, at fixed points in the plane. Two repaired computers can communicate directly if their Euclidean distance is at most . They may also communicate through other repaired computers.
Process operations that repair a computer or check whether two computers can communicate.
Input
The first line contains two integers . Each of the next lines contains two integers , the coordinates of computer (numbered from ). The next line contains an integer , the number of operations. Each of the following lines is one of:
O p: repair computer .S a b: ask whether computers and can communicate.
Output
For each S operation, print SUCCESS if both computers are repaired and can communicate, and FAIL otherwise, one answer per line.
Subtasks
- Subtask 1 (20 points): ; ; ; ; .
- Subtask 2 (30 points): ; ; ; ; .
- Subtask 3 (50 points): ; ; ; ; .
Examples
Input
4 1
0 1
0 2
0 3
0 4
6
O 1
O 2
O 4
S 1 4
O 3
S 1 4
Output
FAIL
SUCCESS
Explanation
After repairing 1,2,4, computer 4 cannot reach 1, so print FAIL. Repairing 3 connects the chain 1–2–3–4, giving SUCCESS.