Submission
Status:
[PPPPP][PPPPP]
Subtask/Task Score:
{50/50}{50/50}
Score: 100
User: Phat12
Problemset: จุดแวะพัก
Language: cpp
Time: 0.232 second
Submitted On: 2025-11-03 20:56:07
/*
TASK: c2_ds66_rest.cpp
LANG: C++
AUTHOR: Phat
*/
#include <bits/stdc++.h>
#define FO(i,L,R) for (int i = L; i < R; i++)
using namespace std;
int32_t main(){
cin.tie(nullptr)->sync_with_stdio(false);
int n,k;
vector<pair<int,string>> vec;
cin >> n >> k;
string name ;
cin >> name;
string s;
while (--n){
int cnt=0;
while(1){
cin >> s;
cerr << s << '\n';
if (!isdigit(s[0])) {
name = s;
break;
}
int num = stoi(s);
if (num == k){
vec.push_back({cnt,name});
}
cnt++;
}
}
int cnt=0;
while(cin >> s){
int num = stoi(s);
if (num == k){
vec.push_back({cnt,name});
}
cnt++;
}
sort(vec.begin(),vec.end());
if (vec.empty()){
cout << -1;
return 0;
}
for (int i=0;i<min((int)vec.size(),3);i++){
cout << vec[i].second << ' ';
}
return 0;
}