Codeforces Round 946 (Div. 3) B.Symmetric Encoding

Codeforces Round 946 (Div. 3)

B.Symmetric Encoding

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
// By SnowDream
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+10;
string b;
set<char> s;
int n;
char v[26];
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while(t--)
{
cin >> n;
cin >> b;
string ans;
for(auto c : b)
{
s.insert(c);
}
auto j=s.end();
j--;
for(char i : s)
{
v[i-'a']=*j;
j--;
}
for(auto c:b)
{
ans+=v[c-'a'];
}
s.clear();
cout << ans << "\n";
}
return 0;
}

Codeforces Round 946 (Div. 3) B.Symmetric Encoding
http://snowdreamxue.github.io/2024/10/21/Codeforces Round 946 (Div. 3)/B.Symmetric Encoding/
Author
SnowDream
Posted on
October 21, 2024
Licensed under