1. 可以使用位运算记录字符种类
  2. 判断是否含有重复子串的时候,只需要判断长度为3的子串即可。
#include<bits/stdc++.h>

using namespace std;


inline bool SubStringDetermine(string s)
{
    unordered_map<string, int> hash;
    // i : length of sub string
    //for (int len = 3; len < s.size() - 1; len++)
    int len = 3;
    {
        for (int i = 0; i < s.size() - len + 1; i++)
        {
            string sub = s.substr(i, len);
            hash[sub] = hash[sub] + 1;
            if (hash[sub] > 1) 
                return false;
        }
    }
    return true;
}

inline int lowbit(int x)
{
    return x & (-x);
}

inline bool TypeDetermine(string s)
{
    int cnt = 0;
    for (auto c : s)
    {
        if (isupper(c))
            cnt |= 1;
        else if (islower(c))
            cnt |= (1 << 1);
        else if (isdigit(c))
            cnt |= (1 << 2);
        else 
            cnt |= (1 << 3);
    }
    // count 1
    int type = 0;
    for (; cnt; cnt -= (lowbit(cnt)))
        type++;
    return type >= 3;
}

inline bool SizeDetermine(string s)
{
    return s.size() > 8;
}

int main()
{
    cin.tie(nullptr)->sync_with_stdio(false);
    string s;
    for (;getline(cin, s);)
    {
        if (SizeDetermine(s) && TypeDetermine(s) && SubStringDetermine(s)) 
            cout << "OK" << endl;
        else 
            cout << "NG" << endl;
    }
    return 0;
}