首页 > 其他 > 详细

CodeForces - 955B(用char会超时。。。)

时间:2018-08-03 15:49:56      阅读:104      评论:0      收藏:0      [点我收藏+]
#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;
}

 

CodeForces - 955B(用char会超时。。。)

原文:https://www.cnblogs.com/WTSRUVF/p/9414227.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!