【栈】HDU1022Train Problem I
来源:互联网 发布:人工智能湖南论坛 编辑:程序博客网 时间:2024/06/04 00:43
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1022
#include<bits/stdc++.h>using namespace std;const int N=1050;int a[N],b[N],c[N];string s1,s2;int main(){ int n; while(cin>>n>>s1>>s2){ stack<int>st; memset(c,0,sizeof(c)); for(int i=0;i<s1.size();i++){ a[i]=s1[i]-'0'; b[i]=s2[i]-'0'; } int i=0,j=0; int k=0; int flag=0; while(i<n){ flag=0; if(!st.empty()&&st.top()==b[i]){ st.pop(); c[k++]=1; flag=1; i++; continue; } if(j<n){ st.push(a[j++]); c[k++]=0; flag=1; } if(flag==0) break; } if(i<n) cout<<"No."<<endl; else{ cout<<"Yes."<<endl; for(int i=0;i<2*n;i++){ if(c[i]) cout<<"out"<<endl; else cout<<"in"<<endl; } } cout<<"FINISH"<<endl; } return 0;}
阅读全文
0 0
- hdu1022Train Problem I(栈)
- 【栈】HDU1022Train Problem I
- hdu1022Train Problem I(栈-STL)
- HDU1022Train Problem I(栈的应用)
- hdu1022Train Problem I
- 思维体操: HDU1022Train Problem I
- hdu1022Train Problem I(栈的简单应用)
- Train Problem I 栈
- hdoj1022------------------Train Problem I---栈
- Train Problem I(栈)
- NYOJ150 Train Problem I 【栈】
- hdu Train Problem I (栈 )
- Train Problem I(栈)
- HDU1022--Train Problem I(栈)
- Problem I
- Problem I
- Problem I
- Problem I
- shell 脚本echo和printf学习
- react native学习笔记7——组件生命周期
- 【Unity与23种设计模式】代理模式(Proxy)
- A
- protect继承
- 【栈】HDU1022Train Problem I
- Java 并发学习
- mysql中utf8_bin、utf8_general_ci、utf8_general_cs编码区别
- 1002. 写出这个数
- 使用sklearn做特征工程
- nodejs探求事件环机制
- 2017 09 06 小结
- pat 乙级 1038. 统计同成绩学生(20)
- 洛谷 P3379 【模板】最近公共祖先(LCA)