CODEFORCE 246 Div.2 B题
来源:互联网 发布:手机网络哪家好 编辑:程序博客网 时间:2024/05/22 03:50
题目如下:
Consider a football tournament where n teams participate. Each team has two football kits: for home games, and for away games. The kit for home games of thei-th team has color xi and the kit for away games of this team has coloryi(xi ≠ yi).
In the tournament, each team plays exactly one home game and exactly one away game with each other team (n(n - 1) games in total). The team, that plays the home game, traditionally plays in its home kit. The team that plays an away game plays in its away kit. However, if two teams has the kits of the same color, they cannot be distinguished. In this case the away team plays in its home kit.
Calculate how many games in the described tournament each team plays in its home kit and how many games it plays in its away kit.
The first line contains a single integer n(2 ≤ n ≤ 105) — the number of teams. Nextn lines contain the description of the teams. Thei-th line contains two space-separated numbersxi,yi(1 ≤ xi, yi ≤ 105; xi ≠ yi) — the color numbers for the home and away kits of the i-th team.
For each team, print on a single line two space-separated integers — the number of games this team is going to play in home and away kits, correspondingly. Print the answers for the teams in the order they appeared in the input.
21 22 1
2 02 0
31 22 11 3
3 14 02 2
刚开始用双重循环查找超时了,最后改为二分查找AC。
代码如下:
- CODEFORCE 246 Div.2 B题
- codeforce 247 div.2 B
- Codeforce 214 Div 2 B.Hometask
- codeforce round 247 div.2 B
- CodeForce #319 div 2 B Modulo sum
- Codeforce Round #422(Div 2) B
- 【CodeForce】Codeforces Round #140 (Div. 2) A B C
- 【CodeForce】Codeforces Round #141 (Div. 2) B. Two Tables
- 【CodeForce】Codeforces Round #142 (Div. 2) A B C
- Codeforce Round#350(Div. 2) 670B Game of Robots
- codeforce 157 div 2
- codeforce 172 Div.2
- codeforce#262(div.2)
- codeforce 2B
- Codeforce Round #382(Div 1) B
- Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) B(模拟) && codeforce 724B Batch Sort
- codeforce 176#div.2 C
- CodeForce Round #186 Div.2
- U盘数据突然不显示怎么恢复
- CSDN换头像的方法
- android的binder机制研究
- 在Eclipse中运行、配置Hadoop
- mprotect设置内存访问权限
- CODEFORCE 246 Div.2 B题
- IE浏览器打开网页提示安全证书过期或证书错误的解决方法
- PAT A 1039. Course List for Student (25)
- MySQL数据库的用户管理相关配置
- Java打成可执行jar过程中需要注意的一些问题
- 访问控制符
- 人一旦选择活下去,就必须为了生活起早贪黑,四处奔波
- opencv下haarclassifiercascade加上LBPHFaceRecognizer实现人脸识别
- 稀疏矩阵的转置