CF958D2.Hyperspace Jump (hard)

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

It is now 125 years later, but humanity is still on the run from a humanoid-cyborg race determined to destroy it. Or perhaps we are getting some stories mixed up here... In any case, the fleet is now smaller. However, in a recent upgrade, all the navigation systems have been outfitted with higher-dimensional, linear-algebraic jump processors.

Now, in order to make a jump, a ship's captain needs to specify a subspace of the dd -dimensional space in which the events are taking place. She does so by providing a generating set of vectors for that subspace.

Princess Heidi has received such a set from the captain of each of mm ships. Again, she would like to group up those ships whose hyperspace jump subspaces are equal. To do so, she wants to assign a group number between 11 and mm to each of the ships, so that two ships have the same group number if and only if their corresponding subspaces are equal (even though they might be given using different sets of vectors).

Help Heidi!

输入格式

The first line of the input contains two space-separated integers mm and dd ( 2<=m<=300002<=m<=30000 , 1<=d<=51<=d<=5 ) – the number of ships and the dimension of the full underlying vector space, respectively. Next, the mm subspaces are described, one after another. The ii -th subspace, which corresponds to the ii -th ship, is described as follows:

The first line contains one integer kik_{i} ( 1<=ki<=d1<=k_{i}<=d ). Then kik_{i} lines follow, the jj -th of them describing the jj -th vector sent by the ii -th ship. Each of the jj lines consists of dd space-separated integers aja_{j} , j=1,...,dj=1,...,d , that describe the vector ; it holds that aj<=250|a_{j}|<=250 . The ii -th subspace is the linear span of these kik_{i} vectors.

输出格式

Output mm space-separated integers g1,...,gmg_{1},...,g_{m} , where denotes the group number assigned to the ii -th ship. That is, for any 1<=i<j<=m1<=i<j<=m , the following should hold: gi=gjg_{i}=g_{j} if and only if the ii -th and the jj -th subspaces are equal. In addition, the sequence (g1,g2,...,gm)(g_{1},g_{2},...,g_{m}) should be lexicographically minimal among all sequences with that property.

输入输出样例

  • 输入#1

    8 2
    1
    5 0
    1
    0 1
    1
    0 1
    2
    0 6
    0 1
    2
    0 1
    1 0
    2
    -5 -5
    4 3
    2
    1 1
    0 1
    2
    1 0
    1 0
    

    输出#1

    1 2 2 2 3 3 3 1 

说明/提示

In the sample testcase, the first and the last subspace are equal, subspaces 2 to 4 are equal, and subspaces 5 to 7 are equal.

Recall that two subspaces, one given as the span of vectors and another given as the span of vectors , are equal if each vector viv_{i} can be written as a linear combination of vectors w1,...,wkw_{1},...,w_{k} (that is, there exist coefficients such that vi=α1w1+...+αkwkv_{i}=α_{1}w_{1}+...+α_{k}w_{k} ) and, similarly, each vector wiw_{i} can be written as a linear combination of vectors v1,...,vnv_{1},...,v_{n} .

Recall that a sequence (g1,g2,...,gm)(g_{1},g_{2},...,g_{m}) is lexicographically smaller than a sequence (h1,h2,...,hm)(h_{1},h_{2},...,h_{m}) if there exists an index ii , 1<=i<=m1<=i<=m , such that gi<hig_{i}<h_{i} and gj=hjg_{j}=h_{j} for all j<ij<i .

首页