2014 12 12

来源:互联网 发布:15年最流行网络的歌曲 编辑:程序博客网 时间:2024/04/28 13:53
E - Football Kit
Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u
Submit Status

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 xiyi(1 ≤ xi, yi ≤ 105xi ≠ 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

Input
21 22 1
Output
2 02 0
Input
31 22 11 3
Output
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]);}
0 0
原创粉丝点击