CodeForces

#include <bits/stdc++.h>
#define mem(a, b) memset(a, b, sizeof(a))
using namespace std;
const int maxn = 100100, INF = 0x7fffffff;
string str;
int vis[26];
int main()
{
    cin>> str;
    mem(vis, 0);
    int cnt = 0, ans = 0;
    for(int i=0; i<str.size(); i++)
            vis[str[i] - 'a']++;
    for(int i=0; i<26; i++)
        if(vis[i])
        {
            cnt++;
            if(vis[i] >= 2)
                ans++;
            if(cnt > 4)
            {
                cout<< "No" <<endl;
                return 0;
            }
        }
    if(cnt == 1)
    {
        cout<< "No" <<endl;
    }
    else if(cnt == 2)
    {
        if(ans == 2)
            cout<< "Yes" <<endl;
        else
            cout<< "No" <<endl;
    }
    else if(cnt == 3)
    {
        if(ans)
            cout<< "Yes" <<endl;
        else
            cout<< "No" <<endl;
    }
    else if(cnt == 4)
        cout<< "Yes" <<endl;

    return 0;
}
自己选择的路,跪着也要走完。朋友们,虽然这个世界日益浮躁起来,只要能够为了当时纯粹的梦想和感动坚持努力下去,不管其它人怎么样,我们也能够保持自己的本色走下去。
原文地址:https://www.cnblogs.com/WTSRUVF/p/9414227.html