zl程序教程

您现在的位置是:首页 >  其他

当前栏目

1124 Raffle for Weibo Followers (20 分)【难度: 简单 / 知识点: 模拟】

知识点模拟 简单 for 20 难度
2023-09-11 14:15:52 时间

在这里插入图片描述
https://pintia.cn/problem-sets/994805342720868352/problems/994805350803292160

#include<bits/stdc++.h>
using namespace std;
const int N=1e3+10;
int n,k,st;
string s[N];
map<string,int>mp;
int main(void)
{
    cin>>n>>k>>st;
    for(int i=1;i<=n;i++) cin>>s[i];
    bool flag=0;
    for(int i=st;i<=n;i+=k)
    {
        if(!mp[s[i]]) cout<<s[i]<<endl,mp[s[i]]++,flag=1;
        else 
        {
            while(i<=n&&mp[s[i]]) i++;
            if(i<=n) cout<<s[i]<<endl,mp[s[i]]++,flag=1;
        }
    }
    if(!flag) puts("Keep going...");
    return 0;
}