Codeforces 432B Football Kit (water)

Source: Internet
Author: User

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(xiyi ).

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.