CF2195F.Parabola Independence

普及+/提高

通过率:0%

时间限制:3.00s

内存限制:512MB

AC君温馨提醒

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

题目描述

You are given a set of nn quadratic functions F=f1,f2,…,fnF={f_1,f_2,\ldots,f_n }, where fi(x)=aix2+bix+cif_i(x)=a_i x^2 + b_i x + c_i.

Two functions ff and gg are called independent if f(x)≠g(x)f(x) \neq g(x) for all x∈Rx \in \mathbb{R}.

Also, a set of functions G=g1,g2,…,gkG={g_1,g_2,\ldots,g_k} is called organized if the two functions gig_i and gjg_j are independent for all 1≤i<j≤∣G∣1 \le i \lt j \le |G|.

For each i=1,2,…,ni=1,2,\ldots,n, please find the size of the largest organized subset of FF that contains fif_i as an element.

给定一组 nn 个二次函数 F={f1,f2,…,fn}F = \{f_1, f_2, \ldots, f_n\},其中 fi(x)=aix2+bix+cif_i(x) = a_i x^2 + b_i x + c_i。

若对所有 x∈Rx \in \mathbb{R} 均有 f(x)≠g(x)f(x) \neq g(x),则称两个函数 ff 和 gg 是独立的。

此外,若对所有 1≤i<j≤∣G∣1 \le i < j \le |G|,函数 gig_i 与 gjg_j 均独立,则称函数集合 G={g1,g2,…,gk}G = \{g_1, g_2, \ldots, g_k\} 是有序的(organized)。

对每个 i=1,2,…,ni = 1, 2, \ldots, n,请找出包含 fif_i 的 FF 的最大有序子集的大小。

输入格式

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 a single integer nn (1≤n≤30001 \le n \le 3000).

Each of the nn following lines contains three integers aia_i, bib_i, cic_i denoting the function fif_i (−106≤ai,bi,ci≤106-10^6 \le a_i, b_i, c_i \le 10^6, ai≠0a_i \neq 0).

It is guaranteed that the functions in one test case are pairwise distinct.

It is guaranteed that the sum of n2n^2 over all test cases does not exceed 300023000^2.

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

每个测试用例的第一行包含一个整数 nn(1≤n≤30001 \le n \le 3000)。

接下来的 nn 行中,每行包含三个整数 aia_i、bib_i、cic_i,表示函数 fif_i(其中 −106≤ai,bi,ci≤106-10^6 \le a_i, b_i, c_i \le 10^6,且 ai≠0a_i \neq 0)。

保证同一测试用例中的所有函数两两不同。

保证所有测试用例的 n2n^2 之和不超过 300023000^2。

输出格式

For each test case, output nn integers s1,s2,…,sns_1,s_2,\ldots,s_n, where sis_i is the size of the largest organized subset that contains fif_i.

对于每个测试用例,输出 nn 个整数 s1,s2,…,sns_1,s_2,\ldots,s_n,其中 sis_i 是包含 fif_i 的最大有序子集的大小。

输入输出样例

  • 输入#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−1f_1(x)=x^2+2x-1;
  • f2(x)=−3x2−3f_2(x)=-3x^2-3;
  • f3(x)=−x2+4x−5f_3(x)=-x^2+4x-5;
  • f4(x)=x2+2x−4f_4(x)=x^2+2x-4.

The functions' graphs are as shown below:

The largest organized subsets of FF containing each function are as follows:

  • f1,f3,f4{f_1,f_3,f_4} is the largest organized subset that contains f1f_1;
  • f1,f2{f_1,f_2} is the largest organized subset that contains f2f_2;
  • f1,f3,f4{f_1,f_3,f_4} is the largest organized subset that contains f3f_3;
  • f1,f3,f4{f_1,f_3,f_4} is the largest organized subset that contains f4f_4.

在第一个测试用例中,函数如下:

  • f1(x)=x2+2x−1f_1(x)=x^2+2x-1;
  • f2(x)=−3x2−3f_2(x)=-3x^2-3;
  • f3(x)=−x2+4x−5f_3(x)=-x^2+4x-5;
  • f4(x)=x2+2x−4f_4(x)=x^2+2x-4。

这些函数的图像如下所示:

包含每个函数的 FF 的最大有序子集如下:

  • {f1,f3,f4}\{f_1,f_3,f_4\} 是包含 f1f_1 的最大有序子集;
  • {f1,f2}\{f_1,f_2\} 是包含 f2f_2 的最大有序子集;
  • {f1,f3,f4}\{f_1,f_3,f_4\} 是包含 f3f_3 的最大有序子集;
  • {f1,f3,f4}\{f_1,f_3,f_4\} 是包含 f4f_4 的最大有序子集。

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

首页