-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcanYouDecideItForME_UVA11203.cpp
76 lines (65 loc) · 1.56 KB
/
canYouDecideItForME_UVA11203.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
using namespace std;
ifstream fin("canYouDecideItForME_UVA11203.in");
ofstream fout("canYouDecideItForME_UVA11203.out");
int main()
{
int T = 0;
fin >> T;
for (int t = 1; t <= T; ++t)
{
string text; fin >> text;
bool showM = false, showE = false, flag = true;
int size = text.size(), x = 0, y = 0, z = 0, temp = 0;
for (int i = 0; i <= size - 1 && flag == true; ++i)
{
if (text[i] == '?')
{
++temp;
}
else if (text[i] == 'M')
{
if (showE == true)
{
flag = false;
}
showM = true;
x = temp;
temp = 0;
}
else if (text[i] == 'E')
{
showE = true;
y = temp;
temp = 0;
}
else
{
flag = false;
}
}
z = temp;
if (showM == false || showE == false || y < 1 || x < 1 || z - (y - 1) - x != 1)
{
flag = false;
}
if (flag == true)
{
fout << "theorem\n";
}
else
{
fout << "no-theorem\n";
}
}
return 0;
}