Codeforces Gym 100500H H. ICPC Quest Water problem

Source: Internet
Author: User

Problem H. ICPC Quest
Time Limit:20 Sec

Memory limit:256 MB

Topic Connection

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

Description

Coach Fegla has invented a song effectiveness measurement methodology. This methodology in simple 中文版 means count the frequency of each character of the Chinese letters [a-z] in the given S Ong (case insensitive). Get the top 5 characters with the highest frequencies, if 2 characters has the same frequency choose the one which is Lex icographically larger. Sum up the indexes of these characters where the index of A are 0, index of B is 1, ..., index of of Z = 25. If This sum exceeds "effective" otherwise print "ineffective" without the quotes.

Input

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

Output

For each test case, print a containing:case x:y x is the case number starting from 1. Y is the required answer either "effective" or "ineffective" without the quotes.

Sample Input

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

Sample Output

Case 1:effective Case 2:ineffective

HINT

Test instructions

Let you count the five most frequent letters and see if the values of these letters exceed 62

The following:

Just a few statistics ...

Code

#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>typedefLong Longll;using namespacestd;//freopen ("d.in", "R", stdin);//freopen ("D.out", "w", stdout);#defineSspeed ios_base::sync_with_stdio (0); Cin.tie (0)#defineTest Freopen ("Test.txt", "R", stdin)Const intmaxn=202501;#defineMoD 1000000007#defineEPS 1e-9Const intinf=0x3f3f3f3f;Constll infll =0x3f3f3f3f3f3f3f3fll;inline ll Read () {ll x=0, f=1;CharCh=GetChar ();  while(ch<'0'|| Ch>'9'){if(ch=='-') f=-1; ch=GetChar ();}  while(ch>='0'&&ch<='9') {x=x*Ten+ch-'0'; ch=GetChar ();} returnx*F;}//*************************************************************************************structnode{intx, y;};BOOLCMP (node A,node b) {if(a.x==b.x)returnA.y>b.y; returnA.x>b.x;} Node a[ -];strings;intMain () {intt=read ();  for(intcas=1; cas<=t;cas++) {memset (A,0,sizeof(a));  for(intI=0;i< -; i++) A[i].y=i;  while(cin>>s) {if(s[0]=='*')                 Break;  for(intI=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+ -, CMP); intsum=0;  for(intI=0;i<5; i++)        {            if(a[i].x!=0) Sum+=a[i].y; }        if(sum> +) printf ("Case %d:effective\n", CAs); Elseprintf ("Case %d:ineffective\n", CAs); }}

Codeforces Gym 100500H H. ICPC Quest Water problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.