Submission
Status:
[PPPPP][PPPPP]
Subtask/Task Score:
{50/50}{50/50}
Score: 100
User: Shangbin
Problemset: จุดแวะพัก
Language: cpp
Time: 0.007 second
Submitted On: 2026-03-05 12:09:46
//จุดแวะพัก
//Problem = https://grader.gchan.moe/problemset/c2_ds66_rest/statement
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
const int maxn = 1005;
int n, k;
string input, subs, name;
vector<pair<int, string>> vec;
int main(){
cin.tie(nullptr)->sync_with_stdio(0);
cin >> n >> k;
n++;
for (int i = 0; i < n; i++){
getline(cin, input);
input += " ";
int index = 0;
for (auto c : input){
if (c == ' '){
if (index == 0) name = subs;
else {
if (stoi(subs) == k) vec.push_back({index, name});
}
subs = "";
index++;
}
else subs += c;
}
}
if (vec.size() == 0) return cout << -1, 0;
sort(vec.begin(), vec.end());
for (int i = 0; i < min(3, (int)vec.size()); i++) cout << vec[i].second << ' ';
}