#include
#include
#include
bool threeCharacters(char *str, int len) {
int a = 0, b = 0, c = 0, d = 0;
for (int i = 0; i < len; i++) {
if (str[i] >= '0' && str[i] <= '9') {
a = 1;
}
else if (str[i] >= 'a' && str[i] <= 'z') {
b = 1;
}
else if (str[i] >= 'A' && str[i] <= 'Z') {
c = 1;
}
else {
d = 1;
}
if (a + b + c + d > 2) {
return true;
}
}
return false;
}
bool threeRepeat(char *str, int len) {
int fast = 1, slow = 0, nums = 0;
while (str[slow] != '\0') {
if (str[fast++] == str[slow]) {
for (int i = 1; i < 3; i++) {
if (str[fast-1+i] == '\0') {
break;
}
else if (str[fast-1+i] == str[slow+i]) {
nums++;
}
}
if (nums > 1) {
return false;
}
else {
nums = 0;
}
}
else if (str[fast] == '\0') {
slow++;
fast = slow + 1;
}
}
return true;
}
int main() {
char str[100] = {'\0'};
while (gets(str)) {
int len = strlen(str);
if (len > 8 && threeCharacters(str, len) && threeRepeat(str, len)) {
printf("OK\n");
}
else {
printf("NG\n");
}
}
return 0;
}
暂无评论