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. IaaS、PaaS 和 SaaS:云服务模型概述

    IaaS.PaaS 和 SaaS:云服务模型概述 为您的组织选择合适的云服务模型,可以帮助您充分利用预算和 IT 资源. 基础设施即服务 (IaaS).平台即服务 (PaaS) 以及软件即服务 (Sa ...

  2. JUC 并发编程--03, 深刻理解锁, 8 锁现象,

    如何判断锁的是谁? 永远知道是什么锁, 线程8锁:就是关于锁的8个问题 问题1: public class LockDemo01 { public static void main(String[] ...

  3. Task04:集合运算

    4.1 表的加减法 4.1.1 什么是集合运算 集合在数学领域表示"各种各样的事物的总和", 在数据库领域表示记录的集合. 具体来说,表.视图和查询的执行结果都是记录的集合, 其中 ...

  4. 【NX二次开发】分析曲线某位置的信息 UF_MODL_ask_curve_props

    分析曲线某位置的信息:点.切线.主副法线.半径等 extern DllExport void ufsta(char *param, int *returnCode, int rlen) { UF_in ...

  5. Pytorch CNN网络MNIST数字识别 [超详细记录] 学习笔记(三)

    目录 1. 准备数据集 1.1 MNIST数据集获取: 1.2 程序部分 2. 设计网络结构 2.1 网络设计 2.2 程序部分 3. 迭代训练 4. 测试集预测部分 5. 全部代码 1. 准备数据集 ...

  6. UNREFERENCED_PARAMETER的用处

    UNREFERENCED_PARAMETER的用处 作用:告诉编译器,已经使用了该变量,不必检测警告! 在VC编译器下,如果您用最高级别进行编译,编译器就会很苛刻地指出您的非常细小的警告.当你生命了一 ...

  7. PL/SQL连不上,报 ORA-12170:TNS 连接超时

    排错步骤: 1.查看网络是否通畅 打开cmd, ping 数据库IP 2. 查看端口是否通畅 打开cmd,tnsping 数据库IP 如果piing不通,可能是防火墙问题 3.检查防火墙状态 #ser ...

  8. JNI相关笔记 [TOC]

    JNI相关笔记 目录 JNI相关笔记 1 生成native code所需要的头文件 2 JNI提供的一些函数和方法 3 局部引用,全局引用,全局弱引用. 4 异常 1 生成native code所需要 ...

  9. 环境安装——MySQL安装

    @ 目录 一文教会你安装与卸载MySQL 1. 官网下载 2. 文件下载 3. 卸载步骤 4. 安装步骤 5. MySQL配置 6. 安装出现的问题 6.1 如果出现了最后一步卡死的状态的话,不要慌: ...

  10. 二、JavaSE语言基础之常量与变量

    1.常量   所谓常量值的是数据处理过程中值不能更改的数据. 2.变量   所谓变量值的是运算过程中值可以改变的数据,类似于代数中的未知数.   在Java语言中,使用变量时必须遵循先定义,而后赋值, ...