Intel Code Challenge Elimination Round (Div.1 + Div.2, combined) B. Verse Pattern 水题
2016-10-02 15:08
531 查看
B. Verse Pattern
题目连接:
http://codeforces.com/contest/722/problem/BDescription
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).Sample Input
32 2 3
intel
code
ch allenge
Sample Output
YESHint
题意
给你n个字符串,然后问你每个字符串里面是否恰好有p[i]个元音字母。如果都符合的话,输出yes,否则输出no
题解:
暴力去判断就好了代码
#include<bits/stdc++.h> using namespace std; const int maxn = 105; int p[maxn]; string s; int dp[2][maxn]; int main() { int now=0,pre=1; int n;scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",&p[i]); int flag = 1;getchar(); for(int i=1;i<=n;i++) { getline(cin,s); int k = 0; for(int j=0;j<s.size();j++) { if(s[j]=='a'||s[j]=='e'||s[j]=='i'||s[j]=='o'||s[j]=='u'||s[j]=='y') k++; } if(k!=p[i])flag=0; } if(flag)cout<<"YES"<<endl; else cout<<"NO"<<endl; }
相关文章推荐
- Intel Code Challenge Elimination Round (Div.1 + Div.2, combined) -- B. Verse Pattern(水题)
- Intel Code Challenge Elimination Round (Div.1 + Div.2, combined) A. Broken Clock 水题
- Intel Code Challenge Elimination Round (Div.1 + Div.2, combined) -- C. Destroying Array (并查集)
- Intel Code Challenge Elimination Round (Div.1 + Div.2, combined)E. Research Rover (容斥Lucas)
- Intel Code Challenge Elimination Round (Div.1 + Div.2, combined) C. Destroying Array -- 逆向思维
- 【Intel Code Challenge Elimination Round (Div1 + Div2, combined) B】【水题】Verse Pattern
- Intel Code Challenge Elimination Round (Div.1 + Div.2, combined) -- A. Broken Clock (贪心)
- Intel Code Challenge Elimination Round (Div.1 + Div.2, combined) D. Generating Sets 贪心+优先队列
- Intel Code Challenge Elimination Round (Div.1 + Div.2, combined)F. Cyclic Cipher
- Intel Code Challenge Elimination Round (Div.1 + Div.2, combined) C. Destroying Array 双向链表+反向做+优先队列
- Intel Code Challenge Elimination Round (Div.1 + Div.2, combined)(set容器里count函数以及加强for循环)
- Intel Code Challenge Elimination Round (Div.1 + Div.2, combined) D. Generating Sets __ dfs+优先队列+贪心
- Intel Code Challenge Elimination Round (Div.1 + Div.2, combined) E
- Intel Code Challenge Elimination Round (Div.1 + Div.2, combined) C. Destroying Array(并查集)
- Codeforces Intel Code Challenge Elimination Round (Div.1 + Div.2, combined) 部分题解
- Intel Code Challenge Elimination Round (Div.1 + Div.2, combined) C. Destroying Array
- Intel Code Challenge Elimination Round (Div.1 + Div.2, combined)
- Intel Code Challenge Elimination Round (Div.1 + Div.2, combined) F
- Intel Code Challenge Elimination Round (Div.1 + Div.2, combined) D. Generating Sets 贪心
- Intel Code Challenge Elimination Round (Div.1 + Div.2, combined) A B C D 水 模拟 并查集 优先队列