简介

简单

code

#include <iostream>
#include <string>
#include <set>
#include <algorithm>
using namespace std;

int main() {
    string str;
    set<string> s;
    while(cin >> str) {
        if(str.size() <= 8) {
            cout << "NG\n";
            continue;
        }
        int check = 0x00;
        for(int i=0; i<str.size(); i++){
            if(str[i] >= '0' && str[i] <='9') {
                check |= 1;
            }
            else if(str[i] >='a' && str[i] <= 'z') {
                check |= 2;
            }
            else if(str[i] >='A' && str[i] <= 'Z') {
                check |= 4;
            }
            else {
                check |= 8;
            } 
        }
        int numCheck = 0;
        //cout << "ccc " << check << endl;
        //cout << (check & 1) << " " << (check & 2) << " " <<  (check & 4) << " " << (check & 8) << std::endl;
        numCheck += (check & 1) > 0 ? 1 : 0;
        numCheck += (check & 2) > 0 ? 1 : 0;
        numCheck += (check & 4) > 0 ? 1 : 0;
        numCheck += (check & 8) > 0 ? 1 : 0;
        check = false;
        for(int i=0; i<str.size()-2; i++){
            for(int j = i+3; j<str.size()-2; j++){
                if(str.substr(i,3) == str.substr(j, 3)){
                    check = true;
                }
            }
        }
        // cout << numCheck << " " << check << endl;
        if(numCheck >= 3 && !check ){
            cout << "OK\n";
            
        }else{
            cout << "NG\n";
        }
    }
    return 0;
}
posted on 2021-06-25 10:25  HDU李少帅  阅读(55)  评论(0编辑  收藏  举报