1124. Raffle for Weibo Followers (20)

时间限制
400 ms
内存限制
65536 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Yue

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.map模拟一个字典dic记录该用户是否领过奖。
2.用一个bool值hasWinner来标记是否有人获过奖。 代码
#include<iostream>
#include<vector>
#include<map>
using namespace std;
int main()
{
int M,N,S;
while(cin >> M >> N >> S)
{
vector<string> List(M + );
map<string,int> dic;
bool hasWinner = false;
for(int i = ;i <= M;i++)
{
cin >> List[i];
} for(int i = S;i <= M;i += N)
{
while(dic.count(List[i]) > && i <= M) i++;
if(i > M) break;
hasWinner = true;
cout << List[i] << endl;
dic[List[i]]++;
}
if(!hasWinner)
cout << "Keep going..." << endl;
}
}

PAT1124:Raffle for Weibo Followers的更多相关文章

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

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

  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[简单]

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

  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_A1124#Raffle for Weibo Followers

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

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

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

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

随机推荐

  1. 对Java配置文件中敏感信息进行加解密的工具类

    在 JavaEE 配置文件中,例如 XML 或者 properties 文件,由于某些敏感信息不希望普通人员看见,则可以采用加密的方式存储,程序读取后进行解密. 常见的如: 数据库用户密码,短信平台用 ...

  2. STL常用排序算法介绍

    merge()  以下是排序和通用算法:提供元素排序策略  merge: 合并两个有序序列,存放到另一个序列. #include <iostream> #include <cstdi ...

  3. Callable与Future

    本文可作为传智播客<张孝祥-Java多线程与并发库高级应用>的学习笔记. 在前面写的代码中,所有的任务执行也就执行了,run方法的返回值为空. 这一节我们说的Callable就是一个可以带 ...

  4. Java-Filter-FilterChain-FilterConfig源码

    public interface Filter { /** * Called by the web container to indicate to a filter that it is being ...

  5. VirtualBox安装RHEL之后配置桥接网络

    VirtualBox安装RHEL之后配置桥接网络 1 如果主机是Intel (R) Ethernet Connection I217-LM上网的: 2 如果主机是无线上网的, 如ipconfig显示如 ...

  6. Material Design之视图状态改变

    视图状态改变是通过StateListAnimator动画集来改变View的状态的,它可以使View在不同状态下发生不同的变化,如下是在drawable目录下定义一个StateListAnimator: ...

  7. 43个优秀的Swift开源项目推荐

    "轮子" 工具类 项目 开发者 备注 SwiftyJSON tangplin, lingoer GitHub 上最为开发者认可的 JSON 解析类 Dollar.swift Ank ...

  8. 字符编辑技术C语言实现

    #include<string.h> #include<ctype.h> #include<stdio.h> /*插入函数 ccode待插入的字符 anystrin ...

  9. LeetCode(35)-Path Sum

    题目: Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up ...

  10. MATLAB坐标系中绘制图片

    MATLAB坐标系中绘制图片 方法一 使用图片坐标循环的方式,代码如下. clear,clc,close all tic; map=imbinarize(imread('map.bmp'));%map ...