C - 白昼夢 / Daydream


Time limit : 2sec / Memory limit : 256MB

Score : 300 points

Problem Statement

You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S=T by performing the following operation an arbitrary number of times:

  • Append one of the following at the end of Tdreamdreamererase and eraser.

Constraints

  • 1≦|S|≦105
  • S consists of lowercase English letters.

Input

The input is given from Standard Input in the following format:

S

Output

If it is possible to obtain S=T, print YES. Otherwise, print NO.


Sample Input 1

erasedream

Sample Output 1

YES

Append erase and dream at the end of T in this order, to obtain S=T.


Sample Input 2

dreameraser

Sample Output 2

YES

Append dream and eraser at the end of T in this order, to obtain S=T.


Sample Input 3

dreamerer

Sample Output 3

NO

//给一个字符串,问,能否只通过加 dream dreamer erase eraser 这四个字符串得到
模拟就只要一重循环就够了,每次都确定连续的单词到底是什么,
 #include <stdio.h>
#include <string.h> char str [];
char dr[]="dream";
char er[]="erase"; int main()
{
while (scanf("%s",&str)!=EOF)
{
int len = strlen (str);
int i,ok=;
for (i=;i<len;i++)//dreameraser
{
if (str[i]=='d')
{
int j;
for (j=i;j<=i+;j++)
{
if (j>=len||dr[j-i]!=str[j])
{
ok=;
break;
}
}
if (j==i+)//是dream
{
i=j-;
if (str[j]=='e'&&str[j+]=='r'&&str[j+]!='a')
{
i=j+;
}
}
}
else if (str[i]=='e')
{
int j;
for (j=i;j<=i+;j++)
{
if (j>=len||er[j-i]!=str[j])
{
ok=;
break;
}
}
if (j==i+) //是erase
{
i=j-;
if (str[j]=='r') i=j;
else i=j-;
}
}
else ok=;
if (ok==) break;
}
if (ok==)
printf("YES\n");
else
printf("NO\n");
}
return ;
}


白昼夢 / Daydream(模拟)的更多相关文章

  1. 【AtCoder】ARC065

    ARC065 C - 白昼夢 / Daydream 直接递推就好 #include <bits/stdc++.h> #define fi first #define se second # ...

  2. DayDream, 移动VR 2.0里程碑: 概述(上篇)

    VR设备, 断断续续使用了很多个; 尤其是最近半年,主要是PC VR方面项目. 以前对移动VR不感冒,这几天试用了一下DayDream, 眼前突然一亮, 就如同年初首次使用HTC Vive眼前一亮的感 ...

  3. 关于Daydream VR的最直白的介绍

    虚拟现实(Virtual Reality),简称虚拟技术,也称虚拟环境,是利用电脑模拟产生一个三度空间的虚拟世界,提供用户关于视觉等感官的模拟,让用户如同身历其境一般,电脑可以立即进行复杂的运算,将精 ...

  4. csp-s模拟测试94

    csp-s模拟测试94 一场简单题,打爆了.$T1$脑抽分解质因数准备分子分母消,想了半天发现$jb$互质直接上天,果断码了高精滚蛋.$T2$无脑手玩大样例,突然灵光一闪想到映射到前$K$大小的区间, ...

  5. App开发:模拟服务器数据接口 - MockApi

    为了方便app开发过程中,不受服务器接口的限制,便于客户端功能的快速测试,可以在客户端实现一个模拟服务器数据接口的MockApi模块.本篇文章就尝试为使用gradle的android项目设计实现Moc ...

  6. 故障重现, JAVA进程内存不够时突然挂掉模拟

    背景,服务器上的一个JAVA服务进程突然挂掉,查看产生了崩溃日志,如下: # Set larger code cache with -XX:ReservedCodeCacheSize= # This ...

  7. Python 爬虫模拟登陆知乎

    在之前写过一篇使用python爬虫爬取电影天堂资源的博客,重点是如何解析页面和提高爬虫的效率.由于电影天堂上的资源获取权限是所有人都一样的,所以不需要进行登录验证操作,写完那篇文章后又花了些时间研究了 ...

  8. HTML 事件(四) 模拟事件操作

    本篇主要介绍HTML DOM中事件的模拟操作. 其他事件文章 1. HTML 事件(一) 事件的介绍 2. HTML 事件(二) 事件的注册与注销 3. HTML 事件(三) 事件流与事件委托 4.  ...

  9. 模拟AngularJS之依赖注入

    一.概述 AngularJS有一经典之处就是依赖注入,对于什么是依赖注入,熟悉spring的同学应该都非常了解了,但,对于前端而言,还是比较新颖的. 依赖注入,简而言之,就是解除硬编码,达到解偶的目的 ...

随机推荐

  1. Makefile中的“-I”(大写i),“-L”(大写l),“-l”(小写l)

    用gcc编译程序时,可能会用到“-I”(大写i),“-L”(大写l),“-l”(小写l)等参数, “-I”(大写i):表示包含头文件: “-L”(大写l):表示库文件目录: “-l”(小写l):表示链 ...

  2. ElasticSearch5.5.2常用命令

    1.启动 转到elasticsearch-5.5.2\bin目录: 打开命令行输入:elasticsearch 2.ELasticsearch集群已经启动并且正常运行 curl http://127. ...

  3. thrift.transport.TTransport.TTransportException: Could not start SASL: Error in sasl_client_start (-4) SASL(-4): no mechanism available: No worthy mechs found

    thrift.transport.TTransport.TTransportException: Could not start SASL: Error in sasl_client_start (- ...

  4. StreamingContext、DStream、Receiver深度剖析

    本课分成四部分讲解,第一部分对StreamingContext功能及源码剖析:第二部分对DStream功能及源码剖析:第三部分对Receiver功能及源码剖析:最后一部分将StreamingConte ...

  5. go语言25个关键字总结

    var和const :变量和常量的声明var varName type 或者 varName : = valuepackage and import: 导入func: 用于定义函数和方法return ...

  6. chown将指定文件的拥有者改为指定的用户或组(转)

    chown将指定文件的拥有者改为指定的用户或组,用户可以是用户名或者用户ID:组可以是组名或者组ID:文件是以空格分开的要改变权限的文件列表,支持通配符.系统管理员经常使用chown命令,在将文件拷贝 ...

  7. Android_编程规范与经常使用技巧

    一.Android编码规范 1.java代码中不出现中文,最多凝视中能够出现中文 2.局部变量命名.静态成员变量命名 仅仅能包括字母,单词首字母出第一个外.都为大写,其它字母都为小写 3.常量命名 仅 ...

  8. ROS库生成和调用

      参考资料: 生成.so文件:http://blog.csdn.net/u013243710/article/details/35795841 调用.so文件:http://blog.csdn.ne ...

  9. JavaScript匿名函数与托付

    <1> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <!-- C#匿名函数--& ...

  10. c#实现记事本

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...