题目
题目连接
解题
#include
#include
using namespace std;
int count(string& s,string& t){
int m=s.size(),n=t.size();
int res=0;
for(int i=0;i<m;i++){
int u=i,v=0;
while(u<m&&v<n){
if(s[u]!=t[v]) break;
u++;
v++;
}
if(v==n) res++;
}
return res;
}
bool isValid(string& s){
int n=s.size();
if(n<8) return false;
int f1=0,f2=0,f3=0,f4=0;
for(char c:s){
if(c>='A'&&c<='Z') f1=1;
else if(c>='a'&&c<='z') f2=1;
else if(c>='0'&&c<='9') f3=1;
else f4=1;
}
if(f1+f2+f3+f4<3) return false;
for(int i=0;i<n-3;i++){
string tmp=s.substr(i,3);
if(count(s,tmp)>=2) return false;
}
return true;
}
int main()
{
string s;
while(getline(cin,s)){
bool res=isValid(s);
if(res) cout<<"OK"<<endl;
else cout<<"NG"<<endl;
}
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49