A1267 | [COCI-2012_2013-contest4]#3 ESEJ
来源COCI
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
Mirko's latest homework assignment is writing an essay. However, he finds writing essays so boring that, after working for two hours, he realized that all he has written are N long words consisting entirely of letters A and B. Having accepted that he will never finish the essay in time, poor Mirko has decided to at least have some fun with it by counting nice words.
Mirko is connecting pairs of identical letters (A with A, B with B) by drawing arches above the word.
A given word is nice if each letter can be connected to exactly one other letter in such a way that no two arches intersect. Help Mirko count how many words are nice.
Mirko is connecting pairs of identical letters (A with A, B with B) by drawing arches above the word.
A given word is nice if each letter can be connected to exactly one other letter in such a way that no two arches intersect. Help Mirko count how many words are nice.
输入格式
The first line of input contains the positive integer N (1 ≤ N ≤ 100), the number of words written down by Mirko.
Each of the following N lines contains a single word consisting of letters A and B, with length between 2 and 100 000, inclusive. The sum of lengths of all words doesn't exceed 1 000 00
0.
Each of the following N lines contains a single word consisting of letters A and B, with length between 2 and 100 000, inclusive. The sum of lengths of all words doesn't exceed 1 000 00
0.
输出格式
The first and only line of output must contain the number of nice words.
输入输出样例
输入 #1
3 ABAB AABB ABBA
输出 #1
2
输入 #2
3 AAA AA AB
输出 #2
1
输入 #3
1 ABBABB
输出 #3
1
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted