Codeforces Round #164 (Div. 2) A. Games【暴力/模拟/每个球队分主场和客场,所有球队两两之间进行一场比赛,要求双方球服颜色不能相同】
1 second
256 megabytes
standard input
standard output
Manao works on a sports TV. He's spent much time watching the football games of some country. After a while he began to notice different patterns. For example, each team has two sets of uniforms: home uniform and guest uniform. When a team plays a game at home, the players put on the home uniform. When a team plays as a guest on somebody else's stadium, the players put on the guest uniform. The only exception to that rule is: when the home uniform color of the host team matches the guests' uniform, the host team puts on its guest uniform as well. For each team the color of the home and guest uniform is different.
There are n teams taking part in the national championship. The championship consists of n·(n - 1)games: each team invites each other team to its stadium. At this point Manao wondered: how many times during the championship is a host team going to put on the guest uniform? Note that the order of the games does not affect this number.
You know the colors of the home and guest uniform for each team. For simplicity, the colors are numbered by integers in such a way that no two distinct colors have the same number. Help Manao find the answer to his question.
The first line contains an integer n (2 ≤ n ≤ 30). Each of the following n lines contains a pair of distinct space-separated integers hi, ai (1 ≤ hi, ai ≤ 100) — the colors of the i-th team's home and guest uniforms, respectively.
In a single line print the number of games where the host team is going to play in the guest uniform.
3
1 2
2 4
3 4
1
4
100 42
42 100
5 42
100 5
5
2
1 2
1 2
0
In the first test case the championship consists of 6 games. The only game with the event in question is the game between teams 2 and 1 on the stadium of team 2.
In the second test sample the host team will have to wear guest uniform in the games between teams: 1 and 2, 2 and 1, 2 and 3, 3 and 4, 4 and 2 (the host team is written first).
【代码】:
#include <bits/stdc++.h>
/*
题意:有n个球队,每个球队分主场和客场
所有球队两两之间进行一场比赛,要求双方球服颜色不能相同
问你需要准备多少种球服。
*/
using namespace std;
const int N = ;
int cnt=;
int n;
int a[N],b[N];
int main()
{
while(cin>>n)
{
for(int i=;i<=n;i++)
cin>>a[i]>>b[i];
for(int i=;i<=n;i++)
for(int j=;j<=n;j++)//当了主场 又在客场出现
if(a[i]==b[j])
cnt++;
cout<<cnt<<endl;
}
return ;
}
傻逼模拟
Codeforces Round #164 (Div. 2) A. Games【暴力/模拟/每个球队分主场和客场,所有球队两两之间进行一场比赛,要求双方球服颜色不能相同】的更多相关文章
- codeforces水题100道 第十六题 Codeforces Round #164 (Div. 2) A. Games (brute force)
题目链接:http://www.codeforces.com/problemset/problem/268/A题意:足球比赛中如果主场球队的主场球衣和客队的客队球衣颜色一样,那么要求主队穿上他们的可对 ...
- Codeforces Round #369 (Div. 2) A B 暴力 模拟
A. Bus to Udayland time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Round #368 (Div. 2) B. Bakery (模拟)
Bakery 题目链接: http://codeforces.com/contest/707/problem/B Description Masha wants to open her own bak ...
- Codeforces Round #284 (Div. 2)A B C 模拟 数学
A. Watching a movie time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Codeforces Round #285 (Div. 2) A B C 模拟 stl 拓扑排序
A. Contest time limit per test 1 second memory limit per test 256 megabytes input standard input out ...
- Codeforces Round #307 (Div. 2) B. ZgukistringZ 暴力
B. ZgukistringZ Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/551/probl ...
- Codeforces Round #328 (Div. 2) A. PawnChess 暴力
A. PawnChess Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/592/problem/ ...
- Codeforces Round #404 (Div. 2)(A.水,暴力,B,排序,贪心)
A. Anton and Polyhedrons time limit per test:2 seconds memory limit per test:256 megabytes input:sta ...
- Codeforces Round #164 (Div. 2)
A. Games 模拟. B. Buttons 简单计数. C. Beautiful Sets of Points 显然每行每列只能有一个点,那么最大点数为\(1+min(n, m)\). 在不考虑\ ...
随机推荐
- javascript类式继承模式#3——借用和设置原型
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- iOS笔记055 - UI总结01
1.程序启动后的开始动画 程序启动后可以加载一个简单的动画界面来介绍程序或者用户信息. 可以使用一个xib来描述界面.并且如果想在程序加载完成后第一个加载这个xib文件,需要在Appdelegat ...
- Python调用Webservice
使用Python调用webservice 推荐使用 suds包 该包一般在Python2.x python3各种麻烦 略过 实例 import suds # webservice url url ...
- PoolManager
我用的PoolManager版本是5.5.2的,导入的包总共有三个文件夹:Editor,Plugins,PoolManagerExampleFiles 1.Editor这个文件夹里面的东西,顾名思义, ...
- FTP数字代码的意义
110 重新启动标记应答.120 服务在多久时间内ready.125 数据链路端口开启,准备传送.150 文件状态正常,开启数据连接端口.200 命令执行成功.202 命令执行失败.211 系统状态或 ...
- 第三节 MVC应用程序架构和测试
在查看如何测试单个功能之后,您可能会问,整个Web应用程序如何? 如前所述,有以下级别的测试: 单元测试 集成测试 功能测试 在开始编写测试时考虑这一点很重要. 可能还有其他类型的测试,但现在让我们关 ...
- 团队Alpha版本冲刺(四)
目录 组员情况 组员1(组长):胡绪佩 组员2:胡青元 组员3:庄卉 组员4:家灿 组员5:凯琳 组员6:丹丹 组员7:何家伟 组员8:政演 组员9:鸿杰 组员10:刘一好 组员:何宇恒 展示组内最新 ...
- HTML,CSS,font-family:中文字体的英文名称【转载】
转自:http://www.9958.pw/post/html_font-family 宋体 SimSun 黑体 SimHei 微软雅黑 Microsoft YaHei 微软正黑体 Microsoft ...
- 3.5 实例讲解Lucene索引的结构设计
3.2节我们已经运行了一个Lucene建立索引的小程序,这一节我们就以这个小程序为例讲解一下Lucene建立索引的过程. import java.nio.charset.StandardCharset ...
- Http错误大全
HTTP/IIS错误类型 1XX 信息提示 用于表示临时的响应.客户端在收到常规响应之前,应准备接受一个或多个1XX响应. 100 :继续101 :切换协议 2XX 成功 表示服务器成功地接受了客户端 ...