题目描述
Read problems statements in [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well.
Chef is stuck in the wavey world of polynomials. You are given all $N$ roots of a polynomial $P(x) = \prod_{i=1}^N (x - a_{i})$. The roots are pairwise distinct integers, but they are not given in any particular order.
To help Chef escape, you should answer $Q$ queries (numbered $1$ through $Q$). For each valid $i$, in the $i$-th query, you are given an integer $x_{i}$ and you have to determine whether $P(x_{i})$ is positive, negative or $0$.
------ Input ------
The first line of the input contains two space-separated integers $N$ and $Q$.
The second line contains $N$ space-separated integers $a_{1}, a_{2}, \ldots, a_{N}$.
$Q$ lines follow. For each valid $i$, the $i$-th of these lines contains a single integer $x_{i}$ describing the $i$-th query.
------ Output ------
For each query, print a single line containing the string "POSITIVE", "NEGATIVE" or "0" (without quotes) describing the value of the polynomial for the $i$-th query.
------ Constraints ------
$1 ≤ N, Q ≤ 2 \cdot 10^{5}$
$|a_{i}| ≤ 10^{9}$ for each valid $i$
$a_{1}, a_{2}, \ldots, a_{N}$ are pairwise distinct
$|x_{i}| ≤ 10^{9}$ for each valid $i$
----- Sample Input 1 ------
4 6
1 3 5 100
-2
2
4
80
107
5
----- Sample Output 1 ------
POSITIVE
NEGATIVE
POSITIVE
NEGATIVE
POSITIVE
0
----- explanation 1 ------
The given polynomial is $(x-1)\cdot (x-3)\cdot (x-5)\cdot (x-100)$.
Query $1$: $x = -2$. This means that $P(-2) = (-2-1)\cdot (-2-3)\cdot (-2-5)\cdot (-2-100) = (-3)\cdot (-5)\cdot (-7)\cdot (-102) = 10710 > 0$. Thus, the answer is POSITIVE.
Query $2$: $x = 2$. This means that $P(2) = (2-1)\cdot (2-3)\cdot (2-5)\cdot (2-100) = (1)\cdot (-1)\cdot (-3)\cdot (-98) = -294 < 0$. Thus, the answer is NEGATIVE.
Query $3$: $x = 4$. This means that $P(4) = (4-1)\cdot (4-3)\cdot (4-5)\cdot (4-100) = (3)\cdot (1)\cdot (-1)\cdot (-96) = 288 > 0$. Thus, the answer is POSITIVE.
Query $6$: $x = 5$. This means that $P(5) = (5-1)\cdot (5-3)\cdot (5-5)\cdot (5-100) = (4)\cdot (2)\cdot (0)\cdot (-95) = 0$. Thus, the answer is 0.
输入格式
见题面
输出格式
见题面