-
Notifications
You must be signed in to change notification settings - Fork 1
/
A.cpp
67 lines (57 loc) · 1.16 KB
/
A.cpp
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
58
59
60
61
62
63
64
65
66
67
#include <bits/stdc++.h>
using namespace std;
#define ll long long
string s;
bool cmp(char ch1, char ch2)
{
if(ch1 != 'a') {
char t1 = ch1 - 1;
if(ch2 != 'a') {
char t2 = ch2 - 1;
if(t1 == t2)
return true;
}
if(ch2 != 'z') {
char t2 = ch2 + 1;
if(t1 == t2)
return true;
}
}
if(ch1 != 'z') {
char t1 = ch1 + 1;
if(ch2 != 'a') {
char t2 = ch2 - 1;
if(t1 == t2)
return true;
}
if(ch2 != 'z') {
char t2 = ch2 + 1;
if(t1 == t2)
return true;
}
}
return false;
}
int main()
{
std::ios_base::sync_with_stdio(false);
ll t;
cin >> t;
ll n;
while(t--) {
cin >> n;
bool chk = 1;
cin >> s;
for(ll i = 0, j = s.length() - 1; i < s.length() / 2; i++, j--) {
if(!cmp(s[i], s[j])) {
chk = 0;
break;
}
}
if(chk)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}