codeforces Gym 100500H H. ICPC Quest 水题


Problem H. ICPC Quest
Time Limit: 20 Sec

Memory Limit: 256 MB

题目连接

http://codeforces.com/gym/100500/attachments

Description

Coach Fegla has invented a song effectiveness measurement methodology. This methodology in simple English means count the frequency of each character of the English letters [A-Z] in the given song (case insensitive). Get the top 5 characters with the highest frequencies, if 2 characters have the same frequency choose the one which is lexicographically larger. Sum up the indexes of these characters where the index of A is 0, index of B is 1, ..., index of of Z = 25. If this sum exceeds 62 print "Effective"otherwise print "Ineffective"without the quotes.

Input

The first line will be the number of test cases T. Each test case will consist of a series of words consisting only of upper or lower case English letters. Each test case ends with a line containing only "*"without the double quotes. Each word consists of a minimum of 1 letter and a max of 20 letters. The number of words in each test case will be a max of 20,000.

Output

For each test case print a single line containing: Case x: y x is the case number starting from 1. y is is the required answer either "Effective"or "Ineffective"without the quotes.

Sample Input

2 You can be the greatest * You can be the best You can be the King Kong banging on your chest *

Sample Output

Case 1: Effective Case 2: Ineffective

HINT

题意

让你统计频率最高的五个字母,然后看这些字母的值是否超过62

题解

统计一下就好了……

代码

#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define test freopen("test.txt","r",stdin)
const int maxn=202501;
#define mod 1000000007
#define eps 1e-9
const int inf=0x3f3f3f3f;
const ll infll = 0x3f3f3f3f3f3f3f3fLL;
inline ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//*************************************************************************************

struct node
{
    int x,y;
};
bool cmp(node a,node b)
{
    if(a.x==b.x)
        return a.y>b.y;
    return a.x>b.x;
}
node a[50];
string s;
int main()
{
    int t=read();
    for(int cas=1;cas<=t;cas++)
    {
        memset(a,0,sizeof(a));
        for(int i=0;i<26;i++)
            a[i].y=i;
        while(cin>>s)
        {
            if(s[0]=='*')
                break;
            for(int i=0;i<s.size();i++)
            {
                if(s[i]>='a'&&s[i]<='z')
                    a[s[i]-'a'].x++;
                if(s[i]>='A'&&s[i]<='Z')
                    a[s[i]-'A'].x++;
            }
        }
        sort(a,a+26,cmp);
        int sum=0;
        for(int i=0;i<5;i++)
        {
            if(a[i].x!=0)
                sum+=a[i].y;
        }
        if(sum>62)
            printf("Case %d: Effective\n",cas);
        else
            printf("Case %d: Ineffective\n",cas);
    }
}

优质内容筛选与推荐>>
1、JS 写 个简单的 TreeView
2、lib和dll文件的区别和联系
3、knockoutJS 快速上手
4、8 java 笔记
5、树的子结构 牛客网 剑指Offer


长按二维码向我转账

受苹果公司新规定影响,微信 iOS 版的赞赏功能被关闭,可通过二维码转账支持公众号。

    阅读
    好看
    已推荐到看一看
    你的朋友可以在“发现”-“看一看”看到你认为好看的文章。
    已取消,“好看”想法已同步删除
    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号