What's wrong with my code!!!
#include <stdio.h>
#include <string.h>
int t, l, i, len, M, E, x, y, z;
char s[1001];
bool b;
int main()
{
scanf("%d", &t);
for (l = 0; l < t; l++)
{
scanf("%s", &s);
b = 1;
M = 0;
E = 0;
len = strlen(s);
for (i = 0; i < len; i++)
{
if (s != '?' && s != 'M' && s != 'E') b = 0;
if (s == 'M') M++;
if (s == 'E') E++;
}
if (M != 1) b = 0;
if (E != 1) b = 0;
i = 0;
len = strlen(s);
x = 0;
while ((s == '?') && (i < len)) i++, x++;
if (x == 0) b = 0;
if (s == 'M') i++; else b = 0;
y = 0;
while ((s == '?') && (i < len)) i++, y++;
if (y == 0) b = 0;
if (s == 'E') i++; else b = 0;
z = 0;
while ((s == '?') && (i < len)) i++, z++;
if (z == 0) b = 0;
if (z > 0 && x > 0 && y > 0 && M == 1 && E == 1) b = 1;
if (b)
puts("theorem");
else
puts("no-theorem");
}
return 0;
}
11203 - Can you decide it for ME?
Moderator: Board moderators
-
- New poster
- Posts: 32
- Joined: Tue Feb 13, 2007 1:31 pm
Re: 11203 - Can you decide it for ME?
the hint is
Hope is helps.
Code: Select all
M is only one
E is only one
x is at least 1 '?'
y is at least 1 '?'
z is at least 2 '?'
y.length == (z.length - x.length)
-
- Learning poster
- Posts: 84
- Joined: Fri Jan 09, 2009 4:37 pm
- Location: IRAN
Re: 11203 - Can you decide it for ME?
x + y == z
i can`t find this point in the problem
i should guess that ????

i can`t find this point in the problem
i should guess that ????
Impossible says I`m possible
-
- Learning poster
- Posts: 87
- Joined: Thu Dec 15, 2011 3:08 pm
- Location: University of Rajshahi,Bangladesh
Re: 11203 - Can you decide it for ME?
cut>>>After AC!!
we r surrounded by happiness
need eyes to feel it!
need eyes to feel it!
Re: 11203 - Can you decide it for ME?
Here's some input / output I found useful during testing / debugging.
Input:
AC Output:
Input:
Code: Select all
9
???????????ME????
?????M?E?????????
?????M??E?????????
?????M?E??????
??M?E???
??M??E???
??ME???
??M???E?????
????M???E?????
Code: Select all
no-theorem
no-theorem
no-theorem
theorem
theorem
no-theorem
no-theorem
theorem
no-theorem