2014 12 12
来源:互联网 发布:15年最流行网络的歌曲 编辑:程序博客网 时间:2024/04/28 13:53
Description
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.
Input
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 thei-th team.
Output
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.
Sample Input
21 22 1
2 02 0
31 22 11 3
3 14 02 2
#include<stdio.h>int main(){int b[100005][2]={0},i,j,n,m=0,a[100005][2],d[100005]={0},c; scanf("%d",&n);while(m<n){scanf("%d%d",&a[m][0],&a[m][1]);c=a[m][0];d[c]++;m++;}for(i=0;i<n;i++) { c=a[i][1];b[i][0]=n-1+d[c];b[i][1]=n-d[c]-1;}for(j=0;j<n;j++)printf("%d %d\n",b[j][0],b[j][1]);}
- 2014 12 12
- 2014-12-12记录
- 2014-08-12 12:45
- 2014-12-31 2014 年记
- 2014/3/12
- 2014-03-12
- 2014-4-12
- 随想-2014-04-12
- 2014-06-12 日志
- 2014-06-12阅读
- 2014-07-12 日志
- 2014-08-12
- 2014/8/12
- 2014-9-12
- 2014/10/12
- 2014-12-04 随笔
- 2014/12/05 随笔
- 2014-12-8
- linux 网络流量监控工具iftop
- hook技术
- 复数
- 杨辉三角函数版
- Linux 常用配置命令
- 2014 12 12
- 命令模式框架 XWork
- JQuery中jqGrid分页实现
- 数据结构 - 图的存储结构表示及其遍历 (DFS && BFS)
- 【Java.Spring.MVC】Spring MVC中的监听器 Listener
- 三层交换原理的理解笔记
- 黑马程序员02
- 自适应分辨率的UI设计规范和制作规范
- pdf转word方法