A886 | Cities and States--Silver
来源USACO
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
To keep his cows intellectually stimulated, Farmer John has placed a large map
of the USA on the wall of his barn. Since the cows spend many hours in the
barn staring at this map, they start to notice several curious patterns. For
example, the cities of Flint, MI and Miami, FL share a very special
relationship: the first two letters of "Flint" give the state code ("FL") for
Miami, and the first two letters of "Miami" give the state code ("MI") for
Flint.
Let us say that two cities are a "special pair" if they satisfy this property
and come from different states. The cows are wondering how many special pairs
of cities exist. Please help them solve this amusing geographical puzzle!
of the USA on the wall of his barn. Since the cows spend many hours in the
barn staring at this map, they start to notice several curious patterns. For
example, the cities of Flint, MI and Miami, FL share a very special
relationship: the first two letters of "Flint" give the state code ("FL") for
Miami, and the first two letters of "Miami" give the state code ("MI") for
Flint.
Let us say that two cities are a "special pair" if they satisfy this property
and come from different states. The cows are wondering how many special pairs
of cities exist. Please help them solve this amusing geographical puzzle!
输入格式
The first line of input contains $N$ ($1 \leq N \leq 200,000$), the number of
cities on the map.
The next $N$ lines each contain two strings: the name of a city (a string of
at least 2 and at most 10 uppercase letters), and its two-letter state code (a
string of 2 uppercase letters). Note that the state code may be something like
ZQ, which is not an actual USA state. Multiple cities with the same name can
exist, but they will be in different states.
cities on the map.
The next $N$ lines each contain two strings: the name of a city (a string of
at least 2 and at most 10 uppercase letters), and its two-letter state code (a
string of 2 uppercase letters). Note that the state code may be something like
ZQ, which is not an actual USA state. Multiple cities with the same name can
exist, but they will be in different states.
输出格式
Please output the number of special pairs of cities.
输入输出样例
输入 #1
6 MIAMI FL DALLAS TX FLINT MI CLEMSON SC BOSTON MA ORLANDO FL
输出 #1
1
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted