Submission

Status:

[PPPPP][-SSSS]

Subtask/Task Score:

{50/50}{0/50}

Score: 50

User: hanapiyajong

Problemset: จุดแวะพัก

Language: cpp

Time: 0.006 second

Submitted On: 2026-03-06 08:58:26

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

int main() {
    ios_base::sync_with_stdio(0),cin.tie(0);
    int n;
    string k;
    string s;
    vector<pair<int,string>> v;
    cin >> n >> k;
    cin.ignore();
    string name;
    for (int i = 0; i < n; i++){
        int idx = 0;
        getline(cin, s);
        stringstream ss(s);
        string sss;
        while(ss >> sss){
            if (idx == 0) name = sss;
            if (sss == k) {
                v.push_back({idx,name});
            }
            idx++;
        }
    }
    if (v.empty()){
        cout << -1;
        return 0;
    }
    sort(v.begin(),v.end());
    int i = 0;
    for (auto vv : v){
        i++;
        cout << vv.second;
        if (i < v.size()) cout << " ";
    }
}