您的位置:首页 > 产品设计 > UI/UE

codeforces Gym 100500H H. ICPC Quest 水题

2015-07-27 19:38 459 查看
[b]Problem H. ICPC Quest[/b]
Time Limit: 20 Sec

Memory Limit: 256 MB

[b]题目连接[/b]
http://codeforces.com/gym/100500/attachments
[b]Description[/b]

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.

[b]Input[/b]

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.

[b]Output[/b]

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.

[b]Sample Input[/b]

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

[b]Sample Output[/b]

Case 1: Effective Case 2: Ineffective

[b]HINT[/b]

[b]题意[/b]

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

[b]题解:[/b]

统计一下就好了……

[b]代码[/b]

#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);
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: