HDUOJ Train Problem I
2015-08-02 09:38
281 查看
#include<stdio.h>
#include<string.h>
#include<stack>
using namespace std;
stack<char> str;
char s1[9],s2[9];
int main()
{
int n;
str.push('#');
while(~scanf("%d %s %s",&n,s1,s2))
{
while(str.top()!='#')
str.pop();
int l=0,i;
for(i=0;i<n;i++)
{
str.push(s1[i]);
if(str.top()==s2[l])
{
while(str.top()==s2[l])
{
str.pop();
l++;
}
}
}
if(str.top()=='#')
{
printf("Yes.\n");
l=0;
for(i=0;i<n;i++)
{
if(str.top()!=s2[l])
{
str.push(s1[i]);
printf("in\n");
if(str.top()==s2[l])
{
while(str.top()==s2[l])
{
str.pop();
printf("out\n");
l++;
}
}
}
}
printf("FINISH\n");
}
else printf("No.\nFINISH\n");
}
return 0;
}
#include<stdio.h>
#include<string.h>
#include<stack>
using namespace std;
stack<char> str;
char s1[9],s2[9];
int main()
{
int n;
str.push('#');
while(~scanf("%d %s %s",&n,s1,s2))
{
while(str.top()!='#')
str.pop();
int l=0,i;
for(i=0;i<n;i++)
{
str.push(s1[i]);
if(str.top()==s2[l])
{
while(str.top()==s2[l])
{
str.pop();
l++;
}
}
}
if(str.top()=='#')
{
printf("Yes.\n");
l=0;
for(i=0;i<n;i++)
{
if(str.top()!=s2[l])
{
str.push(s1[i]);
printf("in\n");
if(str.top()==s2[l])
{
while(str.top()==s2[l])
{
str.pop();
printf("out\n");
l++;
}
}
}
}
printf("FINISH\n");
}
else printf("No.\nFINISH\n");
}
return 0;
}
相关文章推荐
- 如何减少浏览器repaint和reflow ?
- wait 和 sleep的区别
- 2015 Multi-University Training Contest 4(hdu 5327 - hdu 5338)
- Rails 极简入门笔记
- Aircrack-ng 简单的WEP加密破解(下)
- ZOJ_1012_Mainframe
- 24. Navigator taintEnabled() 方法
- 查看文件常用指令cat,tac,nl,more,less,head,tail,od
- 2015 Multi-University Training Contest 3(hdu 5324 - Boring Class)树套树
- 多线程使用信号量sem_init,sem_wait,sem_post
- [leetcode 70]Climbing Stairs
- 开发并调试 Mail Add-in
- main Thread ,worker Thread
- Failed to read candidate component class
- Container With Most Water
- opencv源码分析(一):imread、cvLoadImage、waitKey、imshow函数
- Aircrack-ng 简单的WEP加密破解(上)
- 2015 Multi-University Training Contest 4(hdu5334 - Virtual Participation)数学
- HDU 2473 Junk-Mail Filter (并查集节点删除)
- activity_main cannot be resolved or is not a field