#abc157d. D - Friend Suggestions
D - Friend Suggestions
Score : points
问题描述
一个社交网络服务(SNS)拥有 名用户——用户 、用户 、、用户 。
在这 名用户之间,存在一些关系——共有 条 双向好友关系 和 条 双向屏蔽关系。
对于每一条 的好友关系,用户 和用户 之间存在一条双向好友关系。
对于每一条 的屏蔽关系,用户 和用户 之间存在一条双向屏蔽关系。
我们定义用户 是用户 的 好友候选人 ,当满足以下四个条件时:
- 。
- 用户 和用户 之间不存在好友关系。
- 用户 和用户 之间不存在屏蔽关系。
- 存在由 到 (包含)之间的整数组成的序列 ,使得 、,且对于每个 ,用户 和 之间存在好友关系。
对于每个用户 ,它有多少个好友候选人?
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
An SNS has users - User , User , , User .
Between these users, there are some relationships - friendships and blockships.
For each , there is a bidirectional friendship between User and User .
For each , there is a bidirectional blockship between User and User .
We define User to be a friend candidate for User when all of the following four conditions are satisfied:
- .
- There is not a friendship between User and User .
- There is not a blockship between User and User .
- There exists a sequence consisting of integers between and (inclusive) such that , , and there is a friendship between User and for each .
For each user , how many friend candidates does it have?
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answers in order, with space in between.
Sample Input 1
4 4 1
2 1
1 3
3 2
3 4
4 1
Sample Output 1
0 1 0 1
There is a friendship between User and , and between and . Also, there is no friendship or blockship between User and . Thus, User is a friend candidate for User .
However, neither User or is a friend candidate for User , so User has one friend candidate.
Sample Input 2
5 10 0
1 2
1 3
1 4
1 5
3 2
2 4
2 5
4 3
5 3
4 5
Sample Output 2
0 0 0 0 0
Everyone is a friend of everyone else and has no friend candidate.
Sample Input 3
10 9 3
10 1
6 7
8 2
2 5
8 4
7 3
10 9
6 4
5 8
2 6
7 5
3 1
Sample Output 3
1 3 5 4 3 3 3 3 1 0
update @ 2024/3/10 17:14:48