-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1976A_Verify_Password.cpp
More file actions
57 lines (46 loc) · 1000 Bytes
/
Copy path1976A_Verify_Password.cpp
File metadata and controls
57 lines (46 loc) · 1000 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
45
46
47
48
49
50
51
52
53
54
55
56
57
// https://codeforces.com/contest/1976/problem/A
// @handle: imransihab0
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define py cout << "YES" << endl
#define pn cout << "NO" << endl
#define FastIO() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
void solve()
{
int n;
cin >> n;
string s;
cin >> s;
string num = "", let = "";
if(s.size() == 1)
{
py;
return;
}
for(int i=0; i<s.size() - 1; i++)
{
if(isalpha(s[i] && isdigit(s[i+1])))
{
pn;
return;
}
}
for (int i = 0; i < s.size(); i++)
{
if(isalpha(s[i])) let += s[i];
else num += s[i];
}
sort(num.begin(), num.end());
sort(let.begin(), let.end());
string _s = num+let;
if(s == _s) py;
else pn;
}
int32_t main(){
FastIO();
int t;
cin >> t;
while(t--) solve();
return 0;
}