编程介的小学生 2020-01-12 14:27 采纳率: 20.5%
浏览 83

Defense of the Ancients

Problem Description
DotA? I’m afraid you’ve got a wrong impression, because we are talking about some real Ancients.
A lot of towers are in the first quadrant of rectangular coordinates. And between every two towers there is a wall. All of them are Ancients. Somehow, some skytroopers are trying to attack our Ancients and all we know is that they’ll land at the second, third and fourth quadrant of rectangular coordinates. Because those areas are desolation, the troops decided to follow a fixed straight line. Now we’ve got all the landing coordinates of the troops and the polar angle of their walking lines. To protect our Ancients, we need to know where the troops will first arrive at the Ancients.

Input
There are multiple test cases.
First line contains a single integer T (T<=10), indicates the number of test cases.
For each test case:
The first line has two positive integers N and M (1<N<=100000, M<=100000), represent the number of towers and skytroopers.
Following N lines, each line contains two integers X and Y, represents the coordinate of the tower.
Following M lines, each line has three integers SX, SY and XITA, indicates the coordinates of a skytrooper and the polar angle of their attacking line (in degrees). SX and SY will not bigger than 0 at the same time.
All the coordinates values lies in [-20000, 20000]. No two towers will be in same place.

Output
For every skytrooper, output one line, if the trooper can reach the Ancients, output the coordinate he will first arrive, otherwise output “safe”.
If the value differs in 0.01 with our standard output, we’ll consider it as accepted.

Sample Input
1
6 3
5 1
8 5
13 2
14 7
7 9
1 7
-2 -2 45
8 -2 90
-3 7 120

Sample Output
3.400000 3.400000
8.000000 1.375000
safe

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 微信会员卡接入微信支付商户号收款
    • ¥15 如何获取烟草零售终端数据
    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?