-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1986C.cpp
More file actions
44 lines (32 loc) · 715 Bytes
/
Copy path1986C.cpp
File metadata and controls
44 lines (32 loc) · 715 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
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define ull unsigned long long
#define umap unordered_map
#define f(i, x, n) for (ll i = x; i < n; i++)
#define endl '\n'
#define optimize() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int main() {
optimize();
ll t;
cin >> t;
while (t--) {
ll n, m, in; cin >> n >> m;
string s; cin >> s;
set <ll> ind;
f(i, 0, m) {
cin >> in;
ind.insert(in);
}
vector <ll> indv;
for (auto it : ind) indv.pb(it);
string c; cin >> c;
sort(c.begin(), c.end());
sort(indv.begin(), indv.end());
f (i, 0, indv.size()) {
s[indv[i]-1] = c[i];
}
cout << s << endl;
}
}