• CodeForces 722B


    B. Verse Pattern

    time limit per test:1 second
    memory limit per test:256 megabytes
    input:standard input
    output:standard 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 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。

     1 //2016.10.1
     2 #include <iostream>
     3 #include <cstdio>
     4 #include <cstring>
     5 #define N 105
     6 
     7 using namespace std;
     8 
     9 int p[N];
    10 
    11 int main()
    12 {
    13     int n;
    14     string str;
    15     while(scanf("%d", &n)!=EOF)
    16     {
    17         bool fg = true;
    18         for(int i = 0; i < n; i++)
    19               scanf("%d", &p[i]);
    20         getchar();
    21         for(int j = 0; j < n; j++)
    22         {
    23             getline(cin, str);
    24             if(!fg)continue;
    25             int cnt = 0;
    26             for(int i = 0; i < str.length(); i++)
    27                   if(str[i]=='a'||str[i]=='e'||str[i]=='i'||str[i]=='o'||str[i]=='u' || str[i]=='y')cnt++;
    28             if(cnt!=p[j])fg = false;
    29         }
    30         if(fg)cout<<"YES"<<endl;
    31         else cout<<"NO"<<endl;
    32     }
    33 
    34     return 0;
    35 }
  • 相关阅读:
    yii2 模型查询使用计算值
    git回滚操作
    yii2 模型搜索时 or 条件查询
    从一台服务器发送文件到另一台服务器
    学习swoft的第三天_AOP切面
    C面试题汇总(转)
    秒杀多线程:多线程笔试面试题汇总(转)
    链表的常见操作(转)
    YAFFS跟踪
    libusb开发指南
  • 原文地址:https://www.cnblogs.com/Penn000/p/5927240.html
Copyright © 2020-2023  润新知