File tree 1 file changed +219
-0
lines changed
1 file changed +219
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include < iostream>
2
+ #include < vector>
3
+ #include < string.h>
4
+ #include < stdio.h>
5
+ using namespace std ;
6
+
7
+ int ab;
8
+ int ok;
9
+ bool ans[55 ][1000 ];
10
+ vector <int > x;
11
+ string a;
12
+
13
+ int check (int n)
14
+ {
15
+
16
+ int acount = 0 ;
17
+ int bcount = 0 ;
18
+ int qcount = 0 ;
19
+ int i;
20
+
21
+ for ( i = 0 ; i < a.length (); i++) {
22
+
23
+
24
+ if (a[i] == ' A' or a[i] == ' E' or a[i] == ' I' or a[i] == ' O' or a[i] == ' U' ) {
25
+ acount++;
26
+ bcount = 0 ;
27
+ a[i] = ' A' ;
28
+ }
29
+ else {
30
+ acount = 0 ;
31
+ if (a[i] != ' ?' ) {
32
+ bcount++;
33
+ a[i] = ' B' ;
34
+ }
35
+
36
+ else {
37
+ bcount = 0 ;
38
+ qcount++;
39
+ }
40
+ }
41
+
42
+ if (acount == 3 or bcount == 5 ) {
43
+
44
+ break ;
45
+ }
46
+ }
47
+
48
+ if (acount == 3 or bcount == 5 ) {
49
+ return 0 ;
50
+ }
51
+
52
+ else {
53
+ return 1 ;
54
+ }
55
+
56
+ }
57
+
58
+ int explore (int i)
59
+ {
60
+
61
+ int t;
62
+ int temp;
63
+ int mul = 1 ;
64
+
65
+
66
+ temp = 0 ;
67
+
68
+ if (i >= x.size ()) {
69
+ ok++;
70
+ return 0 ;
71
+ }
72
+
73
+ t = x[i];
74
+
75
+ a[t] = ' A' ;
76
+
77
+ for (int j = 0 ; (t - j) >= 0 and j <= 5 ; j++) {
78
+ temp = temp + ((a[t-j] - ' A' ) * mul);
79
+ mul *= 2 ;
80
+ }
81
+ if (check (t)) {
82
+
83
+ if (ans[i][temp] == 0 ) {
84
+ explore (i+1 );
85
+ ans[i][temp] = 1 ;
86
+ }
87
+
88
+ }
89
+
90
+ else {
91
+ ab++;
92
+ }
93
+
94
+ mul = 1 ;
95
+
96
+ a[t] = ' B' ;
97
+
98
+ temp = 0 ;
99
+
100
+ for (int j = 0 ; (t - j) >= 0 and j <= 5 ; j++) {
101
+ temp += (a[t-j] - ' A' ) * mul;
102
+ mul *= 2 ;
103
+ }
104
+
105
+ if (check (t)) {
106
+
107
+ if (ans[i][temp] == 0 ) {
108
+ explore (i+1 );
109
+ ans[i][temp] = 1 ;
110
+ }
111
+
112
+ }
113
+
114
+ else {
115
+ ab++;
116
+ }
117
+
118
+ a[t] = ' ?' ;
119
+
120
+ }
121
+
122
+
123
+
124
+
125
+
126
+
127
+ int main ()
128
+ {
129
+
130
+ int t;
131
+ int acount;
132
+ int bcount;
133
+ int qcount;
134
+ int i;
135
+
136
+ cin >> t;
137
+
138
+ for (int cs = 1 ; cs <= t; cs++) {
139
+ cin >> a;
140
+
141
+ vector <int > temp;
142
+ swap (x, temp);
143
+ acount = 0 ;
144
+ bcount = 0 ;
145
+ qcount = 0 ;
146
+
147
+ for ( i = 0 ; i < a.length (); i++) {
148
+
149
+
150
+ if (a[i] == ' A' or a[i] == ' E' or a[i] == ' I' or a[i] == ' O' or a[i] == ' U' ) {
151
+ acount++;
152
+ bcount = 0 ;
153
+ a[i] = ' A' ;
154
+ }
155
+
156
+ else {
157
+ acount = 0 ;
158
+ if (a[i] != ' ?' ) {
159
+ bcount++;
160
+ a[i] = ' B' ;
161
+ }
162
+
163
+ else {
164
+ bcount = 0 ;
165
+ qcount++;
166
+ }
167
+ }
168
+
169
+ if (acount == 3 or bcount == 5 ) {
170
+ break ;
171
+ }
172
+
173
+ }
174
+
175
+ if (qcount == 0 ) {
176
+ if (acount == 3 or bcount == 5 ) {
177
+ printf (" Case %d: BAD\n " , cs);
178
+ }
179
+
180
+ else {
181
+ printf (" Case %d: GOOD\n " , cs);
182
+ }
183
+
184
+ }
185
+
186
+ else {
187
+ for (int i = 0 ; i < a.length (); i++) {
188
+ if (a[i] == ' ?' ) {
189
+ x.push_back (i);
190
+ }
191
+
192
+ }
193
+
194
+ ab = 0 ;
195
+ ok = 0 ;
196
+ memset (ans, 0 , sizeof (ans));
197
+ explore (0 );
198
+
199
+ if (ab and ok) {
200
+ printf (" Case %d: MIXED\n " , cs);
201
+ }
202
+
203
+ if (ab and ok == 0 ) {
204
+ printf (" Case %d: BAD\n " , cs);
205
+ }
206
+
207
+ if (ab == 0 and ok) {
208
+ printf (" Case %d: GOOD\n " , cs);
209
+ }
210
+
211
+
212
+
213
+
214
+ }
215
+
216
+ }
217
+
218
+
219
+ }
You can’t perform that action at this time.
0 commit comments