Codeforces Round #246 (Div. 2) —B. Football Kit
1 second
256 megabytes
standard input
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.
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 ≤ 105; xi ≠ yi) —
the color numbers for the home and away kits of the i-th team.
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.
2
1 2
2 1
2 0
2 0
3
1 2
2 1
1 3
3 1
4 0
2 2
#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的更多相关文章
- Codeforces Round #246 (Div. 2) B. Football Kit
题目的意思是求出每个队穿主场衣服和客场衣服的次数 每个队作为主场的次数是n-1,作为客场的次数是n-1 当每个队打主场的时候肯定穿的主场衣服 当每个队打客场时,如果客场与主场的衣服不同,则穿客场衣服 ...
- Codeforces Round #246 (Div. 2)
题目链接:Codeforces Round #246 (Div. 2) A:直接找满足的人数,然后整除3就是答案 B:开一个vis数组记录每一个衣服的主场和客场出现次数.然后输出的时候主场数量加上反复 ...
- Codeforces Round #246 (Div. 2) D. Prefixes and Suffixes
D. Prefixes and Suffixes You have a string s = s ...
- Codeforces Round #246 (Div. 2) C. Prime Swaps(贪心,数论)
题目链接:http://codeforces.com/contest/432/problem/C 首先由题意分析出:这些数是从1到n且各不相同,所以最后结果肯定是第i位的数就是i. 采用这样一种贪心策 ...
- Codeforces Round #246 (Div. 2) A. Choosing Teams
给定n k以及n个人已参加的比赛数,让你判断最少还能参加k次比赛的队伍数,每对3人,每个人最多参加5次比赛 #include <iostream> using namespace std; ...
- Codeforces Round #246 (Div. 2)——D题
KMP算法,没写出来,完全不理解NEXT数组.现在理解了很多 答案都在程序中 ,不过这个思想真的很神奇, 还有毛语不好,一直没看懂题目,现在懂了, 大概是:S中前缀等于后缀,求其长度,和其在S中出现了 ...
- 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 ...
- Codeforces Round #246 (Div. 2) D E
这题说的是给了一个字符串当前缀和后缀相同的时候就计算此时的 整个串种拥有这样的子串友多少个,没想到用KMP解 用0开头的那种类型的 KMP 今天刚好也学了一下,因为KMP的作用是找出最长前缀 KMP ...
- Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals)
Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals) 说一点东西: 昨天晚上$9:05$开始太不好了,我在学校学校$9:40$放 ...
随机推荐
- 学习笔记之NodeJs基本操作
nodejs安装见文章:windows下安装node.js及less 运行js文件:node xxx.js 调用http模块,并指定端口为3000,向客户端输出<h1>Node.js< ...
- gdb 远程qemu-arm调试
把 c 编译成 arm 指令的可运行文件 /usr/bin/arm-linux-gnueabi-g++ hello.cpp cat hello.cpp #include <stdio.h> ...
- Swift - 手机摇晃的监测和响应
摇晃手机也是一种常用的交互手段(比如微信摇一摇功能).iOS SDK中已经将shake事件方便地融合进去了,就像触发touch事件一样简单,发生摇晃事件后程序会自动执行. 1 2 3 4 5 6 7 ...
- 原码、反码、补码和移码事实上非常easy
近期在备战软考,复习到计算机组成原理的时候,看到书中关于原码.反码.补码和移码的定义例如以下(n是机器字长): 原码: 反码: 补码: 移码: 看完这些定义以后,我的脑袋瞬间膨胀到原来的二倍!这样变态 ...
- python for else
http://blog.sina.com.cn/s/blog_5357c0af01013mwn.html raw_input() 与 input() __ Python http://www.cnbl ...
- MVC控制器里面使用dynamic和ExpandoObject
MVC控制器里面使用dynamic和ExpandoObject 在很多时候,我们在数据库里面定义表字段和实际在页面中展示的内容,往往是不太匹配的,页面数据可能是多个表数据的综合体,因此除了我们在表设计 ...
- PHP学习之-1.3 echo语句
echo语句 echo语句是PHP输出语句,可以把字符串输出(字符串用双引号扩起来). 如下代码 <?php echo "Hello World!"; ?> 注意ech ...
- 基于visual Studio2013解决面试题之0610删除重复字符串
题目
- ASP.NET - List<> 绑定 DropDownList
代码: //声明泛型 List<category> inof = new List<category>();//二级分类 //声明类使用的对象类 public class ca ...
- Android SDK Manager安装报错
安装出错了,上网百度一大堆说法,又说版本兼容问题的,有说http换https的,我这个菜鸟真搞不明白,自己捣腾一下午总算弄上去了! 问题: 安装完Eclipse和ADT却无法更新SDK. 启动Andr ...