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 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 <algorithm>
  3. #include <cstdio>
  4. #include <cstring>
  5. #include <map>
  6. #include <stack>
  7. #include <vector>
  8. #include <queue>
  9. #include <set>
  10. using namespace std;
  11. const int MAX = 1e3 + ;
  12.  
  13. int m, n, s, cnt = ;
  14. struct node
  15. {
  16. char s[];
  17. }P[MAX], S[MAX];
  18. set <string> st;
  19. pair <set <string> :: iterator, bool> pr;
  20. set <string> :: iterator iter;
  21.  
  22. int main()
  23. {
  24. // freopen("Date1.txt", "r", stdin);
  25. scanf("%d%d%d", &m, &n, &s);
  26. for (int i = ; i <= m; ++ i)
  27. scanf("%s", &P[i].s);
  28.  
  29. for (int i = s; i <= m; i += n)
  30. {
  31. pr = st.insert(P[i].s);
  32. if (pr.second)
  33. {
  34. strcpy(S[cnt ++].s, P[i].s);
  35. continue;
  36. }
  37. while (i <= m)
  38. {
  39. ++ i;
  40. pr = st.insert(P[i].s);
  41. if (pr.second)
  42. {
  43. strcpy(S[cnt ++].s, P[i].s);
  44. break;
  45. }
  46. }
  47. }
  48.  
  49. if (cnt == )
  50. {
  51. printf("Keep going...\n");
  52. return ;
  53. }
  54. for (int i = ; i < cnt; ++ i)
  55. printf("%s\n", S[i].s);
  56. return ;
  57. }

pat 1124 Raffle for Weibo Followers(20 分)的更多相关文章

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

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

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

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

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

  5. 1124 Raffle for Weibo Followers[简单]

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

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

  7. 1124 Raffle for Weibo Followers

    题意:水题,直接贴代码了.(为什么我第一遍做的时候代码写的那么烦?) 代码: #include <iostream> #include <string> #include &l ...

  8. PAT_A1124#Raffle for Weibo Followers

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

  9. PAT1124:Raffle for Weibo Followers

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

随机推荐

  1. 一个关于内联优化和调用约定的Bug

    很久没有更新博客了(博客园怎么还不更新后台),前几天在写一个Linux 0.11的实验 [1] 时遇到了一个奇葩的Bug,就在这简单记录一下调试过程吧. 现象 这个实验要求在Linux 0.11中实现 ...

  2. 两分钟让你明白Go中如何继承

    最近在重构代码的时候,抽象了大量的接口.也使用这些抽象的接口做了很多伪继承的操作,极大的减少了代码冗余,同时也增加了代码的可读性. 然后随便搜了一下关于Go继承的文章,发现有的文章的代码量过多,并且代 ...

  3. 从Go语言编码角度解释实现简易区块链

    区块链技术 人们可以用许多不同的方式解释区块链技术,其中通过加密货币来看区块链一直是主流.大多数人接触区块链技术都是从比特币谈起,但比特币仅仅是众多加密货币的一种. 到底什么是区块链技术? 从金融学相 ...

  4. 解决IDEA下SpringBoot启动没有Run Dashboard并找回

    前两天看到别人SpringBoot启动服务,启动器是长这样的 而我的呢?是这样的 Run Dashboard 它是一个代替Run窗口的一个更好清晰简洁的一个启动器. 如果我们需要启动多个窗口时,Run ...

  5. JAVA aio简单使用

    使用aio,实现客户端和服务器 对一个数进行轮流累加 //服务器端 public class Server { private static ExecutorService executorServi ...

  6. 包+time+datetime+random+hashlibhmac+typing+requests+re模块(day17整理)

    目录 昨日内容 os模块 sys模块 json模块 pickle模块 logging模块 今日内容 包 相对导入 绝对导入 time模块 sleep 时间戳 time 格式化时间 strtime 结构 ...

  7. 课堂动手动脑验证以及自定义异常类实现对异常处理——java异常类

    异常(exception):发生在程序执行期间,表明出现了一个非法运行的情况.许多JDK中的方法在检测到非法情况时,都会抛出一个异常对象.例如:数组越界和被0除. 代码验证: package test ...

  8. Java基础(二十七)Java IO(4)字符流(Character Stream)

    字符流用于处理字符数据的读取和写入,它以字符为单位. 一.Reader类与Writer类 1.Reader类是所有字符输入流的父类,它定义了操作字符输入流的各种方法. 2.Writer类是所有字符输出 ...

  9. Java基础(十七)日志(Log)

    1.日志的概念 在调试有问题的代码时,经常需要插入一些System.out.println方法来观察程序运行的操作过程.但是,一旦发现了问题并且解决了问题,就需要将这些System.out.print ...

  10. 蓝桥杯基础练习 Huffuman树

    基础练习 Huffuman树 问题描述 Huffman树在编码中有着广泛的应用.在这里,我们只关心Huffman树的构造过程. 给出一列数{pi}={p0, p1, -, pn-1},用这列数构造Hu ...