CF1805C.Place for a Selfie

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

The universe is a coordinate plane. There are nn space highways, each of which is a straight line y=kxy=kx passing through the origin (0,0)(0, 0). Also, there are mm asteroid belts on the plane, which we represent as open upwards parabolas, i. e. graphs of functions y=ax2+bx+cy=ax^2+bx+c, where a>0a \gt 0.

You want to photograph each parabola. To do this, for each parabola you need to choose a line that does not intersect this parabola and does not touch it. You can select the same line for different parabolas. Please find such a line for each parabola, or determine that there is no such line.

宇宙是一个坐标平面。平面上有 nn 条太空高速公路,每条都是一条过原点 (0,0)(0, 0) 的直线 y=kxy=kx。此外,平面上还有 mm 条小行星带,我们将其表示为开口向上的抛物线,即函数 y=ax2+bx+cy=ax^2+bx+c 的图像,其中 a>0a \gt 0。

你需要为每条抛物线拍摄一张照片。为此,对每条抛物线,你都需要选择一条既不与该抛物线相交、也不与该抛物线相切的直线。不同抛物线可以选用同一条直线。请为每条抛物线找出这样的一条直线,或判定不存在这样的直线。

输入格式

Each test contains multiple test cases. The first line contains the number of test cases tt (1≤t≤1041 \le t \le 10^4). The description of the test cases follows.

The first line of each test case contains 22 integers nn and mm (1≤n,m≤1051 \le n, m \le 10^5) —the number of lines and parabolas, respectively.

Each of the next nn lines contains one integer kk (∣k∣≤108|k| \le 10^8), denoting a line that is described with the equation y=kxy=kx. The lines are not necessarily distinct, kk can be equal to 00.

Each of the next mm lines contains 33 integers aa, bb, and cc (a,∣b∣,∣c∣≤108a, |b|, |c| \le 10^8, a>0a \gt 0) — coefficients of equations of the parabolas ax2+bx+cax^2+bx+c. The parabolas are not necessarily distinct.

It is guaranteed that the sum nn over all test cases does not exceed 10510^5, and the sum mm over all test cases also does not exceed 10510^5.

每个测试包含多个测试用例。第一行包含测试用例数量 tt(1≤t≤1041 \le t \le 10^4)。随后是各测试用例的描述。

每个测试用例的第一行包含两个整数 nn 和 mm(1≤n,m≤1051 \le n, m \le 10^5),分别表示直线的数量和抛物线的数量。

接下来的 nn 行中,每行包含一个整数 kk(∣k∣≤108|k| \le 10^8),表示一条由方程 y=kxy=kx 描述的直线。这些直线不一定互不相同,且 kk 可以为 00。

再接下来的 mm 行中,每行包含三个整数 aa、bb 和 cc(a,∣b∣,∣c∣≤108a, |b|, |c| \le 10^8,且 a>0a \gt 0),表示抛物线 ax2+bx+cax^2+bx+c 的系数。这些抛物线不一定互不相同。

保证所有测试用例中 nn 的总和不超过 10510^5,且所有测试用例中 mm 的总和也不超过 10510^5。

输出格式

For each test case, output the answers for each parabola in the given order. If there is a line that does not intersect the given parabola and doesn't touch it, print on a separate line the word "YES", and then on a separate line the number kk — the coefficient of this line. If there are several answers, print any of them. If the line does not exist, print one word "NO".

You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

The empty lines in the output in the example are given only for illustration, you do not need to output them (but you can).

对于每个测试用例,按给定顺序输出每条抛物线对应的答案。如果存在一条直线既不与给定抛物线相交,也不与之相切,则在单独一行输出单词 “YES”,然后在下一行输出该直线的系数 kk。若存在多个满足条件的答案,输出任意一个即可。若这样的直线不存在,则仅输出单词 “NO”。

你可以以任意大小写形式输出答案(大写或小写均可)。例如,字符串 “yEs”、“yes”、“Yes” 和 “YES” 均会被识别为肯定回答。

示例输出中的空行仅为示意之用,你无需输出它们(但也可以输出)。

输入输出样例

  • 输入#1

    5
    1 2
    1
    1 -1 2
    1 -1 3
    2 2
    1
    4
    1 2 1
    2 5 1
    1 1
    0
    1 0 0
    1 1
    100000000
    100000000 100000000 100000000
    2 3
    0
    2
    2 2 1
    1 -2 1
    1 -2 -1

    输出#1

    YES
    1
    YES
    1
    
    YES
    1
    YES
    4
    
    NO
    
    YES
    100000000
    
    YES
    0
    NO
    NO

说明/提示

In the first test case, both parabolas do not intersect the only given line y=1⋅xy=1\cdot x, so the answer is two numbers 11.

In the second test case, the line y=xy=x and the parabola 2x2+5x+12x^2+5x+1 intersect, and also the line y=4xy=4x and the parabola x2+2x+1x^2+2x+1 touch, so these pairs do not satisfy the condition. So for the first parabola, the answer is 11 (y=1xy=1x), and for the second parabola — 44.

In the third test set, the line and the parabola intersect, so the answer is "NO".

在第一个测试用例中,两条抛物线均不与给定的唯一直线 y=1⋅xy=1\cdot x 相交,因此答案是两个数字 11。

在第二个测试用例中,直线 y=xy=x 与抛物线 2x2+5x+12x^2+5x+1 相交,且直线 y=4xy=4x 与抛物线 x2+2x+1x^2+2x+1 相切,因此这两对均不满足条件。故对于第一条抛物线,答案为 11(即直线 y=1xy=1x),而对于第二条抛物线,答案为 44。

在第三个测试用例中,直线与抛物线相交,因此答案为 “NO”。

输入解题思路,AI测评打分。不知道怎么写?

首页