UVA 673 栈的应用
来源:互联网 发布:中文地址匹配 软件 编辑:程序博客网 时间:2024/06/06 13:56
You are given a string consisting of parentheses () and [].
A string of this type is said to be correct:
(a) if it is the empty string
(b) if A and B are correct, AB is correct,
(c) if A is correct, (A) and [A] is correct.
Write a program that takes a sequence of strings of this type and check their correctness.
Your program can assume that the maximum string length is 128.
Input
The file contains a positive integer n and a sequence of n strings of parentheses ‘()’ and ‘[]’, one stringa line.OutputA sequence of ‘Yes’ or ‘No’ on the output file.
Sample Input
3
([])
(([()])))
([()[]()])()
Sample Output
Yes
No
Yes
题意 很好理解
1 如果 是空 则合法。
2 如果 A与B合法 ,则AB合法。
3 如果A合法 (A)[A]合法。
用栈来模拟这个过程。
每次取一个元素
如果与栈顶匹配,就pop栈顶,如果不匹配,压入栈中
到最后,如果为空,则合法
- UVA 673 栈的应用
- UVA - 673 - Parentheses Balance (栈的应用!)
- UVA 442(栈的应用)
- UVA 673 括号的匹配——经典栈的应用
- uva 610(tarjan的应用)
- UVa 10763 Foreign Exchange (map的应用)
- UVA 11796 - Dog Distance 向量的应用
- Add All -uva优先队列的应用
- Sumsets uva+hash表的应用
- UVA 11235 - Frequent values (RMQ的应用)
- UVA - 10282 Babelfish map的应用
- UVA - 11624 - Fire! (BFS的应用)
- UVA 11020 Efficient Solutions+multiset的应用
- UVA - 12174 Shuffle 滑动窗口的应用。
- <常量数组的应用> UVA 10082 WERTYU
- Uva 514 Rails(栈应用)
- UVA - 112 - Tree Summing (数的求和!栈的应用!)
- uva 11995 栈,队列,优先队列,等基本数据结构的应用与理解
- WPF教程(三十)Grid单元格
- ThinkPHP中的系统函数使用总结
- ORA-12514监听程序当前无法识别连接描述符中请求的服务
- Canvas实现放大镜效果
- 建立堆复杂度On,均摊思想
- UVA 673 栈的应用
- 读《在你身边,为你设计》
- iOS打包上传AppStore最详细的教程(新手必看)
- JAVA SSH ----Struts上传与下载文件
- hex文件和bin文件区别
- Leetcode-354. Russian Doll Envelopes
- CornerStone 常见的图标含义
- KinectManager 部分笔记
- git+jenkins自动构建一