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 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...
题目大意:输出m,n,s分别表示转发微博的人数,寻找的跳数,初始winner,并且要求如果已经获过奖的就不能再获奖,下次遍历到它时就应该跳过。
//第一次我是这么想的,对所有重复转发的只记录第一次的转发,但是后来发现,这样:

因为初始获奖者跳过了Imgonnawin!用户,下一次再出现时我没有将其记录,就顺次到了下一位用户。这就出现了错误。
AC代码:
#include <iostream>
#include <map>
#include <cstdio>
#include <vector>
using namespace std;
map<string,int> mp;
vector<string> vt;
int main() {
int m,n,s;
cin>>m>>n>>s;
string name;
for(int i=;i<=m;i++){
cin>>name;
vt.push_back(name);//存都是要存起来的。
}
// cout<<endl;
int len=vt.size();
bool flag=false;
for(int i=s-;i<len;i+=n){
while(mp.count(vt[i])!=){
i++;
}
if(mp.count(vt[i])==){//如果它没有出现过
flag=true;
cout<<vt[i]<<'\n';
mp[vt[i]]=;//出现过。
}
} if(!flag)cout<<"Keep going...";
return ;
}
//这个题目真的是比较简单的,如果当前已经领过奖了,那么就一直跳过,如果没有出现过就输出并且标记,算是一星的难度吧。
1124 Raffle for Weibo Followers[简单]的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- PAT甲级 1124. Raffle for Weibo Followers (20)
1124. Raffle for Weibo Followers (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN ...
- 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 ...
- 1124 Raffle for Weibo Followers
题意:水题,直接贴代码了.(为什么我第一遍做的时候代码写的那么烦?) 代码: #include <iostream> #include <string> #include &l ...
- PAT1124:Raffle for Weibo Followers
1124. Raffle for Weibo Followers (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN ...
- PAT_A1124#Raffle for Weibo Followers
Source: PAT A1124 Raffle for Weibo Followers (20 分) Description: John got a full mark on PAT. He was ...
- 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 ...
随机推荐
- swift - UISwitch 的用法
具体代码如下,和oc的使用没有差别: 创建: let hswitch = UISwitch() /*创建开关,以及监听它值的改变,代码如下*/ //开关位置 hswitch.center = CGPo ...
- 查看网卡流量:nload
nload命令用于查看网卡流量,用法如下: [root@localhost ~]$ yum install -y epel-release [root@localhost ~]$ yum instal ...
- [SQL]躺着也中枪的datetime类型
写在前面 本来这个东西,我是不想在这里总结的,今天有初学者的朋友问我了,那就不得不说说了,你肯定也踩过这样的坑,没遇到,说明你运气好,编码习惯好.那还是言归正传吧.避免你中枪,还是扫一眼这篇文章吧. ...
- piblog 0.1
搭建开发环境首先,确认系统安装的Python版本是2.7.x. $ python --version Python 然后,安装开发Web App需要的第三方库:$ sudo pip install j ...
- 进程保护--CrossThreadFlags标志位
原理: 1. 将进程的所有线程的线程CrossThreadFlags标志位设置成Terminated或者System. 效果:任务管理器,WSYSCheck,ICESWORD无法结束进程.. 但PCH ...
- JavaScript实现本地图片上传预览功能(兼容IE、chrome、FF)
需要解决的问题有:本地图片如何在上传前预览.编辑:最近发现这个功能很多是基于flash实现的,很多JavaScript实现的代码兼容性都很差,特别是在IE和firefox和chrome三个浏览器上不兼 ...
- LeetCode——Add and Search Word - Data structure design
Description: Design a data structure that supports the following two operations: void addWord(word) ...
- LeetCode——House Robber
Description: You are a professional robber planning to rob houses along a street. Each house has a c ...
- api静态化预案
1.之前听到api静态化预案,一直以为是前端发送api请求,如果api请求失败,则再次发送一条请求,去请求备份的静态资源. 2.前两天了解到的api静态化预案是这样的:在请求api时,给api请求加上 ...
- sencha touch 入门系列 (四)sencha touch 新建项目目录结构解析
通过上一章节的操作,我们的项目已经创建完成了, 大家通过http://127.0.0.1/MyFirst/应该都已经访问到了自己的应用, 接下来,我们展开我们项目,如图所示: 一.目录结构 1. .s ...