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 ...
随机推荐
- java与java web数组括号的不同
由于之前学JAVA SE数组时习惯了数组括号的写法,到了Web这里写了有点不太习惯了,赶快写篇博客加深一下印象哈 一. java和java web中的数组的不同 java: int[] arr = n ...
- Uipath 获取当前浏览器页面URL
文章来源东京IT青年前线 http://www.rpatokyo.com Uipath 获取当前浏览器页面URL的方法 Inject Js Script 因为目前没有直接获取页面URL的Act ...
- Linux用到的常用命令
Linux常用命令
- 图像处理 - ImageMagick 简单介绍与案例
在客户端我们可以用 PhotoShop 等 GUI 工具处理静态图片或者动态 GIF 图片,不过在服务器端对于 WEB 应用程序要处理图片格式转换,缩放裁剪,翻转扭曲,PDF解析等操作, GUI 软件 ...
- ESP8266开发之旅 应用篇① 局域网应用 ——炫酷RGB彩灯
1.前言 这一篇,博主将教大家怎么去实现一个WiFi RGB彩灯. 先来一个博主已经实现功能的图片,如下: 当然,博主也拍了运行视频,请点击 传输门. 1.1 知识储备 ...
- 小程序预览pdf文件
有个业务需求,需要在小程序查看客户已开的发票 发票地址: https://www.chinaeinv.com/p.jspa?cxxxxxxxxxxxx 刚开始是想利用webview当作外链进行跳转访问 ...
- 基于STM32F103和Cube的输入捕获例程
1.开发环境 (1)Cube5.24 (2)Keil5 (3)STM32F103 2.Cube配置 Cube配置很简单,只要打开TIM4通道1的引脚,设置为输入捕获模式,在配置是高或低电平沿触发 TI ...
- CMMS系统中工单派案&调度
系统为客户经理提供一个有效的调度控制台,由客户经理负责将需要外派现场处理的工单进行统一的分配调度,系统显示每个技术人员的时间表,根据专业技能.可用性.距离或其他资格标准筛选技术服务人员,并向调度人员提 ...
- 设计模式(十七)Observer模式
在Observer模式中,当观察对象的状态发生变化时,会通知给观察者.Observer模式适用于根据对象状态进行相应处理的场景. 首先看一下示例程序的视图. 然后用实际代码来理解这种设计模式. pac ...
- beanFactory 设计模式 Bean 生命周期的胡言乱语,哈哈
写在前面的话 适用读者:有一定经验的,本文不适合初学者,因为可能不能理解我在说什么 文章思路:不会一开始就像别的博客文章那样,Bean 的生命周期,源码解读(给你贴一大堆的源码).个人觉得应该由问题驱 ...