Submission

Status:

[PPPPP][-SSSS]

Subtask/Task Score:

{50/50}{0/50}

Score: 50

User: Quaoar

Problemset: จุดแวะพัก

Language: cpp

Time: 0.014 second

Submitted On: 2026-03-10 20:18:40

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

int main(){
    int n , k;
    cin >> n >> k;
    vector <pair<int , string>>arr;
    vector <int> t;
    for (int i = 0 ; i < n ; i++){
        string name;
        cin >> name;
        string a;
        cin.ignore();
        getline(cin, a);

        stringstream ss(a);
        int num;

        while (ss >> num) {
            t.push_back(num);
        }
        auto it = lower_bound(t.begin() , t.end() , k);
        int idx;
        if (it != t.end()){
            idx = it - t.begin();
        } else {
            idx = 0;
        }
        // cout << idx << "\n";
        if (t[idx] == k){
            arr.push_back({idx , name});
            
        } else {
            arr.push_back({INT_MAX , name});
            // cout << -1 << "\n";
        }
        
        t.clear();
    }
    bool valid = true;
    sort(arr.begin() , arr.end());
    for (auto i : arr){
        if (i.first != INT_MAX){
            cout << i.second << " ";
            valid = false;
        }    
    }
    if (valid){
        cout << -1;
    }
    return 0;
}