Submission
Status:
[PPPPP][PPPPP]
Subtask/Task Score:
{50/50}{50/50}
Score: 100
User: hanapiyajong
Problemset: จุดแวะพัก
Language: cpp
Time: 0.008 second
Submitted On: 2026-03-06 09:08:32
#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);
int sss;
ss >> name;
while(ss >> sss){
if (sss == k) {
v.push_back({idx,name});
break;
}
idx++;
}
}
if (v.empty()){
cout << -1;
return 0;
}
sort(v.begin(),v.end());
int i = 0;
for (auto vv : v){
i++;
if(i > 3) return 0;
cout << vv.second;
if (i < v.size()) cout << " ";
}
}