#P9685. 三色

    ID: 10608 远端评测题 2000ms 512MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>计算几何洛谷原创O2优化洛谷月赛

三色

Background

My heart is still beating.

Problem Description

You are given nn triples (ai,bi,ci)(a_i,b_i,c_i). There are qq queries. In each query, you are given a set SS. Determine whether there exists a real triple (p,q,r)(p,q,r) such that: for all ii satisfying pai+qbi+r>0pa_i+qb_i+r>0, the set formed by their cic_i is exactly SS.

Input Format

The first line contains an integer TT, which represents the number of test cases.

For each test case, the first line contains three numbers n,q,kn,q,k, where k=Sk=|S|.

The next nn lines each contain three integers ai,bi,cia_i,b_i,c_i.

The next qq lines describe the queries. The ii-th line contains kk integers si,1,si,2,,si,ks_{i,1},s_{i,2},\dots,s_{i,k}, representing the elements of SS in the ii-th query. It is guaranteed that the elements are distinct.

Output Format

For each test case, output a string RR of length qq in one line. For the ii-th query, if the answer is “exists”, then RiR_i is 1\tt 1; otherwise, RiR_i is 0\tt 0.

3
5 2 1
3 0 1
-2 2 2
1 -3 3
-2 -1 4
0 0 5
2
5
5 4 2
3 0 1
-2 2 2
1 -3 3
-2 -1 4
0 0 5
2 3
2 4
5 1
3 5
5 6 3
3 0 1
-2 2 2
1 -3 3
-2 -1 4
0 0 5
3 5 4
2 5 3
4 2 1
2 4 3
3 1 2
3 1 4
10
0110
100101

Hint

Constraints

For all testdata, 1n,n1051\le n,\sum n\le 10^5, 1q,q3×1051\le q,\sum q \le 3\times 10^5, 1k31\le k\le 3, 1ci,si,jn1\le c_i,s_{i,j}\le n, ai,bi109|a_i|,|b_i|\le 10^9.

For any iji\neq j, it is guaranteed that (ai,bi)(aj,bj)(a_i,b_i)\neq (a_j,b_j), and there do not exist (p,q)(p,q) and three different indices i,j,ki,j,k such that pai+qbi=paj+qbj=pak+qbkpa_i+qb_i=pa_j+qb_j=pa_k+qb_k.

Subtasks

# Special Property Points
0 Sample 0
1 n3n\le 3 2
2 k=1k=1 11
3 n2106\sum n^2\le 10^6 23
4 k=2k=2 29
5 k=3k=3 35

Translated by ChatGPT 5