Submission

Status:

[P-SSS][PPP-S]

Subtask/Task Score:

{0/50}{0/50}

Score: 0

User: solarsunny

Problemset: จุดแวะพัก

Language: cpp

Time: 0.007 second

Submitted On: 2025-10-22 23:21:42

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



int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    int k;
    cin >> n >> k;
    vector<pair<int,string>> c; // first pair is dist till k and second on is name;
    for(int i=0; i<n; i++) {
        string cus;
        getline(cin, cus);
        istringstream ss(cus);
        string name;
        ss >> name;
        int x;
        int d=0;
        bool success = false;
        while(ss >> x) {
            d++;
            if(x==k) {
                success = true;
                break;
            }
        }
        if(success) {
            c.push_back(make_pair(d,name));
        }

    }
    sort(c.begin(),c.end());
    for(int i=0; i<3 && i<c.size(); i++) {
        cout << c[i].second << " ";
    }
    cout << "\n";
    return 0;
}

/*

5 7
taohu 0 1 7 9
mafuyu 2 5
ccsleep 2 4 7 25
sira 7
iris 32 64 128


*/