-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodeforces_TmtDocument.cpp
More file actions
64 lines (52 loc) · 838 Bytes
/
Codeforces_TmtDocument.cpp
File metadata and controls
64 lines (52 loc) · 838 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
58
59
60
61
62
63
64
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int ulli;
int main()
{
int e;
cin >> e;
while (e--)
{
ulli n;
cin >> n;
char word[n - 1];
ulli nOfm = 0, nOft = 0;
for (int i = 0; i < n; i++)
{
cin >> word[i];
if (word[i] == 'M')
{
nOfm++;
}
else
{
nOft++;
}
}
bool isAfirmative = true;
if (n == 3 && (word[0] == 'T' && word[1] == 'M' && word[2] == 'T'))
{
isAfirmative = true;
}
else if (n > 3 && (n / 3) == nOfm && (n / 3) * 2 == nOft)
{
for (int i = 0; i < n; i += 3)
{
if (word[i] == 'T' && word[i + 1] == 'T' && word[i + 2] == 'T')
{
isAfirmative = false;
break;
}
}
}
else
{
isAfirmative = false;
}
if (isAfirmative)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}