Submission

Status:
[PPPPP][PPPPP]

Score: 100

User: Jibhong

Problemset: จุดแวะพัก

Language: cpp

Time: 0.007 second

Submitted On: 2025-03-24 10:10:06

#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
// map<int,vector<string>>mp;
vector<pair<int,string>>out;
int main(){
    ios::sync_with_stdio(0);cin.tie(0);
    int n,q;
    cin>>n>>q;
    cin.ignore();
    for(int i=0;i<n;++i){
        string inp;
        getline(cin,inp);
        stringstream ss;
        string e;
        ss<<inp;
        bool gay=0;
        int cnt=0;
        string name;
        while(ss>>e){
            if(!gay){
                name=e;
                gay=1;
                continue;
            }
            if(stoi(e)!=q){
                ++cnt;
                continue;
            }  
            out.emplace_back(cnt,name);
            break;
        }
        
    }
    if(out.empty()){
        cout<<-1;
        return 0;
    }
    sort(out.begin(),out.end());
    int cnt=0;
    for(auto e:out){
        ++cnt;
        cout<<e.S<<' ';
        if(cnt==3)break;
    }
    return 0;
}