zoukankan      html  css  js  c++  java
  • 【57.14%】【codeforces 722B】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 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.

    【题解】

    a,e,i,o,u,y被认为是元音字母。
    求一个字符串里面有x个元音字母。它就能被分成x个SMG;判断和所给的相不相同就可以了。

    #include <cstdio>
    #include <cstring>
    #include <iostream>
    #include <string>
    
    using namespace std;
    
    int a[200];
    string s;
    
    int main()
    {
        //freopen("F:\rush.txt", "r", stdin);
        int n;
        scanf("%d", &n);
        for (int i = 1; i <= n; i++)
            scanf("%d", &a[i]);
        getchar();
        for (int i = 1; i <= n; i++)
        {
            getline(cin, s);
            int len = s.size();
            int num = 0;
            for (int i = 0; i <= len - 1; i++)
                if (s[i] == 'a' || s[i] == 'i' || s[i] == 'e' || s[i] == 'o' || s[i] == 'u' || s[i] == 'y')
                    num++;
            if (num != a[i])
            {
                puts("NO");
                return 0;
            }
        }
        puts("YES");
        return 0;
    }
  • 相关阅读:
    mysql之触发器before和after的区别
    字段与属性的区别
    功能性和非功能性需求 UP中FURPS+模型需求分类方式
    脏读、不可重复读 共享锁、悲观锁 和 事务五种隔离级别
    抽象类、接口的区别 和 抽象类可以不实现接口的全部方法
    错误码:2003 不能连接到 MySQL 服务器在 (10061)
    在ubuntu下使用mysql API读取数据库的乱码问题
    vs2010下htmlcxx的编译以及环境的搭建
    effective c++ 条款15 在资源管理类中提供对原始资源的访问
    Qt 依赖包的加载
  • 原文地址:https://www.cnblogs.com/AWCXV/p/7632197.html
Copyright © 2011-2022 走看看