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=;
#define mod 1000000007
#define eps 1e-9
const int inf=0x3f3f3f3f;
const ll infll = 0x3f3f3f3f3f3f3f3fLL;
inline ll read()
{
ll x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';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[];
string s;
int main()
{
int t=read();
for(int cas=;cas<=t;cas++)
{
memset(a,,sizeof(a));
for(int i=;i<;i++)
a[i].y=i;
while(cin>>s)
{
if(s[]=='*')
break;
for(int i=;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+,cmp);
int sum=;
for(int i=;i<;i++)
{
if(a[i].x!=)
sum+=a[i].y;
}
if(sum>)
printf("Case %d: Effective\n",cas);
else
printf("Case %d: Ineffective\n",cas);
}
}
上一篇:人工智能-有限状态机(FSM)的学习


下一篇:Codeforces Gym 100513F F. Ilya Muromets 水题