hdu 1022 栈
久违的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; }