算法竞赛入门经典第六章例题6-2 Rails UVA - 514
2018-01-16 20:18
381 查看
https://vjudge.net/problem/UVA-514
#include<iostream> #include<stack> using namespace std; #pragma warning(disable:4996) int main(){ #ifdef _DEBUG //freopen("in", "r", stdin); //freopen("out", "wb", stdout); #endif // _DEBUG int N; while (cin >> N && N) { int a[1005]; while (cin >> a[0] && a[0]) { for (int i = 1; i < N; ++i) cin >> a[i]; bool _ok = 1; stack<int> sta; int x = 1; for (int i = 0; i < N; ++i) if (x <= a[i]) { while (x != a[i]) sta.push(x++); ++x; } else if (a[i] == sta.top()) sta.pop(); else { _ok = 0; break; } cout << (_ok ? "Yes" : "No") << endl; } cout << endl; } }
相关文章推荐
- 经典第六章 例题 6-2 UVA 514 Rails(栈的基础应用)
- 例题6-2 铁轨(Rails, ACM/ICPC CERC 1997, UVa 514)
- 算法竞赛入门经典第六章例题6-20 Ideal Path UVA - 1599
- 算法竞赛入门经典第六章例题6-5 Boxes in a Line UVA - 12657
- 算法竞赛入门经典第六章例题6-4 Broken Keyboard (a.k.a. Beiju Text) UVA - 11988
- 算法竞赛入门经典 UVa 514 Rails
- 算法竞赛入门经典第六章例题6-6 Dropping Balls UVA - 679
- 【例题 6-2 UVA - 514】Rails
- 算法竞赛入门经典第六章例题6-1 Concurrency Simulator UVA - 210
- 例题6-2 UVA 514 - Rails (铁轨)
- UVa-514-Rails
- Rails uva514
- 算法竞赛入门经典第五章例题5-6 Team Queue UVA - 540
- 算法竞赛入门经典第五章例题5-9 Database UVA - 1592
- UVa_514 - Rails
- 算法竞赛入门经典第六章例题6-7 Trees on the level UVA - 122
- 紫书第六章-----数据结构基础(例题6-20 Ideal Path UVA - 1599 )
- 紫书例题6-2 UVa 514 ( 栈
- UVA 514 Rails
- UVa 514: Rails