题目很简单,可是打了一个小时,这种题目真是悲剧啊
/*
* hdu3788/win.cpp
* Created on: 2011-9-6
* Author : ben
*/
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
const int MAXN = 1010;
bool judge(char *s, int len) {
if (len < 3) {
return false;
}
if (len == 3) {
return (s[0] == 'z' && s[1] == 'o' && s[2] == 'j');
}
int ii = 0;
while (s[ii] == s[len - 1 - ii] && s[ii] == 'o') {
ii++;
}
if (len - 2 * ii == 3) {
return judge(&s[ii], len - 2 * ii);
}
char tempstr[MAXN];
int a = 0, tlen;
while (s[a] == 'o' && a < len) {
a++;
}
if (a > len - 3) {
return false;
}
for (tlen = 0; tlen < a; tlen++) {
tempstr[tlen] = s[tlen];
}
if (s[tlen] != 'z') {
return false;
}
tempstr[tlen] = 'z';
if (s[++tlen] != 'o') {
return false;
}
for (; tlen < len - a - 1; tlen++) {
tempstr[tlen] = s[tlen + 1];
}
tempstr[tlen] = '\0';
for (int t = tlen + 1; t < len; t++) {
if (s[t] != 'o') {
return false;
}
}
return judge(tempstr, tlen);
}
int main() {
#ifndef ONLINE_JUDGE
freopen("data.in", "r", stdin);
#endif
char str[MAXN];
while (scanf("%s", str) == 1) {
if (judge(str, strlen(str))) {
puts("Accepted");
} else {
puts("Wrong Answer");
}
}
return 0;
}