其他分享
首页 > 其他分享> > pat乙级 1069 微博转发抽奖 (20 分) map映射

pat乙级 1069 微博转发抽奖 (20 分) map映射

作者:互联网

题目传送门

#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<map>
#include<string>
using namespace std;

int main()
{
    int M,N,S,i,j,flag=0;
    string str;
    map<string,int>mp;
    scanf("%d %d %d",&M,&N,&S);
    for(i=1;i<=M;i++){
        cin>>str;
        if(mp[str]==1&&i==S)S=S+1;
        else if(mp[str]==0&&i==S){
            mp[str]=1;
            cout<<str<<endl;
            flag=1;
            S=S+N;
        }
    }
    if(flag==0)cout<<"Keep going..."<<endl;

    return 0;
}

标签:1069,map,pat,&&,int,mp,str,include,cout
来源: https://blog.csdn.net/qq_45961907/article/details/122801882