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 ...
随机推荐
- PBO项目的组织
前言: 最近发现PMI的英文官网已经公布了第五版PMBOK的初稿,针对第四版而言的确有了不少变动.了解这些变动,对理解项目管理知识的整理和发展,以及掌握PMP考试的变化方向都是很重要的.当然,变动尤其 ...
- Java SPI、servlet3.0与@HandlesTypes源码分析
关于Java SPI与servlet3.0的应用,这里说的很精炼,链接地址如下. https://blog.csdn.net/pingnanlee/article/details/80940993 以 ...
- vue——同一局域网内访问项目
1.想要在手机上访问本地的vue项目,首先要保证手机和电脑处在同一局域网内(连着同一个无线网) 2.将你电脑的ip设置为固定ip(ipconfig查找本地的ip,然后修改它,改为你想变的数字) 3.在 ...
- Springboot项目的jar包目录结构
上图为一个由Luyten工具反编译后的一个jar包 说明: SpringBoot提供的bootstrap的类是放到包的最外面,比如上面的org.springframework.boot.loader. ...
- NOIP2018提高组初赛游记
AH省的,好像水军多,走的都比较早(莫非是真·大佬!!) 本人考了71,较去年退步了.(去年还考80多的来着) 题目坑.. 第一.二大题选择 第三题年份,看了试卷标题,第二十二届,算出来后没有这个选项 ...
- 该虚拟机似乎正在使用中。 如果该虚拟机未在使用,请按“获取所有权(T)”按钮获取它的所有权。否则,请按“取消(C)”按钮以防损坏。 配置文件: ***.vmx。
打开虚拟机的时候,出现这样的问题: 该虚拟机似乎正在使用中. 如果该虚拟机未在使用,请按“获取所有权(T)”按钮获取它的所有权.否则,请按“取消(C)”按钮以防损坏. 配置文件: D:\VM\wi ...
- [.Net Core 3.0从入门到精通]1.笔记简介及.Net Core3.0介绍
文章目的:.Net Core 3.0学习笔记整理与分享. 面向人群:有一定基础的C#开发人员或学习人员(C#语法一定要掌握). 笔者水平:中级C#开发攻城狮(水平有限,写的不对的地方希望大家指正). ...
- Prometheus(二):Prometheus 监控Windows机器
一.安装wmi-exporter 首先在需要监控的Windows机器上安装wmi_exporter.wmi_exporter下载地址:https://github.com/martinlindhe/w ...
- dom 创建时间
下面讲述如何在页面生成一个装有日期的盒子 首先写出一个日期的函数进行赋值使用document.createElement创建一个文档节点div,然后将时间函数输出在div之中,利用document.b ...
- Windows许可证即将过期怎么办?
最近在使用电脑的时候,一开机就会弹窗出现:Windows 许可证即将过期.我勒个去,windows还会过期啊. 我搜遍全网,发现了一个很棒的 Windows10 永久激活的工具,而且没有广告什么乱七八 ...