CF2195F.Parabola Independence
普及+/提高
通过率:0%
时间限制:3.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given a set of n quadratic functions F=f1,f2,…,fn, where fi(x)=aix2+bix+ci.
Two functions f and g are called independent if f(x)=g(x) for all x∈R.
Also, a set of functions G=g1,g2,…,gk is called organized if the two functions gi and gj are independent for all 1≤i<j≤∣G∣.
For each i=1,2,…,n, please find the size of the largest organized subset of F that contains fi as an element.
给定一组 n 个二次函数 F={f1,f2,…,fn},其中 fi(x)=aix2+bix+ci。
若对所有 x∈R 均有 f(x)=g(x),则称两个函数 f 和 g 是独立的。
此外,若对所有 1≤i<j≤∣G∣,函数 gi 与 gj 均独立,则称函数集合 G={g1,g2,…,gk} 是有序的(organized)。
对每个 i=1,2,…,n,请找出包含 fi 的 F 的最大有序子集的大小。
输入格式
Each test contains multiple test cases. The first line contains the number of test cases t (1≤t≤104). The description of the test cases follows.
The first line of each test case contains a single integer n (1≤n≤3000).
Each of the n following lines contains three integers ai, bi, ci denoting the function fi (−106≤ai,bi,ci≤106, ai=0).
It is guaranteed that the functions in one test case are pairwise distinct.
It is guaranteed that the sum of n2 over all test cases does not exceed 30002.
每个测试包含多个测试用例。第一行包含测试用例的数量 t(1≤t≤104)。随后是各测试用例的描述。
每个测试用例的第一行包含一个整数 n(1≤n≤3000)。
接下来的 n 行中,每行包含三个整数 ai、bi、ci,表示函数 fi(其中 −106≤ai,bi,ci≤106,且 ai=0)。
保证同一测试用例中的所有函数两两不同。
保证所有测试用例的 n2 之和不超过 30002。
输出格式
For each test case, output n integers s1,s2,…,sn, where si is the size of the largest organized subset that contains fi.
对于每个测试用例,输出 n 个整数 s1,s2,…,sn,其中 si 是包含 fi 的最大有序子集的大小。
输入输出样例
输入#1
3 4 1 2 -1 -3 0 -3 -1 4 -5 1 2 -4 5 3 0 0 1 0 -5 -3 0 0 -1 0 10 1 0 -10 5 884 -667 497 680 -973 213 23 -548 -412 826 359 -333 773 212 218
输出#1
3 2 3 3 3 3 2 2 3 3 3 3 1 2
说明/提示
In the first test case, the functions are as follows:
- f1(x)=x2+2x−1;
- f2(x)=−3x2−3;
- f3(x)=−x2+4x−5;
- f4(x)=x2+2x−4.
The functions' graphs are as shown below:

The largest organized subsets of F containing each function are as follows:
- f1,f3,f4 is the largest organized subset that contains f1;
- f1,f2 is the largest organized subset that contains f2;
- f1,f3,f4 is the largest organized subset that contains f3;
- f1,f3,f4 is the largest organized subset that contains f4.
在第一个测试用例中,函数如下:
- f1(x)=x2+2x−1;
- f2(x)=−3x2−3;
- f3(x)=−x2+4x−5;
- f4(x)=x2+2x−4。
这些函数的图像如下所示:

包含每个函数的 F 的最大有序子集如下:
- {f1,f3,f4} 是包含 f1 的最大有序子集;
- {f1,f2} 是包含 f2 的最大有序子集;
- {f1,f3,f4} 是包含 f3 的最大有序子集;
- {f1,f3,f4} 是包含 f4 的最大有序子集。
输入解题思路,AI测评打分。不知道怎么写?