-
Notifications
You must be signed in to change notification settings - Fork 0
/
1722A.cpp
52 lines (46 loc) · 1.08 KB
/
1722A.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
#include<iostream>
#include<map>
#include<iterator>
using namespace std;
void resetMap(map<char, int>&m){
for(auto itr=m.begin(); itr != m.end(); itr++){
itr->second = 0;
}
}
bool fillMap(map<char, int>&m, string name){
for(int j=0; j<name.length(); j++){
auto itr = m.find(name[j]);
if(itr == m.end()){
return false;
}
itr->second += 1;
}
return true;
}
bool checkMap(map<char, int>&m){
for(auto itr = m.begin(); itr != m.end(); itr++){
if(itr->second != 1){
return false;
}
}
return true;
}
int main(){
map<char, int> m;
m.insert({'T',0}); m.insert({'i',0}); m.insert({'m',0}); m.insert({'u',0}); m.insert({'r',0});
int t, n;
string name;
cin >> t;
for(int i=0; i<t; i++){
cin >> n;
cin >> name;
if(n != 5 || fillMap(m, name) == false){
cout << "NO" << endl;
resetMap(m);
continue;
}
checkMap(m) ? cout << "YES" << endl : cout << "NO" << endl;
resetMap(m);
}
return 0;
}