Problem I. Hall of Fame

来源:ACM International Collegiate Programming Contest, Syrian Collegiate Programming Contest (2014) Syria, September, 23, 2014 CF链接Gym 100500I

ICPC World Finals 2014 was held in Russia, in Ekaterinburg from 21/06/2014 to 26/06/2014, hosted by Ural Federal University (UrFU). The opening ceremony was held on 23/06/2014 at 4:00 PM, in Cosmos Big Hall. During the ceremony a nice lady was singing the famous song "Hall of Fame". In case you don’t know the song here is its lyrics:(歌词在下图放大可查看)

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.

Examples

Fame.in:

2

You can be the greatest

*

You can be the best

You can be the King Kong banging on

your chest

*

Standard Output:

Case 1: Effective

Case 2: Ineffective

其实题目仔细分析就好,并不是很难,写代码的时候要细心。(题目意思就是:找出出现次数最多的那5个字母,如果出现次数相同则按字典序由大到小排序,A到Z分别指代0到25,最后将那5个字母代表的数字加起来,判断是否大于64,是则输出Effective,反之Ineffective。)

代码如下:

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
struct node
{int data, x;  // data用来存某个字母出现的次数,x来存编号代表相应字母(0->A/a,1->B/b...)
} b[27];
void qs(int l, int r);
int main()
{int T;scanf("%d", &T);int i = 0, g = 1;while(T){getchar();char a[20020][22];scanf("%s", a[++i]); // 每次输入一个小子段并存下来if(strcmp(a[i], "*") == 0) // 每当遇到*则判断,if语句中最后重置i为0,并且T--{memset(b, 0, sizeof(b)); // 将结构体数组初始化for(int j = 1; j < i; j++){int l = strlen(a[j]);for(int k = 0; k < l; k++) // 判断A/a...Z/z并存下来相应编号{if(a[j][k] >= 'A' && a[j][k] <= 'Z'){b[a[j][k] - 'A'].data++;b[a[j][k] - 'A'].x = a[j][k] - 'A';}else if(a[j][k] >= 'a' && a[j][k] <= 'z')//因为不分大小写,所以A与a使用同一下标{b[a[j][k] - 'a'].data++;b[a[j][k] - 'a'].x = a[j][k] - 'a';}}}qs(0, 25); // 快排for(i = 0; i < 25; i++){for(int j = 0; j < 25 - i; j++){if(b[j].data == b[j + 1].data && b[j].x < b[j + 1].x)// 因为想要在快排中出现次数相同时直接判断字典序,但是失败了,所以这里写了一个冒泡只把出现次数相同的排一下字典序,很幸运没有超时^.^{struct node t = b[j];b[j] = b[j + 1];b[j + 1] = t;}}}int sum = 0;for(i = 0; i < 5; i++){sum += b[i].x; // 一切准备就绪,只需要将前5个字母代表的数值加起来就好}if(sum > 62) printf("Case %d: Effective\n", g++);else printf("Case %d: Ineffective\n", g++);i = 0;T--; // 不要忘了组数减减,以及上边重置i为0}}return 0;
}
void qs(int l, int r)
{if(l >= r) return ;int i = l, j = r;struct node t = b[l];while(i < j){  // 开始就是这里出问题了,注释掉的部分是失败的。。。但是不清楚为什么,看得出来的小伙伴欢迎下方评论指正while(i < j && b[j].data <= t.data /*||(b[j].data == t.data && b[j].x < t.x))*/){j--;}b[i] = b[j];while(i < j && b[i].data >= t.data /*||(b[i].data == t.data && b[i].x > t.x))*/){i++;}b[j] = b[i];}b[i] = t;qs(l, i - 1);qs(i + 1, r);
}

Problem I. Hall of Fame (2014 Syria ICPC)相关推荐

  1. Problem D: 栈的基本运算(栈和队列)

    Problem D: 栈的基本运算(栈和队列) Time Limit: 1 Sec  Memory Limit: 128 MB Submit: 43  Solved: 15 [Submit][Stat ...

  2. HDU 6333 Problem B. Harvest of Apples(莫队离线)

    Problem B. Harvest of Apples(莫队离线) Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 262144/26214 ...

  3. CV算法复现(分类算法4/6):GoogLeNet(2014年 谷歌)

    致谢:霹雳吧啦Wz:https://space.bilibili.com/18161609 目录 致谢:霹雳吧啦Wz:https://space.bilibili.com/18161609 1 本次要 ...

  4. 寻找大学目标及行动步骤——记ITAEM团队第二期宣讲会(2014.05.14)

    ·昨晚8:00-9:40,在 钟海楼03029 ,进行了ITAEM团队第二期宣讲会(第一期见第一期宣讲会总结),来參加的主要是大一学生,以信院为主,也有法学院.文学院的同学. 在宣讲会中,大家都比較积 ...

  5. java项目开发实践经验每日总结(2014/2/22)

    2014/2/22 1.阅读分析代码可以从需求逻辑层,业务逻辑层,目录结构层,包结构层,类结构层,方法结构层,代码结构层,方法实现结构层,语法结构层 2.单页的代码结构 所属包,导入文件和包,公共类( ...

  6. 基于全景图像与激光点云配准的彩色点云生成算法(2014年文章)

    标题:The algorithm to generate color point-cloud with the registration between panoramic imageand lase ...

  7. UVa Problem 10310 Dog and Gopher (狗拿地鼠)

    // Dog and Gopher (狗拿地鼠) // PC/UVa IDs: 111301/10310, Popularity: A, Success rate: average Level: 1 ...

  8. 图像识别技术初探(2014/2/17)

    目录 1 前言. 1 1.1 植物的发展史. 1 1.1.1 植物界的类群及多样性. 1 1.1.2 植物的分类等级. 2 1.2植物的识别方法. 3 1.2.1 花与种子的特性. 3 1.2.2 叶 ...

  9. Problem T 分数拆分问题(第四讲)

    题目描述 输入正整数k,遇到文件末尾结束.找到所有的正整数x和y(x大于等于y),使得1/k=1/x+1/y. 输入 一行输入一个正整数k. 输出 先在第一行输出解的个数,再每行输出一个表达式. 样例 ...

最新文章

  1. 八皇后问题(递归+非递归)
  2. 为不同的屏幕尺寸提供不同的图片(为那些没有必要下载全尺寸大图的设备节省带宽)...
  3. 新CalendarFX视图:MonthGridView!
  4. BZOJ 3479: [Usaco2014 Mar]Watering the Fields( MST )
  5. 一个整合SQL语句的类
  6. python 多个装饰器的调用顺序
  7. sh执行文件 参数传递_shell中脚本参数传递的两种方式
  8. wordpress用途_8个热门WordPress多用途主题及其炫酷功能
  9. 大数据应用领域都有哪些(一)
  10. 【标准算例数据源】作业车间、流水车间、柔性作业车间、其它
  11. php日期函数实际应用,PHP日期函数的使用介绍
  12. 树莓派与笔记本电脑连接屏幕共享(通过热点)
  13. 唧唧DOWN闪退的原因
  14. oracle应付创建会计科目,R12 应付创建会计科目警告【已解决】
  15. JS实现文本的语音朗读
  16. 互联网到底怎么连接的?一张图告诉你
  17. 卸载Oracle步骤
  18. 怎么选择Java培训机构?
  19. 2021-06-18四种方法帮你排除电磁兼容测试故障
  20. linux jpg图片缩放,ImageMagick之图片缩放

热门文章

  1. Lm317电压源芯片制作电流源
  2. vivado仿真设计流程
  3. 机器学习LDA-基础Julia与Python的实现
  4. ffmpeg delogo滤镜去除图片水印
  5. php 模板渲染,ThinkPHP6.0模板渲染 - ThinkPHP6.0快速开发手册(案例版) - php中文网手册...
  6. [linux-023]在thinkpad T480上安装ubuntu 20.04 LTS
  7. python画红色等边三角形面积公式_等边三角形面积公式?
  8. 腾讯优图贾佳亚:当AI进入产业应用时代时,计算机视觉技术更应该服务于人才对!...
  9. Hacking Team泄露数据表明韩国、哈萨克斯坦针对中国发起网络攻击
  10. 【NOIP2005 提高组】篝火晚会