#P9685. Real Number Triple Query
Real Number Triple Query
Real Number Triple Query
We are given n triples \((a_i, b_i, c_i)\). There are q queries. In each query a set \(S\) is provided. The task is to determine whether there exists a real triple \((p,q,r)\) such that the following holds:
For every index \(i\) satisfying \[ p\,a_i+q\,b_i+r>0, \] the set of the corresponding \(c_i\)'s is exactly \(S\). Equivalently, if we define \[ Pos=\{i\mid c_i\in S\}\quad and \quad Neg=\{i\mid c_i\notin S\}, \] we require that there exists \((p,q,r)\in\mathbb{R}^3\) such that \[ \begin{aligned} &p\,a_i+q\,b_i+r>0, \quad \forall\, i\in Pos,\\ &p\,a_i+q\,b_i+r\le0, \quad \forall\, i\in Neg. \end{aligned} \]
You may assume that n is small (for example \(n\le10\)); hence a brute-force search over candidate separating directions is acceptable.
inputFormat
The first line contains an integer \(n\) (\(1\le n\le 10\)), the number of triples. Each of the next \(n\) lines contains three numbers \(a_i\), \(b_i\) and \(c_i\).
The next line contains an integer \(q\) denoting the number of queries. Then for each query, there is one line which starts with an integer \(k\) (the size of the set \(S\)), followed by \(k\) numbers representing the elements of \(S\).
outputFormat
For each query, output a line containing Yes if there exists a real triple \((p,q,r)\) satisfying the conditions, otherwise output No.
sample
3
1 2 10
-1 0 5
0 -1 7
1
2 10 5
Yes