博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
SGU 538. Emoticons 水题
阅读量:7176 次
发布时间:2019-06-29

本文共 2208 字,大约阅读时间需要 7 分钟。

538. Emoticons

题目连接:

Description

A berland national nanochat Bertalk should always stay up-to-date. That's why emoticons highlighting was decided to be introduced. As making emoticons to be highlighted is not exactly the kind of task one performs everyday but this task had to be done as soon as possible, the following simple rule was decided to be introduced: a round opening or closing bracket be considered part of an emoticon if:

this is an opening bracket and there exists the nearest bracket following to the right. The nearest round bracket to the right should be a closing bracket and there shouldn't be anything between the brackets but spaces and Latin letters,
or else it can be a closing bracket and there exists the nearest round bracket following to the left. The nearest round bracket to the left should be an opening bracket. Besides, there shouldn't be anything between the brackets but spaces and Latin letters.

If a bracket doesn't satisfy the conditions, it is considered a part of an emoticon. For example, let's consider the string "Hi:) (it is me) I have bad ((". In the string only the brackets that outline "it is me" aren't emoticons. Note that an opening bracket immediatelly followed by a closing bracket, i.e. "()", are not parts of emoticons by definition.

Your task is to print the number of brackets that are parts of emoticons in the given string.

Input

The input data consist of a single non-empty string. The length of the string does not exceed 105 characters. The string consists of lowercase and uppercase Latin letters, spaces, round brackets and punctuation marks: "-", ":", ",", ";". The string does not begin with and does not end with a space.

Output

Print a single number — the required number of brackets that are part of emoticons.

Sample Input

Hi:) (it is me) I have bad ((

Sample Output

3

Hint

题意

两个括号内如果只有英文字母 空格的话,就说明这个是正常的括号

否则就是表情括号

问你表情括号有多少个

题解:

直接暴力扫一遍就好了,水题

代码

#include
using namespace std;string s;int check(char c){ if(c=='(')return 1; if(c==')')return 2; if(c==' ')return 3; if(c<='Z'&&c>='A')return 3; if(c<='z'&&c>='a')return 3; return 4;}int main(){ getline(cin,s); int ans = 0; int flag = 0; for(int i=0;i

转载地址:http://vubzm.baihongyu.com/

你可能感兴趣的文章
Java 高效压缩zip
查看>>
什么是自行车码表?自行车码表工作原理?自行车码表安装设置?
查看>>
《MATLAB/Simulink系统仿真超级学习手册》——导读
查看>>
微软准备开源 PowerShell!
查看>>
AMD 向 LibreOffice 贡献 GPU 代码 电子表格速度提升500倍
查看>>
J-SUtil-1.1.3_3 支持对象关联映射查询
查看>>
Opera 32 桌面版发布,新增动态背景功能
查看>>
《精解Windows8》——2.4 关闭计算机
查看>>
《嵌入式 Linux C 语言应用程序设计(修订版)》——2.4 嵌入式Linux调试器GDB的使用...
查看>>
【秒懂设计模式】建造者模式
查看>>
在 Ionic 框架移动应用中支持 iBeacons
查看>>
《Hadoop集群与安全》一第2章 安装和配置Hadoop
查看>>
从ConcurrentHashMap的演进看Java多线程核心技术
查看>>
《敏捷迭代开发:管理者指南》目录—导读
查看>>
如何在Oh-My-Zsh中启用Heroku命令补全功能
查看>>
《敏捷软件开发:原则、模式与实践(C#版.修订版)》—第2章2.2节结论
查看>>
用机器算法预测自杀倾向
查看>>
《精通Android 5 多媒体开发》——第6章,第6.2节分析硬件抽象层
查看>>
阿里云生态日沙龙权益申请规则
查看>>
《精通软件性能测试与LoadRunner最佳实战》—第2章2.8节场景运行监控
查看>>