Submission

Status:
[PPPPP][PPPPP]

Score: 100

User: Nathlol2

Problemset: จุดแวะพัก

Language: cpp

Time: 0.008 second

Submitted On: 2025-03-16 16:16:30

#include <bits/stdc++.h>
using namespace std;

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, k;
    cin >> n >> k;
    cin.ignore();
    string s;
    set<pair<int, string>> ans;    
    for(int i = 0;i<n;i++){
        getline(cin, s);
        istringstream ss(s);
        string name;
        ss >> name;
        int x;
        int idx = 0;
        while(ss >> x){
            if(x == k){
                ans.insert({idx, name});
                break;
            }
            idx++;
        }
    }
    if(ans.size() == 0){
        cout << "-1\n";
        return 0;
    }
    int idk = 0;
    for(auto [a, b] : ans){
        cout << b << " ";
        idk++;
        if(idk == 3){
            break;
        }
    }
}