杭电1022 Train Problem I

/*********************************
* 日期:2011-3-12
* 作者:SJF
* 题号:杭电1022
* 题目:Train Problem I
* 结果:AC
* 题意:
* 总结:
**********************************/
#include<iostream>
#include<stack>
#include<string>
using namespace std;
int main( )
{
int N;
char train1[1002],train2[1002];
string mark[100];
while(scanf("%d",&N)!=EOF)
{
stack<char> s;
int i,j=0,k=0;
scanf("%s %s",train1,train2);
for(i=0;i<N;i++)//i train1 k train2 j mark
{
s.push(train1[i]);
mark[j++]="in";
while(!s.empty()&&s.top()==train2[k])
{
mark[j++]="out";
s.pop();
k++;
}
}
if(s.empty())
{
cout<<"Yes."<<endl;
for(i=0;i<j;i++)
cout<<mark[i]<<endl;
cout<<"FINISH"<<endl;
}
else
{
cout<<"No."<<endl;
cout<<"FINISH"<<endl;
}
}
return 0;
}

你可能感兴趣的:(in)