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. 【RoR win32】安装RoR

    在配置好ruby的win 7 命令行下运行, gem install rails 安装成功之后会收到提示,下面就可以用rails建立项目了. 为了提高“rails new”时“bundle insta ...

  2. 【转】C#访问权限修饰符

    C#访问权限修饰符 C#中类及类型成员修饰符有以下四类:public,private,protected,internal. public        类及类型成员的修饰符 private 类型成员 ...

  3. WCF技术的不同应用场景及其实现分析

    这一篇文章,是总结一下WCF技术,以及基于这个技术发展出来的几个典型应用场景,并且我将尝试对这些不同的WCF实现的原理进行一些比较分析. 关于WCF这个技术的基本概念,如果你不是很清楚,可以参考一下有 ...

  4. 视频处理控件TVideoGrabber部分技术问题解答

    TVideoGrabber是一个功能全面.易于使用的视频捕捉工具和多媒体播放器,本文搜集了一些TVideoGrabber的技术问答,并针对于有的朋友遇到的疑难给出了解答. 一.在TVideoGrabb ...

  5. UTF8转码, 考虑利用app转好再传, CC2541转太麻烦了...

  6. Linux内核抢占与中断返回【转】

    转自:http://blog.csdn.net/tommy_wxie/article/details/7425728 版权声明:本文为博主原创文章,未经博主允许不得转载. [html] view pl ...

  7. 使用python脚本监控weblogic

    1.python的脚本如下: ############################################################################### #crea ...

  8. fprintf 读入%s,要注意

    eg  文件内容faninfd 14   "%s %d",会把整行内容放到%s 而%d是乱码 ps: 文件内容是 1,2,3    “%d,%d,%d” 文件内容是1:2:3   ...

  9. 在MyEclipse中搭建Spring MVC开发环境

    环境版本 IDE:MyEclipse 8.5 Spring:spring 3.2.8 JDK:1.6 1.打开MyEclipse-->File-->New-->Web Project ...

  10. 深入理解block

    2010年WWDC发布iOS4时Apple对Objective-C进行了一次重要的升级:支持Block.说到底这东西就是闭包,其他高级语音例如Java和C++已有支持,第一次使用Block感觉满简单好 ...