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. java web sql注入测试(3)---现象分析

    那为什么出现以上问题呢?这是程序代码层控制不当导致的.如果web前端对输入数据控制严格,会对数据库进行操作的字符串,在客户端做敏感字符转义处理,或者在操作数据库的dao层,使用动态参数的sql,不使用 ...

  2. kernel32.dll出错解决方案

    kernel32.dll 一.什么是kernel32内核文件 kernel32.dll是Windows 9x/Me中非常重要的32位动态链接库文件,属于内核级文件.它控制着系统的内存管理.数据的输入输 ...

  3. 5 Best Automation Tools for Testing Android Applications

    Posted In | Automation Testing, Mobile Testing, Software Testing Tools   Nowadays automated tests ar ...

  4. selenium+phantomJS学习使用记录

    背景知识: phantomjs是一个基于webkit的没有界面的浏览器,所以运行起来比完整的浏览器要高效. selenium是一个测试web应用的工具,目前是2.42.1版本,和1版的区别在于2.0+ ...

  5. 高并发 php uniqid 用md5生成不重复唯一标识符方案

    高并发 php uniqid 用md5生成不重复唯一标识符方案uniqid() 函数基于以微秒计的当前时间,生成一个唯一的 ID.uniqid(prefix,more_entropy)prefix 可 ...

  6. (转载)CSV 文件处理 PERL

    http://cn.perlmaven.com/how-to-read-a-csv-file-using-perl http://search.cpan.org/~hmbrand/Text-CSV_X ...

  7. DECODE函数

    DECODE函数相当于一条件语句(IF),它将输入数值与函数中的参数列表相比较,根据输入值返回一个对应值.函数的参数列表是由若干数值及其对应结果值组成的若干序偶形式.当然,如果未能与任何一个实参序偶匹 ...

  8. anroid 查看签名信息的方法

    1.把app改成压缩文件 2.解压以后找到META-INF\CERT.RSA 3.在CMD命令行里面输入:  keytool -printcert -file  E:\META-INF\CERT.RS ...

  9. get/post方式调用http接口

    http://www.cnblogs.com/java-pan/tag/HTTP/ http://www.cnblogs.com/snoopylovefiona/p/4730242.html(可做参考 ...

  10. C#:通过Window API接口实现WiFi

    1.获取Mac地址 //WiFi通知回调 private WlanApi.WLAN_NOTIFICATION_CALLBACK _notificationCallback; this._notific ...