首页 > Rails
头像 迟缓的小章鱼在打卡
发表于 2024-05-24 23:43:56
此题底层逻辑就是判断出栈序列是否合理,加上一些细节的处理。 ">using namespace std; int n; bool end(){/*end函数用来接收每一个入栈序列的总数, 若是0则直接跳过循环*/ cin >> n ; if (n) return true 展开全文
头像 在刷题的单身狗很开心
发表于 2023-09-10 21:01:38
就是查看出队序列合不合理罢了,只要和数组中的数一致按需出队即可。 #include <bits/stdc++.h> using namespace std; const int maxn = 100000+10 展开全文
头像 塞尔维亚的微光
发表于 2023-07-11 11:39:48
#题目链接:https://ac.nowcoder.com/acm/problem/14326 #题目描述: 输入正整数数字串,判断能否将一个顺序数字串通过入栈出栈操作得到该数字串。 输入:首先输入数据长度n,则之后的数据均为包含从1到n的所有数字的顺序随机的数字串。若输入一个元素仅为0的空串,则本 展开全文
头像 zhangjitong
发表于 2024-10-04 19:34:52
只需要纯模拟出栈即可,记得初始化哦 代码如下 #include<bits/stdc++.h> using namespace std; stack<int>sk; int a[100010]; int main(){ while(1){ int n;c 展开全文
头像 死于算法,生于算法
发表于 2021-11-03 11:45:28
输入格式可能会有点复杂 这个翻译过来大概就是依次输入1~n,然后给你一组出栈方式,判断是否合法 #include<iostream> #include<stack> using namespace std; const int N=1e5+10; int n; int a[N 展开全文
头像 xiaming
发表于 2023-04-22 18:22:39
题意 输入序列长度n 在栈中依次输入1、2、3 ... n 给你一组出栈方式,判断是否合法 Code Cpp #include <bits/stdc++.h> using namespace std; const int N = 1010; int n; int a[N], i 展开全文