太囧了,刚开始我居然把

        while(!s.empty()) s.pop();

        while(!q.empty()) q.pop();

写成了

        if(!s.empty()) s.pop();

        if(!q.empty()) q.pop();

害我WA了十多次,浪费了不少时间。

Problem : 1022 ( Train Problem I )     Judge Status : Accepted
RunId : 5628664 Language : C++ Author : ssun
Code Render Status : Rendered By HDOJ C++ Code Render Version 0.01 Beta

#include<cstdio>
#include<stack>
#include<queue>
#include<string>
#include<iostream>
using namespace std;

int main()
{
stack<char> s;
queue<string> q;
char s1[110],s2[110];
int n;
while(scanf("%d",&n)!= EOF)
{
//getchar();
while(!s.empty()) s.pop();
while(!q.empty()) q.pop();
scanf("%s%s",s1,s2);
//cout<<strlen(s1)<<endl;
//printf("%s\n%s",s1,s2);
int k=0;
int i=0;
while(i<=n)
{
if(!s.empty()&&s.top()==s2[k])
{
while(!s.empty()&&s.top()==s2[k])
{
s.pop();
q.push("out");
k++;
}
if(k>=n) break;
//i--;
}
else if(i==n) break;
else
{
s.push(s1[i]);
q.push("in");
i++;
}
}
if(k>=n)
{ puts("Yes.");
while(!q.empty())
{
cout<<q.front()<<endl;
q.pop();
}
}
else puts("No.");
puts("FINISH");
}
return 0;
}