当前位置:网站首页>PAT甲级 1051 Pop Sequence
PAT甲级 1051 Pop Sequence
2022-08-02 23:51:00 【九是否非随机的称呼】
模拟stack
#include<iostream>
#include<vector>
#include<stack>
#include<bits/stdc++.h>
using namespace std;
int main(void){
int i, j, k, m, n, h, mm, nn;
cin>>m>>n>>h;
vector<int> vec[h];
for(i = 0; i < h; i++){
for(j = 0; j < n; j++){
cin>>k;
vec[i].push_back(k);
}
}
for(i = 0; i < h; i++){
stack<int> s;
int cnt = 0;
int num = 1;
while(s.size()<=m){
if(s.size() > 0 && s.top()==vec[i][cnt]){
s.pop();
cnt++;
}
else if(s.size() > 0 && num <=n && s.top()!=vec[i][cnt])
s.push(num++);
else if(s.size()==0 && num <=n)
s.push(num++);
else break;
}
if(s.size() > 0) cout<<"NO"<<endl;
else cout<<"YES"<<endl;
}
return 0;
}边栏推荐
猜你喜欢
随机推荐
Let's talk about the charm of code language
Heartwarming AI Review (1)
【问题征集】向 iPod 之父、iPhone 联合设计者、Google Nest 创始人 Tony Fadell 提问啦
HVV红队 | 渗透测试思路整理
nmap: Bad CPU type in executable
别再到处乱放配置文件了!我司使用 7 年的这套解决方案,稳的一秕
d实验新异常
【Leetcode】305.岛屿数量II(困难)
js基础知识整理之 —— 判断语句和三元运算符
5、Citrix云桌面初始化Storefront设置
机器学习-特征映射方法
scala 集合通用方法
RollBack Rx Professional RMC 安装教程
2022 Shandong International Youth Eye Health Industry Exhibition, Vision Health Exhibition, Optometry Exhibition
Day117. Shangyitong: Generate registered order module
pytest-常用运行参数
MySQL的多表查询(1)
js基础知识整理之 —— 五种输出方式
如何正确地配置入口文件?
6、Powershell命令配置Citrix PVS云桌面桌面注销不关机
https://github.com/ZouJiu1/PAT








