Submission
Status:
[PPPPP][PPPPP]
Subtask/Task Score:
{50/50}{50/50}
Score: 100
User: solarsunny
Problemset: จุดแวะพัก
Language: cpp
Time: 0.007 second
Submitted On: 2025-10-22 23:58:59
#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;
string cus;
getline(cin, cus);
for(int i=0; i<n; i++) {
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));
}
}
if(c.size() == 0) {
cout << -1 << "\n";
return 0;
}
sort(c.begin(),c.end());
for(int i=0; i<3 && i<c.size(); i++) {
cout << c[i].second << " ";
}
cout << "\n";
return 0;
}
/*
5 128
taohu 0 1 7 9
mafuyu 2 5
ccsleep 2 4 7 25
sira 7
iris 32 64 128
*/