题目1366:栈的压入、弹出序列
来源:互联网 发布:二维码生成软件设备 编辑:程序博客网 时间:2024/06/05 18:30
#include <stdio.h> int n;int d[100001];int s[100001];int top;int ans; int main(){ int i, cd, t; while (scanf("%d", &n) != EOF) { for (i = 0; i < n; i++) scanf("%d", &d[i]); top = -1; cd = 0; ans = 1; for (i = 0; i < n; i++) { scanf("%d", &t); if (!ans) continue; while ((top == -1 || s[top] != t) && cd < n) s[++top] = d[cd++]; if (cd == n && s[top] != t) ans = 0; if (top == -1) ans = 0; top--; } puts(ans ? "Yes" : "No"); } return 0;} /************************************************************** Problem: 1366 User: cust123 Language: C++ Result: Accepted Time:270 ms Memory:1792 kb****************************************************************/
0 0
- 题目1366:栈的压入、弹出序列-九度
- 九度 题目1366:栈的压入、弹出序列
- 题目1366:栈的压入、弹出序列
- 题目1366:栈的压入、弹出序列
- 题目1366:栈的压入、弹出序列
- 题目1366:栈的压入、弹出序列
- 题目22:栈的压入、弹出序列
- 算法题目---栈的压入、弹出序列
- 1366栈的压入弹出序列
- 九度题目1366——栈的压入弹出序列
- 九度 OJ 题目1366:栈的压入、弹出序列
- 九度_题目1366:栈的压入、弹出序列
- 【剑指Offer面试编程题】题目1366:栈的压入、弹出序列--九度OJ
- 九度OJ-题目1366:栈的压入、弹出序列
- 栈的压入、弹出序列
- 栈的压入、弹出序列
- 栈的压入、弹出序列
- Q22:栈的压入、弹出序列
- 百度云应用基础版数据库连接
- R语言进行中文分词和聚类
- 取消后续事件
- LeetCoder 2. Add Two Numbers
- ZOJ 3963 Heap Partition(贪心)
- 题目1366:栈的压入、弹出序列
- php系统函数
- CSS三类写法
- 欢迎使用CSDN-markdown编辑器
- 模拟计算机计算源码、反码、补码(难度系数:1颗星)
- ZOJ 3960 What Kind of Friends Are You?(哈希)
- SpringBoot实战 之 入门篇
- 【笔记】formvalidtor中的ajaxValidator用法
- React-Native Fetch使用Promise封装(一)