PAT甲级 1124 - Raffle for Weibo Followers

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Mr0cheng/article/details/79415707
#include<bits/stdc++.h>
using namespace std;
const int maxn=1000+3;
set<string> se;
string str[maxn];
vector<string> vec;
int main(){
  int m,n,s;
  scanf("%d %d %d",&m,&n,&s);
  for(int i=1;i<=m;++i){
    cin>>str[i];
  }

  bool flag=false;
  set<string>::iterator it;
  while(s<=m){
    while(se.find(str[s])!=se.end() && s<=m){
      ++s;
    }
    if(s<=m){
      flag=true;
      vec.push_back(str[s]);
      se.insert(str[s]);
      s+=n;
    }else{
      break;
    }
  }
  for(vector<string>::iterator its=vec.begin();its!=vec.end();++its){
    cout<<*its<<endl;
  }
  if(!flag)cout<<"Keep going..."<<endl;
  return 0;
}

猜你喜欢

转载自blog.csdn.net/Mr0cheng/article/details/79415707