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 ...
随机推荐
- Android Studio 1.5运行问题
Error:Unable to start the daemon process: could not reserve enough space for object heap.Please assi ...
- 动画讲解TCP
前言 TCP 三次握手过程对于面试是必考的一个,所以不但要掌握 TCP 整个握手的过程,其中有些小细节也更受到面试官的青睐. 对于这部分掌握以及 TCP 的四次挥手,小鹿将会以动画的形式呈现给每个人, ...
- Cocos2d-x 学习笔记(15.3) EventDispatcher DirtyFlag 脏标记
1. 定义 用枚举定义脏标记的4种类型. enum class DirtyFlag { NONE = , FIXED_PRIORITY = << , SCENE_GRAPH_PRIORIT ...
- opencv实践::透视变换
问题描述 拍摄或者扫描图像不是规则的矩形,会对后期处理产生不 好影响,需要通过透视变换校正得到正确形状. 解决思路 通过二值分割 + 形态学方法 + Hough直线 +透视变换 #include &l ...
- 概念理解-异步IO
#include <aio.h> /* 函数名 :int aio_write(struct aiocb *aiocbp) 参 数 :struct aiocb *aiocbp 返回值 :执行 ...
- C# Halcon混合编程中遇到的问题(一)
目标平台 安装64位的halcon的情况下,目标平台必须使用x64而不能使用x86 目标框架 不能使用.Net Framework Client版本,有一些必须的程序集会缺失,测试使用.Net Fra ...
- 基于docker的mysql8的主从复制
基于docker的mysql8的主从复制 创建mysql的docker镜像 构建docker镜像,其中数据卷配置内容在下面,结构目录如下 version: '3.7' services: db: # ...
- Centos 新建用户
Centos 新建用户 为什么要新建用户? 因为root的权限太多,不方便多人多角色使用,所以添加一个用户 添加用户 新建用户 adduser '用户名' 添加用户密码 passwd '用户名' 输入 ...
- 一文读懂Java类加载机制
Java 类加载机制 Java 类加载机制详解. @pdai Java 类加载机制 类的生命周期 类的加载:查找并加载类的二进制数据 连接 验证:确保被加载的类的正确性 准备:为类的静态变量分配内存, ...
- django-模板之include标签(十五)
就是将一些常用的html代码分离出来,使其可以重复利用,减少代码量 index.html <!DOCTYPE html> <html lang="en"> ...