题目例如以下:

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. 一幅图概括Android测试的方方面面

    一幅图概括Android测试的方方面面,来自网络: 另外的一些测试技巧 1,测试应用程序时,环境是很大的一个影响因素:系统时间,网络情况,异常关闭等 2,测试应用程序时,第三方嵌入程序也是有影响的.如 ...

  2. 微信公众平台开发(57)Emoji表情符号

    微信公众平台开发 微信公众平台开发模式 企业微信公众平台 Emoji表情符号 作者:方倍工作室 地址:http://www.cnblogs.com/txw1958/p/crack-golden-egg ...

  3. 直线相交 POJ 1269

    // 直线相交 POJ 1269 // #include <bits/stdc++.h> #include <iostream> #include <cstdio> ...

  4. Components of the Impala Server

    Components of the Impala Server The Impala server is a distributed, massively parallel processing (M ...

  5. redis 应用

    前段使用JQueryMobile进行展示. 实现了用户注册,登陆,列表基本功能 非常简洁. 如果想了解Redis存储,Express的处理可以提供一些基础的示范. 下载地址: https://gith ...

  6. JAVA NIO 类库的异步通信框架netty和mina

    Netty 和 Mina 我究竟该选择哪个? 根据我的经验,无论选择哪个,都是个正确的选择.两者各有千秋,Netty 在内存管理方面更胜一筹,综合性能也更优.但是,API 变更的管理和兼容性做的不是太 ...

  7. Hadoop port to Jxta P2P Framework

    https://www.java.net/forum/topic/jxta/jxta-community-forum/hadoop-port-jxta-p2p-framework —————————— ...

  8. UVALive 7334 Kernel Knights (dfs)

    Kernel Knights 题目链接: http://acm.hust.edu.cn/vjudge/contest/127407#problem/K Description Jousting is ...

  9. threading模块

    threading — Higher-level threading interface¶ Source code: Lib/threading.py This module constructs h ...

  10. .NET的Snk使用方法

    保护你Asp.Net生成的DLL和Code不被别人反编译  大家做项目开发一般都是分层的,比如UI层,业务层,数据访问层.业务层引用数据访问层的DLL(比如 dataAccess.dll),并使用da ...