题目链接
#include <iostream>
#include <cstring>
using namespace std;
bool isThree(string s) {
int ans[4] = {0, 0, 0, 0};
for(int i = 0; i < s.length(); i++) {
if(s[i] >= 'a' && s[i] <= 'z') {
ans[0] = 1;
} else if(s[i] >= 'A' && s[i] <= 'Z') {
ans[1] = 1;
} else if(s[i] >= '0' && s[i] <= '9') {
ans[2] = 1;
} else {
ans[3] = 1;
}
}
int n = ans[0] + ans[1] + ans[2] + ans[3];
if(n >= 3) return true;
return false;
}
bool isNotRepeat(string str) {
bool flag = true;
for(int i = 0; i <= str.size() - 6; i++)
for(int j = i + 3; j < str.size(); j++)
if(str[i] == str[j] && str[i + 1] == str[j + 1] && str[i + 2] == str[j + 2]) {
flag = false;
break;
}
return flag;
}
int main() {
string s;
while(getline(cin, s)) {
if(s.length() <= 8) {
cout << "NG" << endl;
continue;
}
bool thr = isThree(s);
bool rep = isNotRepeat(s);
if(thr == true && rep == true)
cout << "OK" << endl;
else
cout << "NG" << endl;
}
return 0;
}