EKSPLOZIJA
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 45   Accepted: 12

Description

Mirko likes to play with strings of characters, but this time he has taken it too far – he put an “explosion” in the string! An explosion is a series of characters which, if found in the vicinity of fire, explodes and starts a chain reaction. Mirko, being as negligent as he usually is, forgot that his string contained an explosion and placed it near a candlelight. Thus the chain reaction began. The chain reaction takes place in the following way:

• if a string contains explosions, they all explode and a new string is formed by concatenating the pieces without the exploding parts

• this concatenation could possibly create new explosions

• the chain reaction repeats while there are explosions in the string

Now Mirko wants to know whether anything will be left after this series of chain reactions. If nothing remains, output “FRULA” (without quotes). If, by any chance, something is left, output the final string remaining after all the reactions.

Please note: The explosion will not contain two equal characters.

Input

The first line of input contains Mirko's string, (1 ≤ |Mirko's string| ≤ 1 000 000). The second line of input contains the explosion string, (1 ≤ |explosion| ≤ 36). Both Mirko's string and the explosion string consist of uppercase and lowercase letters of the English alphabet and digits 0, 1, … 9.

Output

The first and only line of output must contain the final string remaining after all the reactions as stated in the task.

Sample Input

12ab112ab2ab 12ab

Sample Output

FRULA

Hint

Firstly, the bombs on positions 1 and 6 explode. Then we are left with ****1****2ab (where * marks the character that exploded) and when that string is put together, we get 12ab. Sadly, that is an explosion all over again so it disappears.

这题就是给你两个字符串,问你字符串一里面把所有字符串都删除还剩下什么

我就是模拟栈做得。。

AC代码:

/* ***********************************************
Author        :yzkAccepted
Created Time  :2016/3/19 20:57:06
TASK          :。.cpp
LANG          :C++
************************************************ */#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <stack>
using namespace std;
typedef __int64 ll;
const int maxn=1000010;
char st[maxn],s[maxn],g[maxn];
char ans[maxn];
int main()
{int i,j,k;//freopen("in.txt","r",stdin);//freopen("out.txt","w",stdout);memset(s,0,sizeof(s));memset(st,0,sizeof(st));memset(g,0,sizeof(g));memset(ans,0,sizeof(ans));scanf("%s",s+1);int n=strlen(s+1);scanf("%s",g+1);int m=strlen(g+1);int rear=0;int flag=1;for(i=1;i<=n;i++){st[++rear]=s[i];if(rear>=m && st[rear]==g[m]){flag=1;for(j=1;j<=m;j++){if(st[rear-m+j]!=g[j]){flag=0;break;}}if(flag==1)rear-=m;}}for(i=1;i<=rear;i++)ans[i]=st[i];if(rear==0)printf("FRULA\n");elseprintf("%s\n",ans+1);return 0;
}

zjnu 1744 EKSPLOZIJA(模拟栈)相关推荐

  1. 六、使用数组模拟栈的思路及代码实现

    使用数组模拟栈的实现过程 1.栈的介绍 (1) 栈的英文为(stack) (2) 栈是一个先入后出(FILO-First In Last Out)的有序列表. (3) 栈(stack)是限制线性表中元 ...

  2. 第一回写的用arraylist模拟栈操作

    package hashMap; import java.util.ArrayList; import d.Student; /*** 用ArrayList模拟栈操作* @author zhujiab ...

  3. 032_使用ArrayDeque模拟栈结构

    import java.util.ArrayDeque; import java.util.Iterator;/*** 使用ArrayDeque模拟栈结构*/ public class DequeSt ...

  4. 数组模拟栈和队列板子

    使用数组模拟数据结构栈和队列 栈:后进先出 对于栈:我们使用tt表示栈顶的下标,如果tt==0表示栈空 队列:先进先出 对于队列,我们使用hh表示队首,tt表示队尾,tt初始化为-1,判断队列是否为空 ...

  5. Leetcode402 remove-k-digits贪心+vector模拟栈的思想

    题目 给定一个以字符串表示的非负整数 num,移除这个数中的 k 位数字,使得剩下的数字最小. 注意: num 的长度小于 10002 且 ≥ k. num 不会包含任何前导零. 示例 1 : 输入: ...

  6. CCF-CSP 201903-2 二十四点 Python语言 模拟栈实现

    项目场景: 二十四点问题本质是处理表达式,一提到处理表达式第一反应大概就是使用栈来处理,虽然网上大部分使用python语言处理二十四点问题都是利用强大的eval()函数,但我仍然想要使用python的 ...

  7. LinkedList 模拟栈和队列

    LinkedList 比ArrayList 提供了更多的方法,其中有两个方法可以实现栈和队列的操作. removeFirst() 移除并返回此列表中的第一个元素. removeLast() 移除并返回 ...

  8. Train Problem I(模拟栈)

    题意:模拟栈,试问使用2个栈,能否使得串1变为串2 思路:模拟,经典问题,注意只要相同的元素放到栈顶后就不会再移动了,只需要考虑剩下的元素,因此每次只考虑一个元素的进入方式. #include< ...

  9. eval?python顺序列表模拟栈实现计算器

    python顺序列表模拟栈实现计算器 借助list中的append和pop模拟顺序栈的入栈和出栈 instack = {'+':1,'-':1,'*':3,'/':3,'%':3,'(':6,')': ...

最新文章

  1. ASP.NET里的事务处理
  2. android 手机跑分,安兔兔安卓手机跑分性能榜公布:第一名实至名归?
  3. mysql三学习sql声明学习
  4. 如何在JUnit 5中替换规则
  5. macos降级_iOS12.3 beta2更新了什么 iOS12.3测试版2新特性与升降级方法
  6. Angular6_PWA
  7. java程序 计算器_简单计算器(java)
  8. Vue——this.$nextTick()
  9. Intel Sandy Bridge/Ivy Bridge架构/微架构/流水线 (20) - IvyBridge微架构
  10. 六省联考2017 Day1
  11. python学习点滴记录-Day14-前端基础之javascript
  12. 云服务器预装什么系统好,云服务器预装什么系统好
  13. itext实现PDF模板套打java,生成电子合同电子收据电子发票
  14. 盖洛普优势识别器2.0-《现在.发现你的优势》升级版
  15. Day 20 IOl流
  16. MSE(MeanSquaredError) loss 与 CE(CrossEntropyLoss) loss
  17. 关闭烦人的wps广告
  18. 「万物生长」一个APK从诞生到活跃在Android手机上,android驱动开发权威指南pdf
  19. python基础学习笔记——完结
  20. 软件企业双软认证的条件和好处是什么

热门文章

  1. linux函数脚本,linux 函数_linux常用脚本和函数
  2. 近期工作中遇到的问题及其解决办法
  3. 前端在线网页版表格是怎么开发的?教程来咯~~~
  4. Android开发中调用百度地图SDK
  5. javascript高级程序设计学笔记——第五章 引用类型
  6. 霓歌即时通讯中的相关专利整理(六)
  7. 【网络安全期末复习2】消息认证与数字签名的过程图与原理
  8. 网上复试,开学还要复核?深圳大学考研新通知!
  9. 解决:efi usb device has been blocked by the current security policy
  10. C++:类的静态成员变量及静态成员函数