Submission
Status:
[xSSSS][xSSSS]
Subtask/Task Score:
{0/50}{0/50}
Score: 0
User: hanapiyajong
Problemset: จุดแวะพัก
Language: cpp
Time: 0.002 second
Submitted On: 2026-03-06 09:00:59
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0),cin.tie(0);
int n;
int 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 (stoi(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 << " ";
}
}