Created
May 5, 2023 04:14
-
-
Save jiyometrik/575de57438c8b2df60c806fae1ab7605 to your computer and use it in GitHub Desktop.
a solution for the 2023 ec3 beginner competitive programming final contest's problem A: conlanging in c++.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
bool vowel(char a) { | |
return a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u' || a == 'y'; | |
} | |
int main() { | |
ios_base::sync_with_stdio(0); | |
cin.tie(0); | |
int n; string s; int ans = 0; | |
cin >> n >> s; | |
string w; | |
for (int i = 0; i < n; i++) { | |
bool flag = 0; | |
cin >> w; | |
if (w.size() != s.size()) continue; // if the sizes don't match then go on to the next word | |
for (int y = 0; y < s.size(); y++) { // loop through syllable structure | |
if (s[y] == 'V' && !vowel(w[y])) flag = 1; // if there's supposed to be a vowel but it isn't a vowel go die | |
else if (s[y] == 'C' && vowel(w[y])) flag = 1; // if there's supposed to be a consonant but it isn't go die | |
} | |
if (!flag) ans++; // if you've avoided all those things that disqualify the word, then increment the count | |
} | |
cout << ans; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment