Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
- #define X first
- #define Y second
- #define Push push_back
- #define ALL(x) x.begin(), x.end()
- using lli = long long;
- using pll = pair<lli, lli>;
- using Double = long double;
- template<typename T>
- using Vector = vector<vector<T>>;
- template<typename T>
- using prior = priority_queue<T>;
- int main() {
- IOS;
- int n;
- cin >> n;
- getchar();
- string s, t;
- getline(cin, s);
- getline(cin, t);
- set<char> app;
- string encrypt;
- for (auto x : s) {
- if (x == ' ') continue;
- if (!app.count(x)) {
- app.insert(x);
- encrypt += x;
- }
- }
- int tmp = *encrypt.rbegin();
- for (int i = tmp+1; i <= tmp+26; ++i) {
- char j;
- if (i > 'z') j = i - 26;
- else j = i;
- if (!app.count(j)) {
- app.insert(j);
- encrypt += j;
- }
- }
- assert(encrypt.size() == 26);
- string decrypt(26, ' ');
- for (int i = 0; i < 26; ++i) {
- decrypt[encrypt[i] - 'a'] = ('a' + i);
- }
- // for (char x = 'a'; x <= 'z'; ++x) cout << x; cout << "\n";
- // cout << encrypt << "\n";
- if (n == 1) {
- string answer;
- for (auto x : t) {
- if (x == ' ') {
- answer += ' ';
- continue;
- }
- bool big = false;
- if (isupper(x)) {
- big = true;
- x += 32;
- }
- answer += (encrypt[x - 'a'] - 32 * big);
- }
- cout << answer << "\n";
- }
- if (n == 0) {
- string answer;
- for (auto x : t) {
- if (x == ' ') {
- answer += ' ';
- continue;
- }
- bool big = false;
- if (isupper(x)) {
- big = true;
- x += 32;
- }
- answer += (decrypt[x - 'a'] - 32 * big);
- }
- cout << answer << "\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement