别人博客学习到思路
里面用到STL里面的Map
是一对一的映射关系,一串字符串可以作为内容去对应
#include<stdio.h>
#include<vector>
#include<map>
#include<iostream>
using namespace std;int m,n,s;
map<string,bool> msb;
vector<string> vs;int main()
{cin >> m >> n >> s;vs.push_back(" ");//vs[0] string st;for(int i=0;i<m;i++){cin >> st;vs.push_back(st);msb[st] = false;}int i = s;if(vs.size()-1<s){cout << "Keep going..." << endl;return 0;}while(i<=m){if(msb[vs[i]]==false){cout << vs[i] << endl;msb[vs[i]] = true;i+=n;}else{i++;} } return 0;
}