include iostream include map include string include vector using names

 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
68
69
70
71
#include<iostream>
#include<map>
#include<string>
#include <vector>
using namespace std;
map<char, int> word;
vector<bool> used;
int main()
{
string s;
cin >> s;
char m;
for (int i = 0; i < 26; ++i)// Создание map ключи - буквы англ. алфавита, значения - пары
{
word['A' + i] = 0;
}
for(int i = 0; i < s.size(); i++)
{
word[s[i]]++;
if(i == 4)
m= s[i];
}
int num;
cin >> num;
for(int i = 0; i < num; i++)
{
cin >> s;
if(s.size() > 9 || s.size() < 4)
{
cout << s << " is invalid" << endl;
continue;
}
bool mid = false;
for(int j = 0; j < s.size(); j++)
{
if(s[j] == m)
{
mid = true;
break;
}
}
if(!mid)
{
cout << s << " is invalid" << endl;
continue;
}
map<char, int> temp = word;
for(int j = 0; j < s.size(); j++)
{
if(temp[s[j]] > 0)
temp[s[j]]--;
else
{
mid = false;
break;
}
}
if(mid)
{
cout << s << " is valid" << endl;
}
else
{
cout << s << " is invalid" << endl;
}
}
}