Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- char ch[] = {'A', 'E', 'I', 'O', 'o', 'U', 'u', 'Y'};
- map<char, char> nxt;
- vector <string> dictionary;
- void brute(string t) {
- if (t.size() == 5) {
- dictionary.push_back(t);
- return;
- }
- if (t.empty()) {
- for (int i = 0; i < 8; i++) {
- brute(t + ch[i]);
- }
- return;
- }
- brute(t + t.back());
- brute(t + nxt[t.back()]);
- }
- int getPos(char c) {
- for (int i = 0; i < 8; i++) {
- if (ch[i] == c) return i;
- }
- }
- bool cmp(string a, string b) {
- for (int i = 0; i < a.size(); i++) {
- int x = getPos(a[i]);
- int y = getPos(b[i]);
- if (x == y) continue;
- return x < y;
- }
- return 0;
- }
- int main(){
- ios::sync_with_stdio(0);
- nxt['A'] = 'Y';
- nxt['E'] = 'I';
- nxt['I'] = 'E';
- nxt['O'] = 'U';
- nxt['o'] = 'u';
- nxt['U'] = 'A';
- nxt['u'] = 'o';
- nxt['Y'] = 'A';
- brute("");
- sort(dictionary.begin(), dictionary.end(), cmp);
- string s;
- cin >> s;
- for (int i = 0; i < dictionary.size(); i++) {
- if (dictionary[i] == s) {
- cout << dictionary[i + 1] << endl;
- return 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement