AT_abc462_b.Gift
入门
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
N people, numbered 1 through N, exchanged gifts with each other.
Person i sent gifts to Ki people: persons Ai,1,Ai,2,…,Ai,Ki.
For each i=1,2,…,N, find all people who sent a gift to person i.
N 个人,编号为 1 至 N,彼此之间互赠礼物。
第 i 个人向 Ki 个人赠送了礼物:即第 Ai,1,Ai,2,…,Ai,Ki 个人。
对每个 i=1,2,…,N,找出所有向第 i 个人赠送礼物的人。
输入格式
The input is given from Standard Input in the following format:
N
K1 A1,1 A1,2 … A1,K1
K2 A2,1 A2,2 … A2,K2
⋮
KN AN,1 AN,2 … AN,KN
输入从标准输入中按以下格式给出:
N
K1 A1,1 A1,2 … A1,K1
K2 A2,1 A2,2 … A2,K2
⋮
KN AN,1 AN,2 … AN,KN
输出格式
Output N lines.
For the i-th line, let B1,B2,…,BX be the numbers of the people who sent a gift to person i, listed in ascending order (where X is the count of people who sent a gift to person i), and output in the following format:
X B1 B2 … BX
输出 N 行。
对于第 i 行,设 B1,B2,…,BX 为向第 i 个人赠送礼物的所有人的编号(按升序排列),其中 X 表示向第 i 个人赠送礼物的人数。请按如下格式输出:
X B1 B2 … BX
输入输出样例
输入#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 1 sent a gift to person 2, person 2 sent a gift to person 3, person 3 sent a gift to person 2, and person 4 sent gifts to persons 1,2,3.
Person 1 received a gift from person 4. Thus, output 1 4 on the first line.
Person 2 received gifts from persons 1,3,4. Thus, output 3 1 3 4 on the second line.
Person 3 received gifts from persons 2,4. Thus, output 2 2 4 on the third line.
Person 4 did not receive any gifts. Thus, output 0 on the fourth line.
Constraints
- 2≤N≤100
- 1≤Ki≤N−1
- 1≤Ai,1<Ai,2<⋯<Ai,Ki≤N
- Ai,j=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≤100
- 1≤Ki≤N−1
- 1≤Ai,1<Ai,2<⋯<Ai,Ki≤N
- Ai,j=i
- 所有输入值均为整数。
输入解题思路,AI测评打分。不知道怎么写?