QOJ.ac

QOJ

时间限制: 1.0 s 内存限制: 32 MB 总分: 90

#16638. ESEJ

统计

Mirko 的最新家庭作业是写一篇论文。然而,他觉得写论文太无聊了,在写了两个小时之后,他发现自己写下的只是 $N$ 个完全由字母 A 和 B 组成的单词。可怜的 Mirko 已经接受了自己无法按时完成论文的事实,于是他决定至少通过计算“漂亮单词”的数量来找点乐子。

Mirko 通过在单词上方绘制拱桥来连接成对的相同字母(A 与 A 连接,B 与 B 连接)。如果一个单词中的每个字母都可以与恰好一个其他字母连接,且任意两条拱桥都不相交,则称该单词是漂亮的。请帮助 Mirko 计算有多少个单词是漂亮的。

输入格式

输入的第一行包含一个正整数 $N$ ($1 \le N \le 100$),表示 Mirko 写下的单词数量。

接下来的 $N$ 行,每行包含一个仅由字母 A 和 B 组成的单词,其长度在 $2$ 到 $100\,000$ 之间(含边界)。所有单词的长度之和不超过 $1\,000\,000$。

输出格式

输出的第一行也是唯一一行,应当包含漂亮单词的数量。

样例

输入 1

3
ABAB
AABB
ABBA

输出 1

2

输入 2

3
AAA
AA
AB

输出 2

1

输入 3

1
ABBABB

输出 3

1

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.