John got a full mark on PAT. He was so happy that he decided to hold a raffle(抽奖) for his followers on Weibo -- that is, he would select winners from every N followers who forwarded his post, and give away gifts. Now you are supposed to help him generate the list of winners.

Input Specification:

Each input file contains one test case. For each case, the first line gives three positive integers M (<= 1000), N and S, being the total number of forwards, the skip number of winners, and the index of the first winner (the indices start from 1). Then M lines follow, each gives the nickname (a nonempty string of no more than 20 characters, with no white space or return) of a follower who has forwarded John's post.

Note: it is possible that someone would forward more than once, but no one can win more than once. Hence if the current candidate of a winner has won before, we must skip him/her and consider the next one.

Output Specification:

For each case, print the list of winners in the same order as in the input, each nickname occupies a line. If there is no winner yet, print "Keep going..." instead.

Sample Input 1:

9 3 2
Imgonnawin!
PickMe
PickMeMeMeee
LookHere
Imgonnawin!
TryAgainAgain
TryAgainAgain
Imgonnawin!
TryAgainAgain

Sample Output 1:

PickMe
Imgonnawin!
TryAgainAgain

Sample Input 2:

2 3 5
Imgonnawin!
PickMe

Sample Output 2:

Keep going... 
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<string>
using namespace std;
int main()
{int m,n,s,f=0,num=0;map<string,int> winner;cin>>m>>n>>s;string a;for(int i=0;i<m;i++){cin>>a;//cout<<a<<endl;if(f==0){num++;//cout<<num<<endl;if(num==s){cout<<a<<endl;num=0;f=1;winner[a]=1;}}else{if(winner.find(a)==winner.end()){num++;if(num==n){cout<<a<<endl;num=0;winner[a]=1;}}}}if(f==0)cout<<"Keep going..."<<endl;return 0;
}

1124. Raffle for Weibo Followers相关推荐

  1. 【PAT (Advanced Level) Practice】1124 Raffle for Weibo Followers (20 分)

    1124 Raffle for Weibo Followers (20 分) John got a full mark on PAT. He was so happy that he decided ...

  2. PAT甲级1124 Raffle for Weibo Followers :[C++题解]哈希表、微博转发抽奖

    文章目录 题目分析 题目来源 题目分析 来源:acwing 分析:开一个哈希表存已经中将的用户,避免重复发奖. 遍历所有m条姓名,从第一个中奖的开始,依次模拟即可. ac代码 #include< ...

  3. PAT 1124 Raffle for Weibo Followers python解法

    1124 Raffle for Weibo Followers (20 分) John got a full mark on PAT. He was so happy that he decided ...

  4. PAT 1124 Raffle for Weibo Followers

    PAT 1124 Raffle for Weibo Followers Java 1.题意 输入:数字m,n,s,一串人名. 第s个为获奖的人,则s+n 为下一个获奖的人,如果此人已经获奖,那么则往后 ...

  5. pat 1124 Raffle for Weibo Followers(20 分)

    1124 Raffle for Weibo Followers(20 分) John got a full mark on PAT. He was so happy that he decided t ...

  6. PAT_A 1124. Raffle for Weibo Followers (20)

    1124. Raffle for Weibo Followers (20) John got a full mark on PAT. He was so happy that he decided t ...

  7. 1124 Raffle for Weibo Followers (20 分)

    John got a full mark on PAT. He was so happy that he decided to hold a raffle(抽奖) for his followers ...

  8. 1124 Raffle for Weibo Followers(map)

    John got a full mark on PAT. He was so happy that he decided to hold a raffle(抽奖) for his followers ...

  9. PTA甲1124 Raffle for Weibo Followers (20 point(s))

    强烈推荐,刷PTA的朋友都认识一下柳神–PTA解法大佬 本文由参考于柳神博客写成 柳神的CSDN博客,这个可以搜索文章 柳神的个人博客,这个没有广告,但是不能搜索 还有就是非常非常有用的 算法笔记 全 ...

最新文章

  1. maven Ubuntu14.04 安装
  2. 从S3获取数据在html表示,AWS Lambda从DynamoDB加载内容,以S3格式显示在HTML中(示例代码)...
  3. 【Linux】一步一步学Linux——lastb命令(99)
  4. HDU - 5306 Gorgeous Sequence(吉司机线段树)
  5. OpenStack是什么?
  6. ZYNQ FPGA控制LED灯不闪烁
  7. 实现机器学习的循序渐进指南IV——逻辑回归
  8. 安装Python-2.5.2,并修改默认python版本
  9. Mybatis入门教程
  10. html视频怎么转换成图片,视频怎么转成gif格式 录制视频转gif图片用什么软件|gif动画录制工具...
  11. Android做一个WiFi信号测试,Android开发——WiFi信号检测
  12. 【线性代数】P7 方阵的行列式伴随矩阵
  13. 操作员或系统管理员_什么是系统管理员?
  14. 揭秘本世纪惊心动魄的粮食战争!中国反败为胜,但国际粮商仍未服输
  15. COLORMAP_JET的颜色规律
  16. 关于MMO游戏服务器从零开发基本内容介绍
  17. 创始人也会有的流量焦虑
  18. ixgbe 如何开启vf
  19. Servlet+常用头信息+响应状态码+响应对象
  20. Elasticsearch 如何实现时间差查询?

热门文章

  1. 在BRATS挑战赛中用于脑肿瘤分割、预后评估和总体生存预测的最佳机器学习算法
  2. 怎样做一个iOS App的启动分层引导动画?
  3. Flink界面提交任务报错500【The program plan could not be fetched】
  4. Ajax详解第六篇(jQuery实现Ajax)
  5. manjaro deepin 闪屏_微信聊天“闪屏”特效,整蛊效果100分!
  6. 中南大学计算机学院闭委,2019-2020计算机学院第一学期学委会议顺利召开
  7. 算法导论 — 比较排序算法对比实验
  8. 文明重启战局服务器维护中,王牌战争文明重启8月23日更新公告
  9. Java集合中Set
  10. Python学习笔记五:控制语句