Powered by:NEFU AB-IN
密码要求: 1.长度超过8位 2.包括大小写字母.数字.其它符号,以上四种至少三种 3.不能有长度大于2的包含公共元素的子串重复 (注:其他符号不含空格或换行) 数据范围:输入的字符串长度满足
加入字典判断是否存在相同的字符串
#include
#include
#include
using namespace std;
#define int long long
#undef int
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define IOS \
ios::sync_with_stdio(false); \
cin.tie(nullptr); \
cout.tie(nullptr)
#define DEBUG(X) cout << #X << ": " << X << '\n'
const int M = 70, N = 4e4 + 10, INF = 0x3f3f3f3f;
bool check(string s) {
if (SZ(s) <= 8) return false;
int a = 0, b = 0, c = 0, d = 0;
unordered_map<string , int> vis;
for (int i = 0; i < SZ(s); ++i) {
if (isupper(s[i])) a = 1;
else if (islower(s[i])) b = 1;
else if (isdigit(s[i])) c = 1;
else d = 1;
if(i + 2 < SZ(s) && vis[s.substr(i, 3)]){
return false;
}
vis[s.substr(i, 3)] = 1;
}
return a + b + c + d >= 3;
}
signed main() {
IOS;
string s;
while (cin >> s) {
if (check(s)) cout << "OK\n";
else cout << "NG\n";
}
return 0;
}