博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
洛谷——P2908 [USACO08OPEN]文字的力量Word Power
阅读量:6329 次
发布时间:2019-06-22

本文共 2527 字,大约阅读时间需要 8 分钟。

P2908 [USACO08OPEN]文字的力量Word Power

题目描述

Farmer John wants to evaluate the quality of the names of his N (1 <= N <= 1000) cows. Each name is a string with no more than 1000 characters, all of which are non-blank.

He has created a set of M (1 <= M <= 100) 'good' strings (no

longer than 30 characters and fully non-blank). If the sequence letters of a cow's name contains the letters of a 'good' string in the correct order as a subsequence (i.e., not necessarily all next to each other), the cow's name gets 1 quality point.

All strings is case-insensitive, i.e., capital letters and lower case letters are considered equivalent. For example, the name 'Bessie' contains the letters of 'Be', 'sI', 'EE', and 'Es' in the correct order, but not 'is' or 'eB'. Help Farmer John determine the number of quality points in each of his cow's names.

约翰想要计算他那N(l < =N <= 1000)只奶牛的名字的能量.每只奶牛的名字由不超过1000个字 符构成,没有一个名字是空字体串.

约翰有一张“能量字符串表”,上面有M(1 < =M < =100)个代表能量的字符串.每个字符串 由不超过30个字体构成,同样不存在空字符串.一个奶牛的名字蕴含多少个能量字符串,这个名 字就有多少能量.所谓“蕴含”,是指某个能量字符串的所有字符都在名字串中按顺序出现(不 一定一个紧接着一个).

所有的大写字母和小写字母都是等价的.比如,在贝茜的名字“Bessie”里,蕴含有“Be” “si” “EE”以及“Es”等等字符串,但不蕴含“Ls”或“eB” .请帮约翰计算他的奶牛的名字 的能量.

输入输出格式

输入格式:

 

  • Line 1: Two space-separated integers: N and M

  • Lines 2..N+1: Line i+1 contains a string that is the name of the ith cow

  • Lines N+2..N+M+1: Line N+i+1 contains the ith good string

 

输出格式:

 

  • Lines 1..N+1: Line i+1 contains the number of quality points of the ith name

 

输入输出样例

输入样例#1: 
5 3 Bessie Jonathan Montgomery Alicia Angola se nGo Ont
输出样例#1: 
1 1 2 0 1

说明

There are 5 cows, and their names are "Bessie", "Jonathan", "Montgomery", "Alicia", and "Angola". The 3 good strings are "se", "nGo", and "Ont".

"Bessie" contains "se", "Jonathan" contains "Ont", "Montgomery" contains both "nGo" and "Ont", Alicia contains none of the good strings, and "Angola" contains "nGo".

 

模拟

挨个字符枚举判断

#include
#include
#include
#include
#define N 1010using namespace std;char ch[N][N],s[N];int n,m,k,l,len,ans[N];int read(){ int x=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9'){
if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar(); return x*f;}int work(char *s){ len=strlen(s); for(int i=1;i<=n;i++) { k=0;l=strlen(ch[i]); for(int j=0;j
>ch[i]; for(int i=1;i<=m;i++) cin>>s,work(s); for(int i=1;i<=n;i++) printf("%d\n",ans[i]); return 0;}

 

转载于:https://www.cnblogs.com/z360/p/8029437.html

你可能感兴趣的文章
SpringBoot 实战 (二) | 第一个 SpringBoot 工程详解
查看>>
Go goroutine理解
查看>>
IDE 插件新版本发布,开发效率 “biu” 起来了
查看>>
理解环境变量 JAVA_TOOL_OPTIONS
查看>>
看大牛是如何使用和理解线程池
查看>>
sql server 索引阐述系列八 统计信息
查看>>
c# Request对象(13)
查看>>
USB,蓝牙,以太网,还是WIFI?
查看>>
阿里云服务器更改时区为utc
查看>>
APP测试流程和测试点
查看>>
ansible实战
查看>>
PowerShell 远程管理之启用和执行命令
查看>>
mysql安装错误
查看>>
PHP中实现函数重载
查看>>
白宫电子邮件系统疑被黑:第一夫人护照信息被曝光
查看>>
站在物联网风口,传感器产业弯道超车?
查看>>
SQL Server-聚焦EXISTS AND IN性能分析(十六)
查看>>
使用oschina的git服务器图文流程 (转)
查看>>
国内物联网平台初探(一) ——百度物接入IoT Hub
查看>>
asp.net mvc中配置路由默认值(Area中)
查看>>