1051. Pop Sequence (25)
2017-02-14 22:47
513 查看
根据序列模拟窄的压窄出窄情况
#include<iostream> #include<stack> #include<string> using namespace std; int main() { int M, N, K; cin >> M >> N >> K; string str; while (K--) { stack<int> sta; int i = 1; for (int t = 0;t < N;t++) { int temp; cin >> temp; while ((sta.empty()|| sta.top() != temp) && i <= N) sta.push(i++); if (sta.top() == temp && sta.size()<=M) sta.pop(); else { cout << "NO" << endl;getline(cin, str);break; } if (t == N - 1) { cout << "YES" << endl;break; } } } }
相关文章推荐
- 1051. Pop Sequence (25)
- 1051. Pop Sequence (25)
- 1051. Pop Sequence (25)
- 1051. Pop Sequence (25)
- 1051. Pop Sequence (25)
- 1051. Pop Sequence (25)
- 1051. Pop Sequence (25)
- 1051. Pop Sequence (25)
- PAT甲级真题及训练集(6)--1051. Pop Sequence (25)
- PAT - 甲级 - 1051. Pop Sequence (25)(模拟)
- PAT (Advanced Level) Practise 1051 Pop Sequence (25)
- 1051. Pop Sequence (25)
- 1051.Pop Sequence (25) PAT甲级刷题
- 1051. Pop Sequence (25)
- 1051.Pop Sequence (25)
- PAT (Advanced Level) Practise 1051 Pop Sequence (25)
- 1051. Pop Sequence (25)解题报告
- 1051. Pop Sequence (25)
- 1051. Pop Sequence (25)
- 1051. Pop Sequence (25)