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 ...
随机推荐
- Determine If Two Rectangles Overlap
判断相交的情况比较复杂,所以从判断不相交的角度考虑. ! (P1.y < P4.y || P1.x > P4.x || P2.y > P3.y || P2.x < P3.x)
- 【C++】基于socket的多线程聊天室(控制台版)
以前学习socket网络编程和多线程编程的时候写的一个练手程序 聊天室基本功能: 1.用户管理:登录,注册,登出,修改用户名,修改密码 2.聊天室功能:群聊,私聊,获取在线用户列表,获取所有用户列表 ...
- 9.PHP 教程_PHP运算符
PHP 运算符 在 PHP 中,赋值运算符 = 用于给变量赋值. 在 PHP 中,算术运算符 + 用于把值加在一起. PHP 算术运算符 运算符 名称 描述 实例 结果 x + y 加 x 和 y 的 ...
- [转]IOS 学习笔记(8) 滚动视图(UIScrollView)的使用方法
下面介绍pageControl结合ScrollView实现连续滑动翻页的效果,ScrollView我们在应用开发中经常用到,以g这种翻页效果还是很好看的,如下图所示: 通过这个例子,我们重点学习UIS ...
- 禁用Java DNS缓存-Disable DNS caching
Once an application has performed network access (i.e. urlconnection, parsing of xml document with e ...
- XML中SystemID和PublicID的区别
http://hi.baidu.com/binboot007/item/1533f91d52113d7c7b5f259c http://supportweb.cs.bham.ac.uk/documen ...
- android 百度最新地图sdk包怎么去除 放大缩小按钮
// 隐藏缩放控件 int childCount = mMapView.getChildCount(); View zoom = null; ; i < childCount; i++) { V ...
- 转:PAT练习题概览
AT(pat.zju.edu.cn)是一个面向 C/C++程序的 Online Judge 系统.相比 ZOJ,HDOJ,POJ 等 ACM 题库,PAT 的题目非常基础,对于数据结构.算法的入门是比 ...
- POJ 3228Gold Transportation(二分+最大流)
题目地址:POJ3288 这个题跟之前的一道题混了,感觉是一样的,所以连想都没怎么想就拆点然后求最短路然后二分求最大流了.结果连例子都只是,还一直以为又是哪里手残了..结果看了看例子,手算也确实不正确 ...
- nyoj-709-异形卵(水题)
异 形 卵 时间限制:1000 ms | 内存限制:65535 KB 难度: 描写叙述 我们探索宇宙,是想了解浩瀚星空的奥妙.但我们却非常少意识到宇宙深处藏匿的危急,它们无时无刻不紧盯着我们的地球 ...