Description
Consider a football tournament where n teams participate. Each team has a football kits:for home games, and a for the away games. The kit for home games of the I-th team have 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 on total). The team, that's plays the home game, traditionally plays in its home kit. The team that plays a away game plays in its away kit. However, if teams has the kits of the same color, they cannot is distinguished. The away team plays in the IT home kit.
Calculate How many games on the described tournament each team plays in their home kit and how many games it plays in its AW AY kit.
Input
The first line contains a integer n (2≤ n ≤105) -the number of teams. Next n lines contain the description of the teams. The i -th line contains II space-separated numbers x i , y Sub class= "Lower-index" > i (1≤ x i , y i ≤105;  x i ≠ y i ) -the color numbers for the Home and Away kits of The I -th team.
Output
For each team, print on a single line, and space-separated integers-the number of games The this team was going to the play in Hom E and Away kits, correspondingly. Print the answers for the teams in the order they appeared in the input.
Sample Input
Input
2
1 2
2 1
Output
2 0
2 0
Input
3
1 2
2 1
1 3
Output
3 1
4 0
2 2
#include <cstdio>#include<cstring>#include<iostream>#include<algorithm>#defineMAXN 100000+100using namespacestd;intZHU[MAXN];intKE[MAXN];intNUMZ[MAXN];intNUMK[MAXN];intMain () {intn,i,j,z,k; while(SCANF ("%d", &n)! =EOF) {memset (Zhu,0,sizeof(Zhu)); memset (Ke,0,sizeof(KE)); for(i=1; i<=n;i++) {scanf ("%d%d",&z,&k); ZHU[Z]++; KE[K]++; Numz[i]=Z; Numk[i]=K; } for(i=1; i<=n;i++) { intzc=n-1+Zhu[numk[i]]; intKc=2* (n1)-Zc; printf ("%d%d\n", ZC,KC); } } return 0;}
View Code
Codeforces 432B Football Kit (water)