Kattis-Beekeeper

Posted 做一个AC梦

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Kattis-Beekeeper相关的知识,希望对你有一定的参考价值。

题目链接

Beekeeper – Kattis, Kattis

题目所述基本内容

It’s Bill the beekeeper again. In this problem, we learn that didn’t choose his career for the best reason. Bill chose to be a beekeeper because he really, really likes the look of the double e’s in the word “beekeeper”. Your task is to help identify other words Bill will really like.

 

Bill’s affinity for a word is determined by how many pairs of double vowels it has, where vowels are the letters a,e,i,o,u,y. Given a list of words, find the word that has the most pairs of double vowels, as it will be Bill’s favorite word.

Notes:

  • It is guaranteed that there will be a unique correct answer. That is, one word in the list will have strictly more pairs of vowels than all other words in the list.

  • No word in the input will have three or more of the same vowel consecutively, because that would just be too much for poor Bill.

输入输出样例

Input

The input will contain multiple test cases, up to 10. The first line of each case contains N, the number of words in that case (0<N≤1000). The next N lines will contain the words that make up that case. Each word will contain only lowercase English letters [a-z], and no word will be longer than 80 characters. Words will not necessarily be actual English words, but they will contain at least one letter. The input will be terminated by a line containing a single zero.

Output

For each case, print Bill’s favorite word. Each output should be printed on its own line.

Sample Input 1Sample Output 1
4
artist
engineer
beekeeper
programmer
3
bookkatt
jailaikia
yeehaaw
0
beekeeper
yeehaaw

METADATA

CPU Time limit1 second
Memory limit1024 MB
Difficulty2.7
StatisticsBeekeeper – Kattis, Kattis
AuthorNicholas Sharp
Source2014 Virginia Tech High School Programming Contest

代码

#include<iostream>
#include<vector>
#include<string>
#include<map>
using namespace std;
int main() 
	int count = 0;
	int choice = 0;
	string temp;
	map<int, string>ma;
	vector<string>res;
	while (cin >> choice) 
		if (choice == 0) 
			break;
		
		else 
			int max = count;
			for (int i = 0; i < choice; i++) 
				cin >> temp;
				for (int j = 0; j < temp.size(); j++) 
					if (temp[j] == 'a' || temp[j] == 'e' || temp[j] == 'i' || temp[j] == 'o' || temp[j] == 'u' || temp[j] == 'y') 
						if (temp[j] == temp[j + 1]&&temp[j+1]!=temp[j+2]) 
							count++;
						
					
				
				ma[count] = temp;
				if (count >max) 
					max = count;
				
				count = 0;
			
			res.push_back(ma[max]);
			ma.clear();
		
	
	for (int i = 0; i < res.size(); i++) 
		cout << res[i] << endl;
	
	return 0;


结束语
好兄弟好兄弟,留下你的关注和点赞,666走一波!!!!!

以上是关于Kattis-Beekeeper的主要内容,如果未能解决你的问题,请参考以下文章

关于基础微积分的结束语

关于基础微积分的结束语

关于基础微积分的结束语

关于基础微积分的结束语

youcans 的 OpenCV 例程200篇结束语

C#如何结束EXCEL进程