CodeForces 722B
B. Verse Pattern
You are given a text consisting of n lines. Each line contains some space-separated words, consisting of lowercase English letters.
We define a syllable as a string that contains exactly one vowel any arbitrary number (possibly none) of consonants. In English alphabet following letters are considered to be vowels: 'a', 'e', 'i', 'o', 'u' and 'y'.
Each word of the text that contains at least one vowel can be divided into syllables. Each character should be a part of exactly one syllable. For example, the word "mamma" can be divided into syllables as "ma" and "mma", "mam" and "ma", and "mamm" and "a". Words that consist of only consonants should be ignored.
The verse patterns for the given text is a sequence of n integers p1, p2, ..., pn. Text matches the given verse pattern if for each i from 1 ton one can divide words of the i-th line in syllables in such a way that the total number of syllables is equal to pi.
You are given the text and the verse pattern. Check, if the given text matches the given verse pattern.
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 100) — the number of lines in the text.
The second line contains integers p1, ..., pn (0 ≤ pi ≤ 100) — the verse pattern.
Next n lines contain the text itself. Text consists of lowercase English letters and spaces. It's guaranteed that all lines are non-empty, each line starts and ends with a letter and words are separated by exactly one space. The length of each line doesn't exceed 100 characters.
Output
If the given text matches the given verse pattern, then print "YES" (without quotes) in the only line of the output. Otherwise, print "NO" (without quotes).
Examples
input
3
2 2 3
intel
code
ch allenge
output
YES
input
4
1 2 3 1
a
bcdefghi
jklmnopqrstu
vwxyz
output
NO
input
4
13 11 15 15
to be or not to be that is the question
whether tis nobler in the mind to suffer
the slings and arrows of outrageous fortune
or to take arms against a sea of troubles
output
YES
Note
In the first sample, one can split words into syllables in the following way:
in-tel
co-de
ch al-len-ge
Since the word "ch" in the third line doesn't contain vowels, we can ignore it. As the result we get 2 syllabels in first two lines and 3syllables in the third one.
两个坑点,1.y也是元音 2.数出来的元音必须正好等于pi。
//2016.10.1
#include <iostream>
#include <cstdio>
#include <cstring>
#define N 105 using namespace std; int p[N]; int main()
{
int n;
string str;
while(scanf("%d", &n)!=EOF)
{
bool fg = true;
for(int i = ; i < n; i++)
scanf("%d", &p[i]);
getchar();
for(int j = ; j < n; j++)
{
getline(cin, str);
if(!fg)continue;
int cnt = ;
for(int i = ; i < str.length(); i++)
if(str[i]=='a'||str[i]=='e'||str[i]=='i'||str[i]=='o'||str[i]=='u' || str[i]=='y')cnt++;
if(cnt!=p[j])fg = false;
}
if(fg)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
} return ;
}
CodeForces 722B的更多相关文章
- CodeForces 722B Verse Pattern (水题)
题意:统计元音,这里多加一个元音,y. 析:直接统计就好了. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000" ...
- 【57.14%】【codeforces 722B】Verse Pattern
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- codeforces722B
Verse Pattern CodeForces - 722B You are given a text consisting of n lines. Each line contains some ...
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【Codeforces 738A】Interview with Oleg
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...
- CodeForces - 662A Gambling Nim
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...
- CodeForces - 274B Zero Tree
http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...
随机推荐
- PHP 代码跟踪
怎么知道代码的执行过程呢,也就是说怎么知道:是先执行哪些代码,然后执行哪些代码呢? 这里有一个非常犀利的函数,可以让你知道代码的执行过程 debug_backtrace() 函数. 来一段代码: L ...
- spring3mvc与struts2比较
目前企业中使用SpringMvc的比例已经远远超过Struts2,那么两者到底有什么区别,是很多初学者比较关注的问题,下面我们就来对SpringMvc和Struts2进行各方面的比较: 1. 核 心控 ...
- struts2-----新建项目
1. 建立界面原型 2. 建立Struts.xml 确定namespace, package, action, 空方法, result, 界面原型修改, 匹配现有设置, 测试, 做好规划 3. 建立数 ...
- SDOI2016 R1 解题报告 bzoj4513~bzoj4518
储能表 将n, m分解为二进制,考虑一个log(n)层的trie树,n会在这颗trie树上走出了一个路径,因为 行数 $ \le n$,所以在n的二进制路径上,每次往1走的时候,与m计算贡献,m同样处 ...
- MySQL的 explain 解析
EXPLAIN 的每个输出行提供一个表的相关信息,并且每个行包括下面的列: 项 说明 id MySQL Query Optimizer 选定的执行计划中查询的序列号.表示查询中执行 select 子句 ...
- Laravel Cache 使用
在项目中使用 laravel 的 cache 时,使用下面形式方法: $value = Cache::remember('users', $minutes, function() { return D ...
- Keil MDK下如何设置非零初始化变量(转)
源:Keil MDK下如何设置非零初始化变量 一些工控产品,当系统复位后(非上电复位),可能要求保持住复位前RAM中的数据,用来快速恢复现场,或者不至于因瞬间复位而重启现场设备.而keil mdk在默 ...
- NSURL 子串截取
NSURL *url = [NSURL URLWithString:@"http://reg.email.163.com/unireg/call.do?cmd=register.entran ...
- 部署项目时遇到的问题---IIS7.X配置ASP.NET MVC4
1.安装.NET Frameword4.0框架.如果先装IIS后装4.0框架的话,要在IIS注册4.0框架.具体方法见下图 .NET框架版本请根据操作系统版本自行选择.注册完后,在“ISAPI和CGI ...
- matlab获取向量中出现次数最多的元素
向量X 1. tabulate(X) 返回一个矩阵:第一列为元素值,第二列为相应元素出现个数,第三列为相应元素个数占所有元素个数百分比 table = tabulate(X); %获取出现次数最多的元 ...