您的位置:首页 > 其它

PAT 1124. Raffle for Weibo Followers (20) 模拟微博抽奖,Set应用

2018-01-26 00:41 525 查看
/*************************
题意:
微博,跳跃式的获奖
注意一个人只能获得一次
************************/
/***********************
解题思路:

*************************/
/***********************

*********************/
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<queue>
#include<stdlib.h>
#include<algorithm>
#include<string.h>
#include<stack>
#include<map>
#include<set>
#include<unordered_map>
using namespace std;
#define M 10005
#define INF 0x7ffffff

string s[M];
set<string> Set;
int main(){
int n,k, first, i ;
cin>>n>>k>>first;
for(i=0;i<n;i++){
cin>>s[i];
}

int p ;
if(first > n)
cout<<"Keep going..."<<endl;
else{
p = first - 1;
while(p < n){
if(Set.find(s[p]) == Set.end()){
cout<<s[p]<<endl;
Set.insert(s[p]);
p += k;
}else p++;
}
}

return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: