2295: 【POJ Challenge】我爱你啊

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 126  Solved: 90
[Submit][Status]

Description

ftiasch是个十分受女生欢迎的同学,所以她总是收到许多情书。虽然她十分有魅力,然而她却是个低调的人。因此她从来不会告诉别人她到底收到了多少情书。

ftiasch的好朋友1tthinking想知道她到底收到了多少情书。1tthinking知道,ftiasch每次收到一封情书,就会在日记
最后写下一个包含"luvletter"子序列的串。比如现在ftiasch的日记是alduddvdletterflusvletetedr,那么
ftiasch可能受到了0、1、2封情书。现在给出一些ftiasch的日记,问对于每篇日记,ftiasch最多可能受到多少的情书。

某个序列的子序列是从最初序列通过去除某些元素但不破坏馀下元素的相对位置而形成的新序列。參考wikipedia

Input

第1行,一个整数 T (0 ≤ T ≤ 100), 日记的数量。

第2到 T + 1行,ftiasch的日记 (只包含'a'-'z' 和空格, 长度小于100001)

Output

第1到T行,一个整数, 最大可能的情书数量。

Sample Input

5
t
llllluvletterrr
luvletterlauavalaeatataearaluvletter
is wzk a famous boy yes buz he always receives a lot of luv letters
my heart beats her waves at the shore of the world and writes upon it her signature in tears with the words i love thee

Sample Output

0
1
3
1
0

HINT

Source

题解:
给题面点个赞!
刚开始看成DP了,后来发现直接模拟匹配就可以了。。。
代码:

 #include<cstdio>

 #include<cstdlib>

 #include<cmath>

 #include<cstring>

 #include<algorithm>

 #include<iostream>

 #include<vector>

 #include<map>

 #include<set>

 #include<queue>

 #include<string>

 #define inf 1000000000

 #define maxn 100000

 #define maxm 500+100

 #define eps 1e-10

 #define ll long long

 #define pa pair<int,int>

 #define for0(i,n) for(int i=0;i<=(n);i++)

 #define for1(i,n) for(int i=1;i<=(n);i++)

 #define for2(i,x,y) for(int i=(x);i<=(y);i++)

 #define for3(i,x,y) for(int i=(x);i>=(y);i--)

 #define mod 1000000007

 using namespace std;

 inline int read()

 {

     int x=,f=;char ch=getchar();

     while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}

     while(ch>=''&&ch<=''){x=*x+ch-'';ch=getchar();}

     return x*f;

 }
char s[]="luvletter";
int f[]; int main() { freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); int cs=read();
while(cs--)
{
char ch=' ';int now=,ans=;
while((ch<='z'&&ch>='a')||(ch==' '))
{
ch=getchar();
if(ch==s[now]){now++;if(now==)now=,ans++;}
}
printf("%d\n",ans);
} return ; }

BZOJ2295: 【POJ Challenge】我爱你啊的更多相关文章

  1. BZOJ 2295: [POJ Challenge]我爱你啊

    由于是子序列,那么难度就在于读入 #include<cstdio> #include<algorithm> #include<cstring> using name ...

  2. bzoj2295【POJ Challenge】我爱你啊*

    bzoj2295[POJ Challenge]我爱你啊 题意: 求一个字符串中有多少个"luvletter"(不包括引号).字符串长度≤100000. 题解: 连kmp都不用…… ...

  3. bzoj 2295: 【POJ Challenge】我爱你啊

    2295: [POJ Challenge]我爱你啊 Time Limit: 1 Sec  Memory Limit: 128 MB Description ftiasch是个十分受女生欢迎的同学,所以 ...

  4. 【链表】BZOJ 2288: 【POJ Challenge】生日礼物

    2288: [POJ Challenge]生日礼物 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 382  Solved: 111[Submit][S ...

  5. BZOJ2288: 【POJ Challenge】生日礼物

    2288: [POJ Challenge]生日礼物 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 284  Solved: 82[Submit][St ...

  6. BZOJ2293: 【POJ Challenge】吉他英雄

    2293: [POJ Challenge]吉他英雄 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 80  Solved: 59[Submit][Stat ...

  7. BZOJ2287: 【POJ Challenge】消失之物

    2287: [POJ Challenge]消失之物 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 254  Solved: 140[Submit][S ...

  8. BZOJ2296: 【POJ Challenge】随机种子

    2296: [POJ Challenge]随机种子 Time Limit: 1 Sec  Memory Limit: 128 MBSec  Special JudgeSubmit: 114  Solv ...

  9. BZOJ2292: 【POJ Challenge 】永远挑战

    2292: [POJ Challenge ]永远挑战 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 513  Solved: 201[Submit][ ...

随机推荐

  1. Tomcat6.0数据库连接池配置

    http://blog.163.com/magicc_love/blog/static/185853662201111101130969/ oracle驱动包Tomcat 6.0配置oracle数据库 ...

  2. ubuntu网络连接图标不显示

    sudo emacs /etc/NetworkManager/nm-system-settings.conf 将managed的值改为true,保存退出. sudo service network-m ...

  3. win向linux传文件

    使用pscp.exe即可. 下载pscp.exe(http://pan.baidu.com/s/1jG6zmx4) 复制到windows/system32目录下即可. 然后可在cmd命令行下使用psc ...

  4. PeekMessage

    PeekMessage是一个Windows API函数.该函数为一个消息检查线程消息队列,并将该消息(如果存在)放于指定的结构. 1 语法 BOOL PeekMessage( LPMSG IpMsg, ...

  5. Android开发环境搭建(2015年8月更新)

    1.  下载和安装Android SDK Android的官方站点是http://www.android.com: 登录https://developer.android.com/intl/zh-cn ...

  6. JS中(function(){xxx})(); 这种写法是什么意思?

    自执行匿名函数: 常见格式:(function() { /* code */ })(); 解释:包围函数(function(){})的第一对括号向脚本返回未命名的函数,随后一对空括号立即执行返回的未命 ...

  7. jQuery表格操作

    $("#tableid tr:gt(0)").each(function(i){ $(this).children("td").each(function(j) ...

  8. node.js 小爬虫 imooc 2016.03.06

    爬虫目标:获取http://www.imooc.com/learn/348网页中的章节标题和视频信息. var http = require('http'); var cheerio = requir ...

  9. bzoj1901:Zju2112 Dynamic Rankings

    思路:树套树,我写了两种,一种是线段树套splay,线段树维护区间信息,splay维护第k大,一种是树状数组套权值线段树(并不是什么可持久化线段树,只不过是动态开点罢了,为什么网上一大堆题解都是可持久 ...

  10. itoa 和_itoa_s

    1> itoa, 将整数转换为字符串. char *  itoa ( int value, char * buffer, int radix ); 它包含三个参数: value, 是要转换的数字 ...