blob: 62a742bf0b2d56648b3d2b5e8e0fcc61288d1bdd (
plain)
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
|
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define INF 1000000000
string buildString(map<int, char> &mp, vi &v) {
string s = "";
for (auto x : v) {
s.push_back(mp[x]);
}
return s;
}
int main () {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int tt;
cin >> tt;
while(tt--) {
int n;
cin >> n;
vi v(n);
for (auto &x : v) cin >> x;
string s;
cin >> s;
map<int, char> mp;
for (int i = 0; i < n; i++) {
mp[v[i]] = s[i];
}
// cerr << buildString(mp,v) << '\n';
cout << (s == buildString(mp, v) ? "YES" : "NO") << '\n';
}
}
|