博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CodeForces 432B Football Kit
阅读量:6603 次
发布时间:2019-06-24

本文共 2206 字,大约阅读时间需要 7 分钟。

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

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
1 #include 
2 #include
3 #include
4 using namespace std; 5 map
s; 6 int main() 7 { 8 int n; 9 int i,j,x[100005],y[100005],nn[100005];10 while(scanf("%d",&n)!=EOF)11 {12 s.clear();13 for(i=1;i<=n;i++)14 {15 scanf("%d %d",&x[i],&y[i]);16 s[x[i]]++;17 nn[i]=n-1;18 }19 20 for(i=1;i<=n;i++)21 {22 nn[i]=nn[i]+s[y[i]];23 }24 for(i=1;i<=n;i++)25 printf("%d %d\n",nn[i],2*n-2-nn[i]);26 }27 return 0;28 }
View Code

 

转载于:https://www.cnblogs.com/cyd308/p/4771503.html

你可能感兴趣的文章
2016阿里巴巴73款开源产品全向图
查看>>
[转]平面方程
查看>>
20165105 第八周学习总结
查看>>
Sublime Enter Key Setting自动缩进设置
查看>>
maven在win7系统上的安装
查看>>
实例讲解教你读懂路由表
查看>>
Glibc 和 uClibc
查看>>
VMware 虚拟机的虚拟磁盘编程知识点扫盲之二
查看>>
Have a Good Attitude 良好的态度
查看>>
win7 web开发遇到的问题-由于权限不足而无法读取配置文件,无法访问请求的页面...
查看>>
vs2012中自带IIS如何让其他电脑访问
查看>>
谁(何时)需要设置监听器(回调)
查看>>
关于termux在手机上搭载Linux系统,python,ssh
查看>>
Redux:异步操作
查看>>
Mysql学习第三课-分析二进制日志进行增量备份和还原
查看>>
2-11
查看>>
关于C#调用广州医保HG_Interface.dll调用的一些总结(外部组件异常)
查看>>
N2CMS——Bugs解决方案总结
查看>>
Appium IOS
查看>>
xhprof安装记录
查看>>