HDOJ 1022 数据结构 栈
来源:互联网 发布:dns区域传输使用端口 编辑:程序博客网 时间:2024/06/05 11:07
没做51,做HD开始写博客了。结果谢了半天都是水题。尴尬,这道题其实说白了就是栈,o1是进栈的顺序,o2是要求的出栈的顺序,其实意思就是能不能按照那个顺序出栈。这题思路就是按照o1的进来,然后对着o2进行出栈操作,最后出完了就是YES,没出就是NO。
#include <iostream>#include <string.h>using namespace std ;typedef long long ll;const int MAX =1000050;struct{ char n[10]; int p;}note;char o1[9],o2[9];bool ans[20];int main(){ int n ; while(cin>>n){ cin>>o1>>o2; int p1=0,p2=0; note.p=1; int i = 1; while(i<=2*n){ if(note.n[note.p-1]==o2[p2]){ p2++; note.p--; ans[i]=false; }//出栈 else if(p1<n){ note.n[note.p++]=o1[p1++]; ans[i]=true; }//进栈 i++; } if(note.p==1){ cout<<"Yes."<<endl; for(int i = 1 ; i <= 2*n ; i++) if(ans[i]) cout<<"in"<<endl; else cout<<"out"<<endl; } else cout<<"No."<<endl; cout<<"FINISH"<<endl; } return 0;}
阅读全文
0 0
- HDOJ 1022 数据结构 栈
- [HDOJ 4879] ZCC loves march [模拟+数据结构]
- HDOJ 5296 Annoying problem LCA+数据结构
- HDOJ 1022
- ACM-HDOJ 1022 简单栈应用
- hdoj 1022 Train Problem I 【顺序栈】
- HDOJ 1022 Train Problem I(栈)
- HDOJ Train Problem I 1022(栈)
- HDOJ 1022 Train Problem I(简单栈)
- hdoj-1022-Train Problem I(栈)
- HDOJ 1022 Train Problem I(栈)
- hdoj 1022 Train Problem I【栈】
- hdoj 1022 Train Problem I(栈)
- HDOJ,杭电1237简单计算器。。。数据结构小练习。
- hdu 1022 hdoj 1022
- HDOJ-----1896栈
- HDOJ
- hdoj
- 从FAT16开始认识文件系统《第一讲 DBR肢解它,哼》
- Apache
- 新路程------imx6 sd卡部分摘要
- 深入理解 JavaScript 异步系列(2)—— jquery的解决方案
- JAVA中抽象类和接口的本质区别
- HDOJ 1022 数据结构 栈
- FCN&U-Net
- c++笔记
- 为什么有时我们需要配置hosts文件呢?(转载)
- Android Manifest文件详解
- 以太坊-挣脱数字货币的枷锁
- 如何通过for循环添加对象到集合(防止数据覆盖)
- 仿京东淘宝的秒杀倒计时实现
- 惠更斯Rothermel模型模拟-森林火灾-计算坐标(思路)