Football Kit

Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

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 the i-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
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 <stdio.h>
#include <string.h>
#include <map>
using namespace std;
map <int,int> s;
int main()
{
int n;
int i,j,x[],y[],nn[];
while(scanf("%d",&n)!=EOF)
{
s.clear();
for(i=;i<=n;i++)
{
scanf("%d %d",&x[i],&y[i]);
s[x[i]]++;
nn[i]=n-;
} for(i=;i<=n;i++)
{
nn[i]=nn[i]+s[y[i]];
}
for(i=;i<=n;i++)
printf("%d %d\n",nn[i],*n--nn[i]);
}
return ;
}

CodeForces 432B Football Kit的更多相关文章

  1. 432B - Football Kit

    解题思路: 暴力绝对TLE 一个队伍穿主场球衣的次数 = 这个队伍的客场球衣颜色与其他队主场球衣颜色起冲突的次数 + (n - 1) #include <stdio.h> #include ...

  2. CF 432B :Football Kit

    hash做法: #include<stdio.h> #include<string.h> ; int home[Max],away[Max],hash[Max]; int ma ...

  3. Codeforces Round #246 (Div. 2) —B. Football Kit

    B. Football Kit time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...

  4. Codeforces Round #246 (Div. 2) B. Football Kit

    题目的意思是求出每个队穿主场衣服和客场衣服的次数 每个队作为主场的次数是n-1,作为客场的次数是n-1 当每个队打主场的时候肯定穿的主场衣服 当每个队打客场时,如果客场与主场的衣服不同,则穿客场衣服 ...

  5. codeforces 432 B Football Kit

    题意:给出n支球队,主场的衣服的颜色x[i],客场的衣服的颜色y[i],每只队伍会打n-1次主场,n-1次客场,当这只队伍打客场的衣服颜色和对手一样的时候,那么他们要穿上主场的衣服 问每个球队主场球服 ...

  6. CODEFORCE 246 Div.2 B题

    题目例如以下: B. Football Kit time limit per test 1 second memory limit per test 256 megabytes input stand ...

  7. Codeforces Round #281 (Div. 2) A. Vasya and Football 模拟

    A. Vasya and Football 题目连接: http://codeforces.com/contest/493/problem/A Description Vasya has starte ...

  8. Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals) D. Innokenty and a Football League

    地址:http://codeforces.com/contest/782/problem/D 题目: D. Innokenty and a Football League time limit per ...

  9. codeforces 493A. Vasya and Football 解题报告

    题目链接:http://codeforces.com/contest/493/problem/A 题目意思:给出两个字符串,分别代表 home 和 away.然后有 t 个player,每个playe ...

随机推荐

  1. 夺命雷公狗---linux之centos的安装

    由于要玩node.js了,所以还是来复习下linux系统才行,所以夺命雷公狗分享两套安装linux的方法,这是centos的安装方法,,, 管理员默认帐号为:root,密码则是刚才您输入的那个...

  2. 解决xfce4桌面图标消失的问题

    问题表现:panel还在,桌面的背景变成灰色,桌面图标消失,桌面右键没反映 解决方法:从登录管理器中登录另一个用户,发现桌面正常,猜测是由于家目录下的配置文件引起的. 删除 ~/.cache/sess ...

  3. [OrangePi] Installation on internal EMMC

    Install the image on SD Card as described above Boot your Orange PI board from SD Card Run: sudo ins ...

  4. zw版【转发·台湾nvp系列Delphi例程】HALCON color_fuses1

    zw版[转发·台湾nvp系列Delphi例程]HALCON color_fuses1 procedure TForm1.Button1Click(Sender: TObject);var w, h : ...

  5. 什么是商业智能BI和实施BI的解决方案【转】

    商业智能,或BI,是一种统称,泛指用于对一个企业的原始数据进行分析的各种各样的软件系统.商业智能(BI)是由若干相关的活动组成的领域,包括数据挖掘,在线分析处理,查询和报表. 企业用商业智能(BI)来 ...

  6. 鸟哥的linux私房菜学习记录之账号管理与权限设定

    每个登录者都会取到两个ID,一个使用者ID,一个群组ID

  7. hobby

    如果把战争的原则凝缩为一个词,那就是集中. 人生有三把钥匙, 接受. 改变. 离开.不能接受,那就改变,不能改变,那就离开. 少问别人为什么,多问自己凭什么. 太平自古将军定,不许将军见太平

  8. 对于改善 MySQL 数据装载操作有效率的方法是怎样

    多时候关心的是优化SELECT 查询,因为它们是最常用的查询,而且确定怎样优化它们并不总是直截了当.相对来说,将数据装入数据库是直截了当的.然而,也存在可用来改善数据装载操作效率的策略,其基本原理如下 ...

  9. set_include_path — 设置 include_path 配置选项为当前脚本设置 include_path 运行时的配置选项。

    说明 string set_include_path ( string $new_include_path ) 为当前脚本设置 include_path 运行时的配置选项. 参数 new_includ ...

  10. 在ecshop顶部会员信息提示区显示会员等级

    会员登陆后,在顶部会员信息提示区显示会员等级会员登陆后会在顶部出现这样的提示:您好,test2, 欢迎您回来 ! 进入用户中心 |退出现在设想在会员名后面加上“会员等级”效果如下:您好,test2,  ...