uva 514 铁轨(栈)
来源:互联网 发布:网络发生器辐射高吗 编辑:程序博客网 时间:2024/04/30 04:54
数据结构基础题
思路见码
#include<cstdio> #include<cstring> #include<cmath> #include<cstdlib> #include<iostream> #include<algorithm> #include<vector> #include<map> #include<queue> #include<stack> #include<string>#include<map> using namespace std; #define LL long long const int maxn=1010;int n,target[maxn];int main(){while(scanf("%d",&n)){stack<int> s;int A=1,B=1;for(int i=1;i<=n;i++) scanf("%d",&target[i]);int ok=1;while(B<=n){if(A==target[B]) {A++;B++;}else if(!s.empty()&&s.top()==target[B]) {s.pop();B++;}else if(A<n) {s.push(A);A++;}else {ok=0;break;}}printf("%s\n",ok?"Yes":"No");}return 0;}
0 0
- uva 514 铁轨(栈)
- UVa 514(栈)铁轨
- 铁轨(UVa 514)
- UVa 514 Rails(铁轨) 栈
- UVA 514 铁轨 (Rails)
- UVa 514 铁轨
- UVA 514 Rails 铁轨
- 例题6-2 UVA 514 - Rails (铁轨)
- 铁轨(栈)
- Rails铁轨(栈)
- 铁轨-栈(stack)
- 栈(样列:铁轨)
- 铁轨问题(栈操作)
- 《算法艺术与信息学竞赛》之 栈 例一 铁轨 Uva 514
- 例题6-2 铁轨(Rails, ACM/ICPC CERC 1997, UVa 514)
- 铁轨 栈
- 栈 铁轨
- 栈------铁轨
- JS之clientX,clientY,screenX,screenY,offsetX,offsetY区别测试
- 携手时间,靠近梦想——番茄工作法使用分享
- SDWebImage
- 数据流重定向
- 机器学习十大经典算法 (收集)
- uva 514 铁轨(栈)
- NPTL进程创建流程
- Android ApiDemo 之 BouncingBalls
- 正则表达式(vim版)非贪婪匹配释疑
- mac 邮箱完整备份
- Windows Phone 学习 调用各种网络设置
- Swift学习:6.字符串和字符
- org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog
- 汇编复习题