题目例如以下:

B. Football Kit
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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
xi,
yi
(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 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

刚開始用双重循环查找超时了,最后改为二分查找AC。

代码例如以下:

CODEFORCE 246 Div.2 B题的更多相关文章

  1. Codeforces Round #246 (Div. 2)——D题

    KMP算法,没写出来,完全不理解NEXT数组.现在理解了很多 答案都在程序中 ,不过这个思想真的很神奇, 还有毛语不好,一直没看懂题目,现在懂了, 大概是:S中前缀等于后缀,求其长度,和其在S中出现了 ...

  2. Codeforces Round #246 (Div. 2) D. Prefixes and Suffixes

                                                        D. Prefixes and Suffixes You have a string s = s ...

  3. Codeforces Round #378 (Div. 2) D题(data structure)解题报告

    题目地址 先简单的总结一下这次CF,前两道题非常的水,可是第一题又是因为自己想的不够周到而被Hack了一次(或许也应该感谢这个hack我的人,使我没有最后在赛后测试中WA).做到C题时看到题目情况非常 ...

  4. Codeforces Round #246 (Div. 2)

    题目链接:Codeforces Round #246 (Div. 2) A:直接找满足的人数,然后整除3就是答案 B:开一个vis数组记录每一个衣服的主场和客场出现次数.然后输出的时候主场数量加上反复 ...

  5. Codeforces#441 Div.2 四小题

    Codeforces#441 Div.2 四小题 链接 A. Trip For Meal 小熊维尼喜欢吃蜂蜜.他每天要在朋友家享用N次蜂蜜 , 朋友A到B家的距离是 a ,A到C家的距离是b ,B到C ...

  6. Codeforces Round #612 (Div. 2) 前四题题解

    这场比赛的出题人挺有意思,全部magic成了青色. 还有题目中的图片特别有趣. 晚上没打,开virtual contest打的,就会前三道,我太菜了. 最后看着题解补了第四道. 比赛传送门 A. An ...

  7. Codeforce#331 (Div. 2) A. Wilbur and Swimming Pool(谨以此题来纪念我的愚蠢)

    C time limit per test 1 second memory limit per test 256 megabytes input standard input output stand ...

  8. Codeforces Round #713 (Div. 3)AB题

    Codeforces Round #713 (Div. 3) Editorial 记录一下自己写的前二题本人比较菜 A. Spy Detected! You are given an array a ...

  9. Codeforces Round #786 (Div. 3) 补题记录

    小结: A,B,F 切,C 没写 1ll 对照样例才发现,E,G 对照样例过,D 对照样例+看了其他人代码(主要急于看后面的题,能调出来的但偷懒了. CF1674A Number Transforma ...

随机推荐

  1. 如何进行Monkey Test

    如何进行Monkey Test   目录 一 简介 二 测试准备 三 基本命令格式 四 测试Log获取 五 Monkey命令参数介绍 六 保存monkey log以及手机log到sdcard(新增) ...

  2. android让你的TabHost滑动起来

    在Android应用中,一般TabActivity和若干个Tab选项卡(TabWidget).如果选项卡的数量超过了5个,就不适合放到一个屏幕中,这样可以让这些选项卡滑动起来. 滑动的选项卡的实现有好 ...

  3. 转载:fstream和ifstream详细用法

    文件 I/O 在C++中比烤蛋糕简单多了.在这篇文章里,我会详细解释ASCII和二进制文件的输入输出的每个细节,值得注意的是,所有这些都是用C++完成的. 一.ASCII 输出 为了使用下面的方法, ...

  4. 擦亮自己的眼睛去看SQLServer之简单Insert(转)

    摘要:本来是打算先写SQLServer历史的,不过感觉写那部分内容比较难还需要多查些资料.于是调整了下顺序写下简单的Insert语句. 不过感觉写那部分内容比较难还需要多查些资料.于是调整了下顺序写下 ...

  5. HDU 5768 Lucky7 容斥原理+中国剩余定理(互质)

    分析: 因为满足任意一组pi和ai,即可使一个“幸运数”被“污染”,我们可以想到通过容斥来处理这个问题.当我们选定了一系列pi和ai后,题意转化为求[x,y]中被7整除余0,且被这一系列pi除余ai的 ...

  6. Ye.云狐J2刷机笔记 | 完美切换内部存储卡和SD卡的改法.vold.fstab

    ================================================================================Ye.完美切换内部存储卡和SD卡成功.v ...

  7. 重新安装Photoshop CS6以后启动软件出现Licensing for this product has expired

    当我们卸载试用版本Photoshop CS6并且重新安装,出现Licensing for this product has expired,并且无法打开软件,这是由于证书过期导致的,解决办法是将计算机 ...

  8. 求职基础复习之快速排序c++版

    #include<iostream> using namespace std; int partition(int a[],int p,int q){ int x = a[q]; ; fo ...

  9. Linux下文件的压缩与打包

    一.Linux下常见的文件压缩命令: 在Linux的环境中,压缩文件的扩展名大多是:『*.tar, *.tar.gz, *.tgz, *.gz, *.Z, *.bz2』,为什么会有这样的扩展名呢? 这 ...

  10. Java邮件服务学习之四:邮箱服务客户端Spring Mail

    一.Spring Mail API Spring邮件抽象层的主要包为org.springframework.mail,Spring提供的邮件发送不仅支持简单邮件的发送.添加附件. 1.邮件发送的核心接 ...