hdoj--5479--Scaena Felix(stack水题)
来源:互联网 发布:it企业级 编辑:程序博客网 时间:2024/05/10 14:55
Scaena Felix
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 768 Accepted Submission(s): 327
Problem Description
Given a parentheses sequence consist of '(' and ')', a modify can filp a parentheses, changing '(' to ')' or ')' to '('.
If we want every not empty <b>substring</b> of this parentheses sequence not to be "paren-matching", how many times at least to modify this parentheses sequence?
For example, "()","(())","()()" are "paren-matching" strings, but "((", ")(", "((()" are not.
If we want every not empty <b>substring</b> of this parentheses sequence not to be "paren-matching", how many times at least to modify this parentheses sequence?
For example, "()","(())","()()" are "paren-matching" strings, but "((", ")(", "((()" are not.
Input
The first line of the input is a integer T , meaning that there are T test cases.
Every test cases contains a parentheses sequenceS only consists of '(' and ')'.
1≤|S|≤1,000 .
Every test cases contains a parentheses sequence
Output
For every test case output the least number of modification.
Sample Input
3()(((((())
Sample Output
102
Source
BestCoder Round #57 (div.2)
括号配对水题
#include<cstdio>#include<stack>#include<cstring>#include<algorithm>using namespace std;char s[20000];int main(){int t;scanf("%d",&t);while(t--){memset(s,0,sizeof(s));stack<char>q;scanf("%s",s);q.push(s[0]);int ans=0;int i;for(i=1;i<strlen(s);i++){if(s[i]==')')q.pop(),ans++;elseq.push(s[i]);}printf("%d\n",ans);}return 0;}
0 0
- hdoj--5479--Scaena Felix(stack水题)
- hdoj 5479 Scaena Felix 【Stack】
- HDOJ 5479 Scaena Felix
- HDOJ 5479 Scaena Felix (栈)
- Scaena Felix 5479 (栈)
- HDU 5479 Scaena Felix
- HDU 5479 Scaena Felix
- HDU 5479 Scaena Felix
- HDU 5479 Scaena Felix
- HDU 5479 Scaena Felix(DP)
- hdu 5479 Scaena Felix 枚举
- hdu 5479 Scaena Felix(水)
- HDU 5479 Scaena Felix【STL】
- HDU 5479 Scaena Felix(简单的数据结构题目)
- HDU - 5479 Scaena Felix (栈模拟)水
- Scaena Felix
- HDU 5479 Scaena Felix(求一个序列里有多少对括号能够匹配)
- BestCoder Round #57 (div.2) HDU 5479 Scaena Felix
- 计算s=a+aa+aaa+aaaa+aa...a形式的表达式的和,其中a是一个数字
- [Accessibility] Missing contentDescription attribute on image问题
- Android的单位px,pt,dp,sp总结和获取屏幕分辨率
- IP、域名、手机号归属地查询
- POJ 3258 小牛过河 二分搜索最大的最小值
- hdoj--5479--Scaena Felix(stack水题)
- checkbox已设置为checked--true-但不勾选问题解决方法(只第一次勾选有效)
- 一台电脑同时运行多个tomcat配置方法
- ImageView的src图片交换
- mutable、volatile的使用
- Android-使用Gallery制作图片浏览册
- 实现HTTP协议Get、Post和文件上传功能——使用libcurl接口实现
- tomcat下运行的Jenkins可用插件为空
- 指针与数组