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

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...
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int m, n, s;
    string st;
    cin >> m >> n >> s;
    vector<string> v;
    map <string, bool> ma;
    for (int i = 0; i < m; i++) {
        cin >> st;
        v.push_back(st);
    }
    for (int i = s-1; i < v.size(); i = i + n) {
        while(ma[v[i]]){
            i++;
        }
        cout << v[i] << endl;
        ma[v[i]] = true;
    }
    if(m < s) cout << "Keep going...\n";
    
    return 0;
}

目录
相关文章
|
7月前
|
前端开发
仿新浪sina轻个人微博html静态网页模板
一款最新的仿新浪sina个人微博html静态网页模板(轻博客/轻微博/贴吧主页、qq社交空间主题),模板清新简洁、新颖,包含关注、粉丝、人气、个人资料、文章、视频等。
75 0
|
JavaScript PHP 数据安全/隐私保护
Python模拟登陆 —— 征服验证码 9 微博weibo.com
登录界面 抓包分析可以使用Http Analyzer,Filders,但是看起来很复杂,还是使用火狐好(chrome远远没有火狐好用)。 首先,在输入用户名后,会进行预登录,网址为:http://login.
1525 0
|
7月前
|
API
新浪weibo4android的一个比较重大的问题(原创)
新浪weibo4android的一个比较重大的问题(原创)
36 4
|
存储 C++
【PAT甲级 - C++题解】1076 Forwards on Weibo
【PAT甲级 - C++题解】1076 Forwards on Weibo
60 0
|
存储 C++
【PAT甲级 - C++题解】1124 Raffle for Weibo Followers
【PAT甲级 - C++题解】1124 Raffle for Weibo Followers
72 0
|
SQL 存储 中间件
【hacker101 CTF】Photo Gallery
【hacker101 CTF】Photo Gallery
148 0
WeiBo开发经历(下)
WeiBo开发经历(下)
181 0
WeiBo开发经历(下)
|
Windows
WeiBo开发经历(中)
WeiBo开发经历(中)
95 0
WeiBo开发经历(中)
【1076】Forwards on Weibo (30 分)
【1076】Forwards on Weibo (30 分) 【1076】Forwards on Weibo (30 分)
87 0