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 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 <algorithm>
#include <cstdio>
#include <cstring>
#include <map>
#include <stack>
#include <vector>
#include <queue>
#include <set>
using namespace std;
const int MAX = 1e3 + ; int m, n, s, cnt = ;
struct node
{
char s[];
}P[MAX], S[MAX];
set <string> st;
pair <set <string> :: iterator, bool> pr;
set <string> :: iterator iter; int main()
{
// freopen("Date1.txt", "r", stdin);
scanf("%d%d%d", &m, &n, &s);
for (int i = ; i <= m; ++ i)
scanf("%s", &P[i].s); for (int i = s; i <= m; i += n)
{
pr = st.insert(P[i].s);
if (pr.second)
{
strcpy(S[cnt ++].s, P[i].s);
continue;
}
while (i <= m)
{
++ i;
pr = st.insert(P[i].s);
if (pr.second)
{
strcpy(S[cnt ++].s, P[i].s);
break;
}
}
} if (cnt == )
{
printf("Keep going...\n");
return ;
}
for (int i = ; i < cnt; ++ i)
printf("%s\n", S[i].s);
return ;
}
pat 1124 Raffle for Weibo Followers(20 分)的更多相关文章
- 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 ...
- 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)
1124. Raffle for Weibo Followers (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN ...
- 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 ...
- 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 ...
- 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 ...
- 1124 Raffle for Weibo Followers
题意:水题,直接贴代码了.(为什么我第一遍做的时候代码写的那么烦?) 代码: #include <iostream> #include <string> #include &l ...
- PAT_A1124#Raffle for Weibo Followers
Source: PAT A1124 Raffle for Weibo Followers (20 分) Description: John got a full mark on PAT. He was ...
- PAT1124:Raffle for Weibo Followers
1124. Raffle for Weibo Followers (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN ...
随机推荐
- [Noip1997] 棋盘问题(2)
题目描述 在N×NN \times NN×N的棋盘上(1≤N≤10)(1≤N≤10)(1≤N≤10),填入1,2,…,N21,2,…,N^21,2,…,N2共N2N^2N2个数,使得任意两个相邻的数之 ...
- [BZOJ29957] 楼房重建 - 线段树
2957: 楼房重建 Time Limit: 10 Sec Memory Limit: 256 MBSubmit: 3294 Solved: 1554[Submit][Status][Discus ...
- POJ 1062 昂贵的聘礼(带限制条件的dijkstra)
题目网址:http://poj.org/problem?id=1062 题目: 昂贵的聘礼 Time Limit: 1000MS Memory Limit: 10000K Total Submis ...
- C#窗体练习:带历史信息的菜单
在开发图纸管理软件时,要求在菜单上记录用户最近打开的档案或图纸,以方便下次使用.单击“文件”菜单下的“打开文件”子菜单,打开需要查阅的图纸.下次运行该软件时,上次打开的文件名记录到“文件”菜单的历史菜 ...
- FTPClient连续读取文件
最近在使用FTPClient连续读取ftp上的多个文件内容时,遇到了两个问题: 1. 在for循环中,FTPClient只能读取到第一个文件内容,读取第二个时遇到NPE问题. 2. 遇到程序锁死. 下 ...
- 百万年薪python之路 -- 装饰器进阶
本文链接:https://blog.csdn.net/xiemanR/article/details/72510885 一:函数装饰函数 def wrapFun(func): def inner(a, ...
- 不想用锐捷怎么办?锐捷出问题|锐捷不能用怎么办?用menohust代替吧
首先获取 MentoHUST(代替锐捷网络认证客户端) V4.1.0.2001 绿色免费版 解压到任意目录 用管理员身份 启动 安装&卸载 .bat(右键用管理员运行) 这个文件可能乱码了 ...
- Java中数组操作 java.util.Arrays 类常用方法的使用
任何一门编程语言,数组都是最重要和常用的数据结构之一,但不同的语言对数组的构造与处理是不尽相同的. Java中提供了java.util.Arrays 类能方便地操作数组,并且它提供的所有方法都是静态的 ...
- Python进阶函数
一.函数的动态参数 之前我们说过了传参, 如果我们需要给一个函数传参, 而参数又是不确定的. 或者我给一个函数传很多参数, 我的形参就要写很多, 很麻烦, 怎么办呢. 我们可以考虑使用动态参数. 动态 ...
- python学习之【第十篇】:Python中的内置函数
1.前言 内置函数,就是Python内部预先定义好的函数,可以直接使用,Python中内置函数有以下这么多个: 2.map() 描述: map() 会根据提供的函数对指定序列做映射.第一个参数 fun ...