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:

  1. 9 3 2
  2. Imgonnawin!
  3. PickMe
  4. PickMeMeMeee
  5. LookHere
  6. Imgonnawin!
  7. TryAgainAgain
  8. TryAgainAgain
  9. Imgonnawin!
  10. TryAgainAgain

Sample Output 1:

  1. PickMe
  2. Imgonnawin!
  3. TryAgainAgain

Sample Input 2:

  1. 2 3 5
  2. Imgonnawin!
  3. PickMe

Sample Output 2:

  1. Keep going...
  1. #include <iostream>
  2. #include <unordered_map>
  3. #include <string>
  4. using namespace std;
  5. int m, k, s;
  6. int main()
  7. {
  8. cin >> m >> k >> s;
  9. unordered_map<string,int>res;
  10. string str;
  11. for (int i = ; i <= m; ++i)
  12. {
  13. cin >> str;
  14. if (i == s)
  15. {
  16. if (res[str] == )//输出过
  17. s++;//后移动
  18. else
  19. {
  20. cout << str << endl;
  21. res[str] = ;
  22. s += k;
  23. }
  24. }
  25. }
  26. if (res.size() == )
  27. cout << "Keep going..." << endl;
  28. return ;
  29. }

PAT甲级——A1124 Raffle for Weibo Followers的更多相关文章

  1. PAT甲级 1124. Raffle for Weibo Followers (20)

    1124. Raffle for Weibo Followers (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN ...

  2. PAT A1124 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 ...

  3. A1124. Raffle for Weibo Followers

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

  4. PAT_A1124#Raffle for Weibo Followers

    Source: PAT A1124 Raffle for Weibo Followers (20 分) Description: John got a full mark on PAT. He was ...

  5. PAT甲级:1124 Raffle for Weibo Followers (20分)

    PAT甲级:1124 Raffle for Weibo Followers (20分) 题干 John got a full mark on PAT. He was so happy that he ...

  6. PAT 1124 Raffle for Weibo Followers

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

  7. 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 ...

  8. 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 ...

  9. PAT1124:Raffle for Weibo Followers

    1124. Raffle for Weibo Followers (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN ...

随机推荐

  1. nodejs MYSQL数据库执行多表查询

    1.设计数据库 2.设计数据库表 genres表: books表: 3.安装MySQL模块 4. 代码编写 (1) 第一种方法: 在query中使用nextTables属性,将属性值设置为ture d ...

  2. 41. wait notify 方法

    wait()  等待,如果一个线程执行了wait方法,那么该线程就会进去一个以锁对象为标识符的线程池中等待 notity() 唤醒,如果一个线程执行了notity方法,那么就会唤醒以锁对象为标识符的线 ...

  3. Python 刷题知识点

    if : elif : else : print('{0} \n{1} \n{2}' .format((a + b), (a - b), (a * b))) print(*[num**2 for nu ...

  4. re.match与re.search的区别

    re.match与re.search的区别 re.match只匹配字符串的开始,如果字符串开始不符合正则表达式,则匹配失败,函数返回None:而re.search匹配整个字符串,直到找到一个匹配. 实 ...

  5. delphi根据不同图片生成不规则窗口的实现(仅限于BMP格式)

    unit CreateImageForm; interface uses Windows, SysUtils, Variants, Classes, Graphics; procedure Creat ...

  6. Delphi ADOQuery

    Delphi ADOQuery procedure TForm1.Button1Click(Sender: TObject); var A: Array of String;//定义动态数组 Inde ...

  7. sqoop一些常用命令及参数

    常用命令列举 这里给大家列出来了一部分Sqoop操作时的常用参数,以供参考,需要深入学习的可以参看对应类的源代码. 序号 命令 类 说明 1 import ImportTool 将数据导入到集群 2 ...

  8. NX二次开发-UFUN读取表格注释内容UF_TABNOT_ask_cell_text

    NX11+VS2013 #include <uf.h> #include <uf_ui.h> #include <uf_tabnot.h> #include < ...

  9. Python字典列表字段重组形成新的字典

    最近遇到这样一个需求,需要将字典列表中的字段进行重组,形成一个新的字典.举个例子吧: l1 = [{"x": 22, "y": 22, "demand ...

  10. JavaScript笔记 – 程序语法设计

    一.基础语法设计 JavaScript是可以与HTML标记语言混合.用于网页交互式的解释型脚本语言.由国际标准ECMAScript提供核心语言功能.文档对象模型(DOM)提供访问和操作网页内容的方法和 ...