qq_40646477
2017-11-16 11:54hdu 1022自己试了好多数据,极端数据也试了,可是就是WA,求指教
10#include
#include
using namespace std;
int main()
{
int i,j,k,n,l;
int s[20]={0};
char str1[10];char str2[10];
stack train_station;
while(cin>>n>>str1>>str2)
{
for(k=0;k<20;k++)
{
s[k]=0;
}
i=0;j=0;k=0;l=2*n;
while(l)
{
if(k==0)
{
train_station.push(str1[i++]);
s[k++]=1;
}
else
{
if(!(train_station.empty())&&train_station.top()==str2[j])
{
train_station.pop();
j++;
s[k++]=2;
}
else
{
if(i!=n)
{train_station.push(str1[i++]);
s[k++]=1;}
}
}
l--;
}
if(i==n&&j==n)
{
cout<<"Yes."<<endl;
for(int a=0;a<20;a++)
{
if(s[a]==1)
{cout<<"in"<<endl;}
if(s[a]==2)
{cout<<"out"<<endl;}
}
cout<<"FINISH"<<endl;
}
if(i==n&&j<n)
{
cout<<"No."<<endl;
cout<<"FINISH"<<endl;
}
}
return 0;
}
- 点赞
- 回答
- 收藏
- 复制链接分享
2条回答
为你推荐
- 遮挡判断
- x
- 数据
- 2个回答
- HDU CakeMan
- lines
- as
- numbers
- 地图
- each
- 1个回答
- hdu 2032之前还是好好的杨晖三角,后来数据就不对了。
- hdu
- c
- 杨辉三角
- oj
- 3个回答
- hdu 2054问题求解,直接比较
- c
- oj
- 2个回答
- Stern-Brocot Tree
- c
- 编程
- 测试
- 数据
- 2个回答