PAT甲级: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:

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

思路

  1. 需要输出keep going… 的时候,一定是起始点没有在范围里,只需判断一下起始点的位置特判输出它。
  2. 接下来就直接按照题意进行编写。比较简单。

code

#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
using namespace std;
int main(){
int n_user = 0, step = 0, index = 0;
scanf("%d%d%d", &n_user, &step, &index);
vector<string> list(n_user);
unordered_map<string, bool> dic;
for(int i = 0; i < n_user; i++){
list[i].resize(25);
scanf("%s", &list[i][0]);
}
if(index - 1 >= list.size()){
printf("Keep going...");
return 0;
}
for(int i = index - 1; i < list.size(); ){
if(!dic[list[i]]){
dic[list[i]] = true;
printf("%s\n", list[i].c_str());
i += step;
}else i++;
}
return 0;
}

PAT甲级:1124 Raffle for Weibo Followers (20分)的更多相关文章

  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

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

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

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

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

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

  7. PAT甲级:1136 A Delayed Palindrome (20分)

    PAT甲级:1136 A Delayed Palindrome (20分) 题干 Look-and-say sequence is a sequence of integers as the foll ...

  8. PAT 甲级 1054 The Dominant Color (20 分)

    1054 The Dominant Color (20 分) Behind the scenes in the computer's memory, color is always talked ab ...

  9. PAT 甲级 1027 Colors in Mars (20 分)

    1027 Colors in Mars (20 分) People in Mars represent the colors in their computers in a similar way a ...

随机推荐

  1. Linux学习笔记:Linux命令之文件处理命令

    文件处理命令 touch 命令名称:touch 执行权限:所有用户 功能描述:创建空文件 语法:touch [文件名] touch创建文件的时候命名不推荐存在空格,如下面的情况 1touch prog ...

  2. selenium 隐式等待与显式等待

    1.隐式等待:driver.implicitly_wait() driver = webdriver.Chrome()driver.implicitly_wait(10)     #获取元素时最多会等 ...

  3. 一文讲全了Python 类和对象内容

    摘要:这是一个关于 Python 类和对象的全部内容. 本文分享自华为云社区<从零开始学python | Python 类和对象-面向对象编程>,原文作者:Yuchuan  . Pytho ...

  4. 【VBA】读取配置文件存入字典型变量中

    配置文件:  源码: Dim Co As Object '设为全局变量 Function 读取cfg() As Boolean Dim strcfg As String strcfg = " ...

  5. 配置IPv6公网地址DDNS并开放外网访问端口

    目前使用三大运营商宽带服务都会下发公网IPv6地址,这样我们想要在外网访问家里的路由.NAS等设备就可以直接通过IPv6地址来访问了.但是每次重新拨号后IPv6地址都会改变,而且IPv6的地址很长,这 ...

  6. IDEA2020.2版本设置类和方法的自定义注释模板

    IDEA是目前普遍使用的Java开发编辑器,添加自定义的注释模板,一方面便捷好用,另外一方面可以规范开发.IDEA中设置模板分两种:1.创建Java类的注释,2.方法的注释. 一.Java类的注释模板 ...

  7. 透彻详解(3)旁路电容100nF_0.1uF的由来计算

    原文地址点击这里: 前一节我们已经详细解释了旁路电容在数字电路系统中所起的基本且重要作用,即储能与为高频噪声电流提供低阻抗路径,尽管还并未给旁路电容的这些功能概括一个"高大上"的名 ...

  8. ASW 工作流最佳实践(二):使用 ASW 并发调用函数

    在音视频转码.ETL 作业处理.基因数据处理等诸多场景中,我们都可以通过工作流并行调用云函数,将任务进行并行处理,大大提高任务处理的吞吐量,满足应用场景的高实时性.高并发能力. 在<使用 ASW ...

  9. Vue(8)列表渲染v-for

    循环 在模板中可以用v-for指令来循环数组,对象等. 循环数组 我们可以用 v-for 指令基于一个数组来渲染一个列表.v-for 指令需要使用 item in items形式的特殊语法,其中 it ...

  10. Task异常捕获的方式

    这节来讲一下如果捕获Task的异常. 当Task运行中出现了异常,正常情况下我们在主线程的Try是捕获不到的,而如果在Task内部写try,出现了异常我们会完全不知道.下面就来介绍几个主线程捕获Tas ...