-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbee2852.cpp
More file actions
57 lines (44 loc) · 980 Bytes
/
Copy pathbee2852.cpp
File metadata and controls
57 lines (44 loc) · 980 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
* Contest : Beecrowd
* Problem : 2852 - Troca de Mensagens
* Link : https://judge.beecrowd.com/pt/problems/view/2852
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fastio ios::sync_with_stdio(0); cin.tie(0);
string k, s;
inline void moveK(int &i) { i = (i + 1) % k.size(); }
bool isVowel(char c) {
if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') return true;
else
return false;
}
char change(char k, char c) {
int dist = k - 'a';
char res = (c + dist) % ('z' + 1);
if (res < 'a') res += 'a';
return res;
}
void solve() {
getline(cin, s);
int ki = 0;
char letter = s.front();
for (int i = 0; i < s.size(); ++i) {
char c = s[i];
if (c == ' ') letter = s[i + 1];
else if (!isVowel(letter)) {
s[i] = change(k[ki], c);
moveK(ki);
}
}
cout << s << '\n';
}
int main() {
fastio
cin >> k;
int n; cin >> n;
cin.ignore();
while (n--) solve();
return 0;
}