You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
811 B
C++

#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
char str[20];
int len;
int dfs() {
//cout << "*** " << str << endl;
if (strstr(str, "LOL"))
return -1;
if (strchr(str, '*') == nullptr)
return 0;
int ending = -1;
for (int pos = 0; pos < len; pos++)
if (str[pos] == '*') {
str[pos] = 'L';
ending = max(ending, -dfs());
str[pos] = 'O';
ending = max(ending, -dfs());
str[pos] = '*';
}
return ending;
}
int main() {
int num;
scanf("%d", &num);
while (num--) {
scanf("%s", str);
len = strlen(str);
printf("%d\n", dfs());
}
return 0;
}