当前位置:网站首页>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;
}
边栏推荐
猜你喜欢
随机推荐
如何使用vlookup+excel数组公式 完成逆向查找?
关于地图GIS开发事项的一次实践整理(上)
机器学习-特征映射方法
Rasa 3.x 学习系列- Rasa - Issues 4792 socket debug logs clog up debug feed学习笔记
Nacos配置中心之事件订阅
程序员英语自我介绍
js显示隐藏手机号
Teach you to locate online MySQL slow query problem hand by hand, package teaching package meeting
d合并json
主流定时任务解决方案全横评
js基础知识整理之 —— 闭包
十三、数据回显
【系统架构设计师】第三章 数据库系统
Carefully organize 16 MySQL usage specifications to reduce problems by 80% and recommend sharing with the team
Introduction to resubmit Progressive Anti-Duplicate Submission Framework
最近公共祖先(LCA)学习笔记 | P3379 【模板】最近公共祖先(LCA)题解
智能合约安全-可重入攻击(SW107-Reentrancy)
TensorFlow学习记录(一):基本介绍
Test | ali internship 90 days in life: from the perspective of interns, talk about personal growth
Auto.js 特殊定位控件方法 不能在ui线程执行阻塞操作,请使用setTimeout代替