照题意模拟即可,可用map来存储姓名是否获奖。
#include <cstdio>
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main(){
int m, n, s;
scanf("%d %d %d", &m, &n, &s);
map<string,int> ma;
string str;
int ans;
int flag = 0;
for(int i=1; i<=m; i++){
cin >> str;
if(i == s){
cout << str << endl;
flag = 1;
ma[str]++;
ans = 0;
}
if(i > s){
ans++;
if(ans % n == 0){
if(ma[str] != 0){
ans--;
continue;
}else{
cout << str << endl;
ma[str]++;
}
}
}
}
if(!flag){
printf("Keep going...");
}
return 0;
}