bzoj 1622: [Usaco2008 Open]Word Power 名字的能量【模拟】
模拟即可,注意包含可以是不连续的
方便起见读入的时候全转成小写
#include<iostream>
#include<cstdio>
using namespace std;
const int N=1005;
int n,m,s1,s2,ans[N];
struct qwe
{
int len;
char s[N];
}c[N],p[N];
int main()
{
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)
{
scanf("%s",c[i].s);
while(c[i].s[c[i].len])
{
if(c[i].s[c[i].len]<'a')
c[i].s[c[i].len]=c[i].s[c[i].len]+32;
c[i].len++;
}
}
for(int i=1;i<=m;i++)
{
scanf("%s",p[i].s);
while(p[i].s[p[i].len])
{
if(p[i].s[p[i].len]<'a')
p[i].s[p[i].len]=p[i].s[p[i].len]+32;
p[i].len++;
}
}
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
{
s1=0,s2=0;
while(s1<c[i].len&&s2<p[j].len)
{
if(c[i].s[s1]==p[j].s[s2])
s2++;
s1++;
}
if(s2==p[j].len)
ans[i]++;
}
for(int i=1;i<=n;i++)
printf("%d\n",ans[i]);
return 0;
}
bzoj 1622: [Usaco2008 Open]Word Power 名字的能量【模拟】的更多相关文章
- BZOJ 1622: [Usaco2008 Open]Word Power 名字的能量
题目 1622: [Usaco2008 Open]Word Power 名字的能量 Time Limit: 5 Sec Memory Limit: 64 MB Submit: 349 Solved ...
- BZOJ——1622: [Usaco2008 Open]Word Power 名字的能量
http://www.lydsy.com/JudgeOnline/problem.php?id=1622 Description 约翰想要计算他那N(1≤N≤1000)只奶牛的名字的能量.每只 ...
- 1622: [Usaco2008 Open]Word Power 名字的能量
1622: [Usaco2008 Open]Word Power 名字的能量 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 370 Solved: 18 ...
- 【BZOJ】1622: [Usaco2008 Open]Word Power 名字的能量(dp/-模拟)
http://www.lydsy.com/JudgeOnline/problem.php?id=1622 这题我搜的题解是dp,我也觉得是dp,但是好像比模拟慢啊!!!! 1400ms不科学! 设f[ ...
- [Usaco2008 Open]Word Power 名字的能量
1622: [Usaco2008 Open]Word Power 名字的能量 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 408 Solved: 19 ...
- bzoj1622 [Usaco2008 Open]Word Power 名字的能量
Description 约翰想要计算他那N(1≤N≤1000)只奶牛的名字的能量.每只奶牛的名字由不超过1000个字待构成,没有一个名字是空字体串, 约翰有一张“能量字符串表”,上面有M(1 ...
- BZOJ_1622_[Usaco2008_Open]_Word_Power_名字的能量_(字符匹配_暴力)
描述 http://www.lydsy.com/JudgeOnline/problem.php?id=1622 给出多个文本串和模式串,求每个文本串中有多少模式串. 分析 直接暴力... #inclu ...
- 洛谷——P2908 [USACO08OPEN]文字的力量Word Power
P2908 [USACO08OPEN]文字的力量Word Power 题目描述 Farmer John wants to evaluate the quality of the names of hi ...
- 洛谷 P2908 [USACO08OPEN]文字的力量Word Power
P2908 [USACO08OPEN]文字的力量Word Power 题目描述 Farmer John wants to evaluate the quality of the names of hi ...
随机推荐
- 多光源 MultipleLight
使用2个Pass增加光照效果: 第一个Pass是基础光源,一般是第一个平行光:Tags{"LightMode" = "ForwardBase"} 第二个光源是增 ...
- JavaScript学习---简易图片轮播
效果如下: 图片定时轮播 点击左右控制显示下一张或上一张图片 index.html文件 <html> <head> <title> js编写实现幻灯片效果 < ...
- CodeForcesGym 100524J Jingles of a String
Jingles of a String Time Limit: 2000ms Memory Limit: 524288KB This problem will be judged on CodeFor ...
- 【中文排序】mysql order by 中文排序
1. 在MySQL中,我们经常会对一个字段进行排序查询,但进行中文排序和查找的时候,对汉字的排序和查找结果往往都是错误的. 这种情况在MySQL的很多版本中都存在. 如果这个问题不解决,那么MySQL ...
- [Spring] Properties for project configuration
We might have some project specific configuration need to setup. The good approach to do this in Spr ...
- STL非变易算法
非变易算法:原则上不会变更操作数据的算法. [1] for_each:逐个容器元素,原型for_each(InputIter first, InputIter last, Function f) ...
- python批量删除文件
敲代码測试时总会碰到要删除日志目录下的日志或者删除一些历史文件.每次都会生成,再測试的时候为了查找错误原因方便总是要在測试前删除这些文件.手动删除比較麻烦.所以写一个批量删除脚本 import os ...
- 一个最简单的Servlet实例
先在tomcat的webapps目录下,新建一目录,如test.然后,在test目录下建立WEB-INF为名的目录.这个必须有. 然后,在WEB-INF目录下建立classes目录.用以存储所用到的c ...
- lua遍历目录
require"lfs" function findindir (path, wefind, r_table, intofolder) for file in lfs.dir(pa ...
- Python3 读取和写入excel
https://blog.csdn.net/weixin_43094965/article/details/82226263一.Excel 1.Excel文件三个对象 workbook: 工作簿,一个 ...