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 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

题意:打印当前队 穿主场衣服作战的次数 和  穿客场衣服作战的次数

思路:简单的哈希思想+规律  就可以AC,仅仅是 题意不是非常好理解

规律是 n个队  每一个队会进行 n-1次 比赛  主场服使用次数 + 客场服使用次数  = 2*(n-1)
主场服使用次数  =  n-1 + 当前队客场服与其它队 主场服同样的次数

#include <stdio.h>
#include <stdlib.h>
#include <string.h> int a[100010];
int b[100010],c[100010]; int main()
{
int n,i;
scanf("%d",&n);
memset(a,0,sizeof(a));
for(i = 0; i<n; i++)
{
scanf("%d%d",&b[i],&c[i]);
a[b[i]]++;
}
for(i = 0; i<n; i++)
{
printf("%d %d\n",n-1+a[c[i]],2*(n-1)-(n-1+a[c[i]]));
}
return 0;
}

Codeforces Round #246 (Div. 2) —B. Football Kit的更多相关文章

  1. Codeforces Round #246 (Div. 2) B. Football Kit

    题目的意思是求出每个队穿主场衣服和客场衣服的次数 每个队作为主场的次数是n-1,作为客场的次数是n-1 当每个队打主场的时候肯定穿的主场衣服 当每个队打客场时,如果客场与主场的衣服不同,则穿客场衣服 ...

  2. Codeforces Round #246 (Div. 2)

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

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

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

  4. Codeforces Round #246 (Div. 2) C. Prime Swaps(贪心,数论)

    题目链接:http://codeforces.com/contest/432/problem/C 首先由题意分析出:这些数是从1到n且各不相同,所以最后结果肯定是第i位的数就是i. 采用这样一种贪心策 ...

  5. Codeforces Round #246 (Div. 2) A. Choosing Teams

    给定n k以及n个人已参加的比赛数,让你判断最少还能参加k次比赛的队伍数,每对3人,每个人最多参加5次比赛 #include <iostream> using namespace std; ...

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

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

  7. Codeforces Round #246 (Div. 2) D. Prefixes and Suffixes(后缀数组orKMP)

    D. Prefixes and Suffixes time limit per test 1 second memory limit per test 256 megabytes input stan ...

  8. Codeforces Round #246 (Div. 2) D E

    这题说的是给了一个字符串当前缀和后缀相同的时候就计算此时的 整个串种拥有这样的子串友多少个,没想到用KMP解 用0开头的那种类型的 KMP 今天刚好也学了一下,因为KMP的作用是找出最长前缀 KMP ...

  9. Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals)

    Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals) 说一点东西: 昨天晚上$9:05$开始太不好了,我在学校学校$9:40$放 ...

随机推荐

  1. Bee Framework_百度百科

    Bee Framework_百度百科 Bee Framework 编辑   目录 1详细信息 简介 特性 2工作 主要模块 编译要求 运行要求 目录结构 运行例程 安装步骤     1详细信息 简介 ...

  2. SilkTest Q&A 13

    Q121 :我想要测试 windows2003 上的 remote 应用,但是每次都得到如下的错误 我想要测试 windows2003 上的 remote 应用,但是每次都得到如下的错误: " ...

  3. JQuery获取与设置HTML元素的值value

    JQuery获取与设置HTML元素的值value 作者:简明现代魔法图书馆 发布时间:2011-07-07 10:16:13 20481 次阅读 服务器君一共花费了13.221 ms进行了6次数据库查 ...

  4. InsertOnSubmit、InsertAllOnSubmit等区别 (转)

    a. InsertOnSubmit: 将一个实体添加到datacontext对象中,并在SubmitChange()的时候执行更改. b. InsertAllOnSubmit:将一个实体集合添加到da ...

  5. python模块介绍- binascii 二进制和ASCII转换

    python模块介绍-binascii二进制和ASCII转换 目录 项目简介 简介: Uu编码 Binhex编码 Base64编码 QP码 CRC校验和 二进制转换 其他实例 项目简介 Python中 ...

  6. js点击button按钮跳转到另一个新页面

    点击按钮怎么跳转到另外一个页面呢?我们在网站制作中可能是需要的,因为有时我们需要做这样的效果,尤其是将按钮做成一个图片,而点击图片要跳转到新的页面时,怎么做到呢? 这样的效果可以:onclick=&q ...

  7. boost::asio async_write也不能保证一次发完所有数据 一

    你要是看过basic_stream_socket的文档,里面提到async_write_some不能保证将所有要发送的数据都发出去.并且提到如果想这样做,需要使用boost asio的async_wr ...

  8. Linux内核驱动将多个C文件编译成一个ko文件的方法——每一个C文件中都有module_init与module_exit

    以两个C文件为例: 将本该被分别编译成adc_device.ko和adc_driver.ko的adc_device.c.adc_driver.c编译成一个ko文件! 採用方法: 第一步.改动C文件 1 ...

  9. 中国本土管理咨询公司排名TOP50

    中国本土管理咨询公司排名TOP50 1. 北京正略钧策管理顾问有限公司 2. 北京和君咨询公司 3. 北大纵横管理咨询公司 4. 远卓管理顾问公司 5. AMT管理咨询公司 6. 华夏基石管理咨询有限 ...

  10. 打开excel2007文档时显示“excel无法打开文件~$book.xltm”

    此问题的出现是因为意外情况导致Excel临时文件没有删掉,把C:\Program Files\Microsoft Office\Office12\XLSTART里面的临时文件“~$book”给删除就好 ...