题目翻译:
给出M
个人,从第S
个人(包括他)开始,每N
个人中奖。每个人最多中奖一次,如果他已经中奖过了,又在中奖的位置,那么奖顺延给下一个人。按输入顺序输出中奖的人的名字
题解思路:
直接模拟
代码:
#include<bits/stdc++.h>
using namespace std;
map<string, bool> p;
int main()
{
int M, N, S;
cin >> M >> N >> S;
vector<string> s;
while (M--)
{
string t;
cin >> t;
s.push_back(t);
}
int tag = 0;
for (int i = S - 1;i < s.size();)
{
if (!p[s[i]])
{
tag = 1;
cout << s[i] << endl;
p[s[i]] = 1;
i += N;
}
else
i++;
}
if (!tag)
cout << "Keep going...";
}
坑点:
无