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

——————————————————————————————

题目的意思是给出n个人名字,每个m个人抽奖和抽奖起始点st,输出中奖的人名字,如果重复则下一个

思路:直接暴力,将中奖的人名字扔到一个set里面,每次先判断

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
#define LL long long
const int inf=0x3f3f3f3f; string str[1005]; int main()
{
int n,m,st;
scanf("%d%d%d",&n,&m,&st);
for(int i=1; i<=n; i++)
cin>>str[i];
set<string>s;
s.clear();
int flag=0;
for(int i=st; i<=n; i+=m)
{
while(s.count(str[i])==1&&i<=n)
{
i++;
}
if(i>n)
break;
s.insert(str[i]);
flag=1;
cout<<str[i]<<endl;
}
if(flag==0)
cout<<"Keep going..."<<endl;
return 0;
}

  

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甲级——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. 1124 Raffle for Weibo Followers

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

  8. PAT1124:Raffle for Weibo Followers

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

  9. PAT_A1124#Raffle for Weibo Followers

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

随机推荐

  1. Oracle_高级功能(6) 分区

    oracle分区表1.分区表: 当表中的数据量不断增大,查询数据的速度就会变慢,应用程序的性能就会下降,这时就应该考虑对表进行分区. 表进行分区后,逻辑上表仍然是一张完整的表,只是将表中的数据在物理上 ...

  2. hdu 1429 (bfs+状态压缩) 胜利大逃亡续

    http://acm.hdu.edu.cn/showproblem.php?pid=1429 典型的状压搜索,在普通的搜索基础上,利用二进制的特性记录钥匙与门, 二进制的每一位代表一把钥匙,比如说拿到 ...

  3. BPF+XDP比较全的资料都在这里

    Dive into BPF: a list of reading material Sep 1, 2016 • Quentin Monnet◀Table of contents What is BPF ...

  4. The valid characters are defined in RFC 7230 and RFC 3986问题

    这个问题困扰了我接近两天了!尼玛!网上搜了很多资料,有的给出了解决方案,然后下面的评论说按照楼主做的,没有成功,我一做也确实没有成功.设置了断点,一步一步跟进去看,还是没有头绪.不过有一点可以确认的是 ...

  5. CF Round #516 (Div. 2, by Moscow Team Olympiad)

    前言:依旧菜,\(A\)了\(4\)题,不过这次上蓝了挺开心的. A. Make a triangle! Description 给出\(3\)根木棍,希望用它们拼成三角形,可以将其中的某些木棍增长, ...

  6. day2-pycharm创建项目,driver下载和浏览器设置

    对于ie需要设置,才能使用ie做测试 火狐的使用不能超过43版本,ie11现在有多次弹出alert无法识别其内容的问题 https://github.com/SeleniumHQ/selenium/w ...

  7. sleep()方法和yield()方法有什么区别?

    两者都是Thread类的静态方法,定义如下 public static void sleep(long millis) throws InterruptedException public stati ...

  8. IOS初级:AFNetworking

    狗 日的,第三方框架真j8难搞 1.为什么NS_ASSUME_NONNULL_BEGIN在6.2报错,你他么的还挑IDE,你这是什么态度? 2.还有,你他么的自动给老子转json了,有问过我么? #i ...

  9. Python 解释器介绍

    举个栗子: -c cmd用法 python -c ' import os ; print ("is ok ") ' 或者(注意引号形式) python -c "impor ...

  10. SparkStreaming 监控文件目录

    SparkStream 监控文件目录时,只能监控文件内是否添加新的文件,如果文件名没有改变只是文件内容改变,那么不会检测出有文件进行了添加. )) )).reduceByKey(_ + _) word ...