Translate

Views

Wednesday, July 20, 2022

Solution Kattis - Beekeeper


Link Problem: https://open.kattis.com/problems/beekeeper 


Submission 9153573

IDDATEPROBLEMSTATUSCPULANGTEST CASES
915357317:44:36Beekeeper
Accepted
0.00 sC++
2/2


Files submitted

beekeeper.cpp

#include<bits/stdc++.h>
using namespace std;
bool vowels(char x){
string s= "aeiouy";
for(int i=0; s[i]; i++)
if (s[i]==x) return true;
return false;
}
int f(string s){
int cnt= 0;
for(int i=0; s[i+1]; i++)
if (s[i]==s[i+1] && vowels(s[i])){
i++;
cnt++;
}
return cnt;
}
int main(){
int n;
while(cin >> n && n){
string res;
int MAX= -1; //0 => wa
for(int i=1; i<=n; i++){
string s; cin >> s;
if (f(s) > MAX){
MAX = f(s);
res= s;
}
}
cout<<res<<"\n";
}
}

No comments: