BZOJ 1622: [Usaco2008 Open]Word Power 名字的能量
题目
1622: [Usaco2008 Open]Word Power 名字的能量
Time Limit: 5 Sec Memory Limit: 64 MB
Submit: 349 Solved: 168
[Submit][Status]
Description
Input
Output
Sample Input
Bessie
Jonathan
Montgomery
Alicia
Angola
se
nGo
Ont
INPUT DETAILS:
There are 5 cows, and their names are "Bessie", "Jonathan",
"Montgomery", "Alicia", and "Angola". The 3 good strings are "se",
"nGo", and "Ont".
Sample Output
1
2
0
1
OUTPUT DETAILS:
"Bessie" contains "se", "Jonathan" contains "Ont", "Montgomery" contains
both "nGo" and "Ont", Alicia contains none of the good strings, and
"Angola" contains "nGo".
题解
暴力就可以了。
代码
/*Author:WNJXYK*/
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
using namespace std; #define LL long long
#define Inf 2147483647
#define InfL 10000000000LL inline void swap(int &x,int &y){int tmp=x;x=y;y=tmp;}
inline void swap(LL &x,LL &y){LL tmp=x;x=y;y=tmp;}
inline int remin(int a,int b){if (a<b) return a;return b;}
inline int remax(int a,int b){if (a>b) return a;return b;}
inline LL remin(LL a,LL b){if (a<b) return a;return b;}
inline LL remax(LL a,LL b){if (a>b) return a;return b;} string name[1001];
string power[101];
int ans[1001];
int n,m;
inline char upcase(char x){
if ('a'<=x && x<='z') return x-'a'+'A';
return x;
}
inline int judge(int x,int y){
int lx=power[x].length()-1,ly=name[y].length()-1;
for (int i=0;i<=ly-lx;i++){
bool flag=true;
int now=i;
if (upcase(name[y][i])==upcase(power[x][0]))
for (int j=1;j<=lx;j++){
now++;
while(now<=ly && upcase(power[x][j])!=upcase(name[y][now])) now++;
if (now>ly) {
flag=false;
break;
}
}
else
continue;
if (flag) return 1;
}
return 0;
}
int main(){
scanf("%d%d",&n,&m);
for (int i=1;i<=n;i++) cin>>name[i];
for (int j=1;j<=m;j++) cin>>power[j];
for (int i=1;i<=m;i++){
for (int j=1;j<=n;j++){
ans[j]+=judge(i,j);
}
}
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 名字的能量
http://www.lydsy.com/JudgeOnline/problem.php?id=1622 Description 约翰想要计算他那N(1≤N≤1000)只奶牛的名字的能量.每只 ...
- bzoj 1622: [Usaco2008 Open]Word Power 名字的能量【模拟】
模拟即可,注意包含可以是不连续的 方便起见读入的时候全转成小写 #include<iostream> #include<cstdio> using namespace std; ...
- 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 ...
随机推荐
- linux 之进程间通信-------------InterProcess Communication
进程间通信至少可以通过传送打开文件来实现,不同的进程通过一个或多个文件来传递信息,事实上,在很多应用系统里,都使用了这种方法.但一般说来,进程间 通信(IPC:InterProcess Communi ...
- .Net之一般处理程序
1.一般处理程序是什么? 答:一般处理程序是以.ashx结尾的文件,默认命名为Handler1.ashx. 用在Web项目中,也就是我们常说的网站项目. 2.新建一个一般处理程序 1.1 新建一个空网 ...
- Visual Studio 继续并运行上次的成功生成,未提示直接运行上一个版本解决方案!
Visual Studio ==>工具 ==> 选项==>项目和解决方案 ==>生成并运行_运行时,当出现生成或部署错误时_选择,提示启动
- mac outlook无法发送邮件
工具-帐户 第一步把SSL钩挑上 第二步 下面的更多选项,验证选择“使用接收服务器信息” 搞定了!记得个赞!
- BZOJ 3224: Tyvj 1728 普通平衡树(BST)
treap,算是模板题了...我中间还一次交错题... -------------------------------------------------------------------- #in ...
- 5.6.3.8 fromCharCode()方法
String构造函数本身还有一个静态方法:fromCharCode().这个方法的任务是接收一或多个字符编码,然后将它们转换成一个字符.从本质上来看,这个方法与实例方法charCodeAt()执行的是 ...
- 创建txt格式文本日志
公共方法(可以将其放到类库里边): #region 记录日志 #region 写日志 /// <summary> /// 写日志 /// </summary> /// < ...
- LNMP 基于域名的虚拟主机配置 (Centos5.6)
. . server { listen ; #listen [::]: default_server ipv6only=on; server_name www.blog.com; index inde ...
- 全新安装mysql最新版本
写在前面: 下面写的东西只是最近安装的一个说明,是在系统中没存在mysql的情况下安装的,后期会根据官方文档写一个详细有价值的文档 安装原理:利用mysql官方的mysql_apt-repositor ...
- squid客户端命令
常用squid客户端命令: squidclient -p mgr:info #取得squid运行状态信息: squidclient -p mgr:mem #取得squid内存使用情况: squidcl ...