AT_abc462_b.Gift

入门

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

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

题目描述

NN people, numbered 11 through NN, exchanged gifts with each other.

Person ii sent gifts to KiK_i people: persons Ai,1,Ai,2,…,Ai,KiA_{i,1}, A_{i,2}, \ldots, A_{i,K_i}.

For each i=1,2,…,Ni = 1, 2, \ldots, N, find all people who sent a gift to person ii.

NN 个人,编号为 11 至 NN,彼此之间互赠礼物。

第 ii 个人向 KiK_i 个人赠送了礼物:即第 Ai,1,Ai,2,…,Ai,KiA_{i,1}, A_{i,2}, \ldots, A_{i,K_i} 个人。

对每个 i=1,2,…,Ni = 1, 2, \ldots, N,找出所有向第 ii 个人赠送礼物的人。

输入格式

The input is given from Standard Input in the following format:

NN
K1K_1 A1,1A_{1,1} A1,2A_{1,2} …\ldots A1,K1A_{1,K_1}
K2K_2 A2,1A_{2,1} A2,2A_{2,2} …\ldots A2,K2A_{2,K_2}
⋮\vdots
KNK_N AN,1A_{N,1} AN,2A_{N,2} …\ldots AN,KNA_{N,K_N}

输入从标准输入中按以下格式给出:

NN
K1K_1 A1,1A_{1,1} A1,2A_{1,2} …\ldots A1,K1A_{1,K_1}
K2K_2 A2,1A_{2,1} A2,2A_{2,2} …\ldots A2,K2A_{2,K_2}
⋮\vdots
KNK_N AN,1A_{N,1} AN,2A_{N,2} …\ldots AN,KNA_{N,K_N}

输出格式

Output NN lines.

For the ii-th line, let B1,B2,…,BXB_1, B_2, \ldots, B_X be the numbers of the people who sent a gift to person ii, listed in ascending order (where XX is the count of people who sent a gift to person ii), and output in the following format:

XX B1B_1 B2B_2 …\ldots BXB_X

输出 NN 行。

对于第 ii 行,设 B1,B2,…,BXB_1, B_2, \ldots, B_X 为向第 ii 个人赠送礼物的所有人的编号(按升序排列),其中 XX 表示向第 ii 个人赠送礼物的人数。请按如下格式输出:

XX B1B_1 B2B_2 …\ldots BXB_X

输入输出样例

  • 输入#1

    4
    1 2
    1 3
    1 2
    3 1 2 3

    输出#1

    1 4
    3 1 3 4
    2 2 4
    0
  • 输入#2

    4
    3 2 3 4
    2 1 4
    2 1 2
    2 2 3

    输出#2

    2 2 3
    3 1 3 4
    2 1 4
    2 1 2
  • 输入#3

    7
    1 3
    4 3 4 6 7
    1 7
    3 2 6 7
    2 3 7
    1 4
    1 5

    输出#3

    0
    1 4
    3 1 2 5
    2 2 6
    1 7
    2 2 4
    4 2 3 4 5

说明/提示

Sample 1 Explanation:
Person 11 sent a gift to person 22, person 22 sent a gift to person 33, person 33 sent a gift to person 22, and person 44 sent gifts to persons 1,2,31, 2, 3.

Person 11 received a gift from person 44. Thus, output 1 4 on the first line.

Person 22 received gifts from persons 1,3,41, 3, 4. Thus, output 3 1 3 4 on the second line.

Person 33 received gifts from persons 2,42, 4. Thus, output 2 2 4 on the third line.

Person 44 did not receive any gifts. Thus, output 0 on the fourth line.

Constraints

  • 2≤N≤1002\le N\le 100
  • 1≤Ki≤N−11\le K_i\le N-1
  • 1≤Ai,1<Ai,2<⋯<Ai,Ki≤N1\le A_{i,1} < A_{i,2} < \cdots < A_{i,K_i}\le N
  • Ai,j≠iA_{i,j} \neq i
  • All input values are integers.

样例 1 解释:
第 1 个人送给第 2 个人礼物,第 2 个人送给第 3 个人礼物,第 3 个人送给第 2 个人礼物,第 4 个人送给第 1、2、3 个人礼物。

第 1 个人收到了第 4 个人送的礼物。因此,第一行输出 1 4。

第 2 个人收到了第 1、3、4 个人送的礼物。因此,第二行输出 3 1 3 4。

第 3 个人收到了第 2、4 个人送的礼物。因此,第三行输出 2 2 4。

第 4 个人未收到任何礼物。因此,第四行输出 0。

约束条件

  • 2≤N≤1002\le N\le 100
  • 1≤Ki≤N−11\le K_i\le N-1
  • 1≤Ai,1<Ai,2<⋯<Ai,Ki≤N1\le A_{i,1} < A_{i,2} < \cdots < A_{i,K_i}\le N
  • Ai,j≠iA_{i,j} \neq i
  • 所有输入值均为整数。

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

首页