博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces Round #246 (Div. 2) B. Football Kit
阅读量:6406 次
发布时间:2019-06-23

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

 

 

B. Football Kit
 

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 ≤ 105; xi ≠ 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 test(s)
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

 

 

 

【题目大意】

N个足球队要打比赛,每支队伍都要和其他N-1支队伍打两场,一场主场一场客场,每支队伍的衣服颜色都有分主场x和y,并且x!=y。原则上主场就穿主场颜色的衣服,客场就穿客场颜色的。但是如果一支队伍的是打客场,并且客场颜色刚好跟对方主场颜色一样,为了可以区分,这支客场的队伍需要穿他们主场的衣服。

问题就是要我们计算出,在所有比赛结束后,每个队伍的主场和客场衣服各穿了多少次。

【题目分析】

首先,每支队伍都要打自己主场的比赛n-1次,所以他们主场颜色的衣服至少是N-1次,剩下的就是n-1次客场作战的比赛中,看他们客场衣服跟其他队主场的冲突次数了。由于颜色使用整数表示,并且不超过100000,所以我们可以直接开个100001大小的数组来统计每种主场颜色出现的次数,这样就可以知道每个队伍的客场跟别人的主场冲突的次数了,相应的客场衣服的次数也就能求出来了。

 

 

#include
#include
#include
#include
#define MAX 100005using namespace std;int x[MAX];int y[MAX];int f[MAX];int main(){ int n; cin>>n; for(int i=0;i
View Code

 

 

 

 

转载于:https://www.cnblogs.com/crazyacking/p/3811133.html

你可能感兴趣的文章
八大监听器
查看>>
self.navigationController退出到指定页面,或者一次性pop出n个页面
查看>>
Quartz实现数据库动态配置定时任务
查看>>
iptables 端口转发以及双向通信
查看>>
备战一线互联网公司Java工程师面试题 (1)
查看>>
ThinkPHP中自动验证失败
查看>>
jquery图片切换插件jquery.cycle.js参数详解
查看>>
JavaScript push() 方法
查看>>
Map集合
查看>>
JSP基础语法1
查看>>
elasticsearch Java API 之GET API & DELETE API
查看>>
《深入理解Java虚拟机》——GC基础概念
查看>>
微信小程序联盟:官方文档+精品教程+demo集合(5月31日更新,持续更新中……)...
查看>>
Fastjson 的 Set类型和 WriteClassName 选项引起的BUG
查看>>
翻译: 星球生成 II
查看>>
IOS 多线程
查看>>
python序列化数据本地存放
查看>>
#CCNA#IP地址、子网划分参考资料网址
查看>>
比较不错的图片上传插件
查看>>
判偶不判奇
查看>>