这道题是道简单的栈模拟题,只要按照真实情况用栈进行模拟即可:

  1. #include<stdio.h>
  2. #include<string.h>
  3. #include<stack>
  4. using namespace std;
  5. int main()
  6. {
  7. int n, i, j, k, flag[];
  8. char s1[], s2[];
  9. stack <char> s;
  10. while(~scanf("%d %s%s",&n,s1,s2))
  11. {
  12. while(!s.empty()) s.pop(); //也可以不写这一句,把 stack <char> s; 就可以了
  13. memset(flag,-,sizeof(flag));
  14. j = k = ;
  15. for(i = ; i < n; i++)
  16. {
  17. s.push(s1[i]);
  18. flag[k++] = ;
  19. while(!s.empty() && s.top() == s2[j])
  20. {
  21. flag[k++] = ;
  22. s.pop();
  23. j++;
  24. }
  25. }
  26. if(j == n)
  27. {
  28. printf("Yes.\n");
  29. for(i = ; i < k; i++)
  30. {
  31. if(flag[i])
  32. printf("in\n");
  33. else
  34. printf("out\n");
  35. }
  36. }
  37. else
  38. printf("No.\n");
  39. printf("FINISH\n");
  40. }
  41. return ;
  42. }

hdu Train Problem I的更多相关文章

  1. hdu Train Problem I(栈的简单应用)

    Problem Description As the new term comes, the Ignatius Train Station is very busy nowadays. A lot o ...

  2. HDU Train Problem I (STL_栈)

    Problem Description As the new term comes, the Ignatius Train Station is very busy nowadays. A lot o ...

  3. HDU Train Problem I 1022 栈模拟

    题目大意: 给你一个n 代表有n列 火车,  第一个给你的一个字符串 代表即将进入到轨道上火车的编号顺序, 第二个字符串代表的是 火车出来之后到顺序, 分析一下就知道这,这个问题就是栈, 先进后出吗, ...

  4. HDU 1022 Train Problem I

    A - Train Problem I Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u ...

  5. hdu 1023 Train Problem II

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1212 Train Problem II Description As we all know the ...

  6. HDU 1022 Train Problem I(栈的操作规则)

    传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1022 Train Problem I Time Limit: 2000/1000 MS (Java/Ot ...

  7. Train Problem I 分类: HDU 2015-06-26 11:27 10人阅读 评论(0) 收藏

    Train Problem I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  8. Hdu 1022 Train Problem I 栈

    Train Problem I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  9. HDU 1022.Train Problem I【栈的应用】【8月19】

    Train Problem I Problem Description As the new term comes, the Ignatius Train Station is very busy n ...

随机推荐

  1. ts tp 高清播放软件 Elecard MPEG Player 6.0.130827

    Elecard MPEG Player 6.0.130827 计算机配置不高的情况下,流畅播放高清视频. 缺点是搜索时停顿严重. 包里有注册机. 下载地址 http://pan.baidu.com/s ...

  2. DP:Bridging Signals(POJ 1631)

    不能交叉的引脚 (这一题的难度在于读题)题目大意:有一堆引脚(signals),左边一排,右边一排,左边从上到下,对应着连接右边的引脚(所有的引脚都被接上),现在引脚之间的连线有交叉,我们要桥接这些交 ...

  3. 获取4G以上的文件大小

    1.DWORD dwFileSizeHigh;  // 得到文件大小的高位  __int64 qwFileSize = GetFileSize(m_hSrcBigFile, &dwFileSi ...

  4. android 实现自定义卫星菜单

    看了hyman老师的视频,听起来有点迷糊,所以就想把实现卫星菜单的实现总结一下.长话短说,下面总结一下: 一.自定义ViewGroup1).自定义属性文件 属性的定义: <attr name=& ...

  5. mysql多实例(个人的情况,不是大众的)里面有配置好的脚本+主从复制

    [root@DB-S ~]# ll /usr/local/|grep mysql lrwxrwxrwx. 1 root root 21 Jun 14 01:52 mysql -> /alidat ...

  6. ubuntu 彻底删除卸载

    1911 sudo apt-get install zabbix-agent 1916 sudo apt-get autoremove zabbix_agent root@(none):~# apt- ...

  7. 菜鸟学Linux命令:find命令 查找文件

    find命令是Linux下最常用的命令之一,灵活的使用find命令,你会发现查找文件变得十分简单. 命令格式 find [指定查找目录]  [查找规则(选项)]  [查找完后执行的动作] 参数规则 - ...

  8. Android打Path的方法

    转自:http://blog.csdn.net/xiangzi10/article/details/42710099 作为程序员,了解diff&patch命 令是非常必要的.比如说我们发现某个 ...

  9. Sql server之路 (五)插入多条数据

    public bool GetDataUsingDataTaskReason(StationReasonCollection reason) { try { strCon.Open(); DateTi ...

  10. hdu 3183 贪心

    题意:给一个数字,删掉其中的若干位,使得最后的数字最小 就是每次删除数的时候都是删掉第一个比右边数大的数 利用双向链表模拟 #include<cstdio> #include<ios ...