您的位置:首页 > 其它

hdu 1022 栈

2017-11-15 21:30 176 查看
久违的ac,真是艰难。第一次提交的竟然是直接判断b字符串是否为a的倒序。

#include<iostream>
#include<stack>
#include<string>
using namespace std;
int main()
{
int t;
string a,b;
while(cin>>t>>a>>b)
{
stack<char>s;
string p;
int i=0;
t=a.size();
while(t--)
{
s.push(a[a.size()-t-1]);
p+="in\n";//cout<<s.top()<<"   "<<b[i];
while(!s.empty()&&s.top()==b[i])
{
//cout<<"i"<<i<<endl;
s.pop();
p+="out\n";
i++;
//cout<<s.size()<<"!!"<<endl;
}
}
if(s.size()==0)
cout<<"Yes."<<endl<<p;
else
cout<<"No."<<endl;
cout<<"FINISH"<<endl;
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  string namespace