Codeforces Round #246 (Div. 2):B. Football Kit
来源:互联网 发布:淘宝子账号登陆不了 编辑:程序博客网 时间:2024/06/06 16:31
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 the i-th team has color xi and the kit for away games of this team has color yi (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. Next n lines contain the description of the teams. The i-th line contains two space-separated numbers xi, 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
#include<cstdio>#include<algorithm>#include<iostream>#include<cstring>using namespace std;#define M 100005int x[M];int y[M];int a[M];int b[M];int main(){ int n, i; while(~scanf("%d", &n)) { memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); for(i=0;i<n;i++) { scanf("%d%d",&x[i],&y[i]); a[x[i]]++;b[y[i]]++; } for(i=0;i<n;i++) { printf("%d %d\n",((n-1)+a[y[i]]),((n-1)-a[y[i]])); } } return 0;}
- Codeforces Round #246 (Div. 2) —B. Football Kit
- Codeforces Round #246 (Div. 2) - B. Football Kit
- Codeforces Round #246 (Div. 2) B. Football Kit
- Codeforces Round #246 (Div. 2):B. Football Kit
- Codeforces #246 (Div. 2) B. Football Kit
- Codeforces 432B Football Kit
- Codeforces 432 B. Football Kit
- codeforces-432B Football Kit
- CF 246 B. Football Kit
- Codeforces 432B Football Kit(水题)
- Codeforces Round #281 (Div. 2) A. Vasya and Football
- Codeforces Round #281 (Div. 2) A - Vasya and Football
- B. Football Kit
- Codeforces Round #246 (Div. 2) A,B,C,D
- Codeforces Round #246 (Div. 2)(B)数学
- Codeforces Round #131 (Div. 2) A B
- Codeforces Round #134 (Div. 2)B. Airport
- Codeforces Round #170 (Div. 2) problem B
- Win7服务对照表
- Codeforces Round #246 (Div. 2):A. Choosing Teams
- 風雷益
- 设置启动MyEclipse8.5的时候选择工作空间
- Ubuntu命令行下安装、卸载、管理软件包的方法
- Codeforces Round #246 (Div. 2):B. Football Kit
- 就这样CSDN账号被人盗了??
- zedboard的demo评测
- XAMPP 安装APC模块
- oracle函数概念
- 自绘按钮控件的2个注意点
- Android 性能优化 一 布局优化工具Hierarchy Viewer的使用
- 《JavaScript权威指南》读后感
- oracle-单表查询脚本