欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1609D.Social Network
Social Network
CF1609D · Social Network
- 难度:1600
- 标签:dsu、graphs、greedy、implementation、trees
- 链接:https://codeforces.com/problemset/problem/1609/D
- 时间限制:2 seconds 内存限制:256 megabytes
- 出现位置:Day14-阶段模拟2-图论DSU卷
英文原题面
Statement
William arrived at a conference dedicated to cryptocurrencies. Networking, meeting new people, and using friends' connections are essential to stay up to date with the latest news from the world of cryptocurrencies. The conference has participants, who are initially unfamiliar with each other. William can introduce any two people, and , who were not familiar before, to each other. William has conditions, 'th of which requires person to have a connection to person . Formally, two people and have a connection if there is such a chain for which for all from to it's true that two people with numbers and know each other. For every () William wants you to calculate the maximal number of acquaintances one person can have, assuming that William satisfied all conditions from and up to and including and performed exactly introductions. The conditions are being checked after William performed introductions. The answer for each must be calculated independently. It means that when you compute an answer for , you should assume that no two people have been introduced to each other yet.
Input
The first line contains two integers and (), the number of people, and number of conditions, respectively. Each of the next lines each contain two integers and (), the numbers of people which must have a connection according to condition .
Output
Output integers. th number must equal the number of acquaintances the person with the maximal possible acquaintances will have, if William performed introductions and satisfied the first conditions.
样例
样例 1
输入:
7 6
1 2
3 4
2 4
7 6
6 5
1 7
输出:
1
1
3
3
3
6
样例 2
输入:
10 8
1 2
2 3
3 4
1 4
6 7
8 9
8 10
1 4
输出:
1
2
3
4
5
5
6
8
样例解释(英文原文)
The explanation for the first test case: In this explanation, the circles and the numbers in them denote a person with the corresponding number. The line denotes that William introduced two connected people. The person marked with red has the most acquaintances. These are not the only correct ways to introduce people.
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |