题目
思路
水题
代码
#include <iostream>
#include <vector>
#include <unordered_set>
using namespace std;
unordered_set<string> ss;
vector<string> winner;
int main()
{
int m, n, s;
cin >> m >> n >> s;
int cnt = 1;
if (s > m ) {
cout << "Keep going...";
return 0;
}
string str;
for (int i = 1; i < s; ++i)
cin >> str;
cin >> str;
ss.emplace(str);
winner.emplace_back(str);
for (int i = s+1; i <= m; ++i) {
cin >> str;
if (cnt != n) {
cnt++;
continue;
}
auto p = ss.find(str);
if (p == ss.end()) {
ss.emplace(str);
winner.emplace_back(str);
cnt = 1;
}
}
for (auto& p :winner) {
cout << p << endl;
}
return 0;
}