CodeForces 722B. Verse Pattern(模拟)
2016-11-29 20:03
447 查看
B. Verse Pattern
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
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 and 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 to n 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 3 syllables in the third one.
统计给出的字典中元音数量,并比对
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
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 and 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 to n 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 3 syllables in the third one.
统计给出的字典中元音数量,并比对
#include<iostream> #include<algorithm> #include<string.h> #include<stdio.h> #include<math.h> #include<vector> #include<queue> using namespace std; const int maxn=105; int num[maxn]; int flag[maxn]; char str[maxn]; int main() { int N; scanf("%d",&N); memset(num,0,sizeof(num)); for(int i=0;i<N;i++) scanf("%d",&num[i]); memset(flag,0,sizeof(flag)); getchar(); for(int i=0;i<N;i++) { memset(str,'\0',sizeof(str)); gets(str); // printf("%s\n",str); int len=strlen(str); for(int j=0;j<len;j++) { // printf("%c\n",str[i]); if(str[j]=='a'||str[j]=='e'||str[j]=='i'||str[j]=='o'||str[j]=='u'||str[j]=='y') flag[i]++; } } for(int i=0;i<N;i++) { // printf("%d %d\n",num[i],flag[i]); if(num[i]!=flag[i]) { printf("NO\n"); return 0; } } printf("YES\n"); return 0; }
相关文章推荐
- CodeForces - 754B Ilya and tic-tac-toe game(模拟)
- CodeForces - 668B Little Artem and Dance(模拟,思路)
- Codeforces - 834B. The Festive Evening - 思维、模拟
- CodeForces - 868B Race Against Time 简单模拟
- CodeForces 734D:Anton and Chess(模拟?)
- CodeForces 158 B. Taxi(模拟)
- CodeForces - 868B Race Against Time(模拟)
- Codeforces--615B--Longtail Hedgehog(贪心模拟)
- CodeForces 493C Vasya and Basketball(模拟 + 二分)
- CodeForces 611B New Year and Old Property(模拟)
- 【CodeForces 779A】Pupils Redistribution(模拟)
- codeforces 591B - Rebranding(模拟)
- Codeforces 438D (今日gg模拟第二题) | 线段树 考察时间复杂度的计算 -_-|||
- CodeForces - 630M Turn (模拟&技巧) 水
- codeforces - Tricky Sum(模拟)
- codeforces 26C Parquet 贪心 模拟
- CodeForces - 366A Dima and Guards (模拟) 水
- 【模拟】Codeforces 710B Optimal Point on a Line
- CodeForces - 858C【贪心+模拟】
- 二进制 模拟 codeforces 485C