forked from ngthanhtrung23/CompetitiveProgramming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathI.cpp
More file actions
35 lines (32 loc) · 656 Bytes
/
I.cpp
File metadata and controls
35 lines (32 loc) · 656 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
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(0);
int test;
cin >> test;
while (test--)
{
int d[256] = {0}, a[26], cnt[30] = {0};
string s;
cin >> s;
for (int i = 0; i < 26; i++) a[i] = s[i] - 'A';
for (int i = 0; i < 26; i++)
if (!d[i])
{
int length = 0, id = i;
while (!d[id])
{
d[id] = 1;
length++;
id = a[id];
}
cnt[length]++;
}
string ans = "Yes";
for (int i = 2; i <= 26; i += 2)
if (cnt[i] % 2)
ans = "No";
cout << ans << endl;
}
}