Submission

Status:
[PPPPP][PPPPP]

Score: 100

User: Angonnyyy

Problemset: จุดแวะพัก

Language: cpp

Time: 0.026 second

Submitted On: 2025-03-16 17:58:00

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

int main(){
    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 level = 0;
        while(ss >> x){
            if(x == k){
                ans.insert({level, name});
                break;
            }
            level++;
        }
    }

    if(ans.empty()){
        cout << "-1";
        return 0;
    }
    int i =0;
    for(auto[a,b]:ans){
        cout << b << " ";
        i++;
        if(i==3) break;
    }

}