Submission
Status:
[PPPPP][-SSSS]
Subtask/Task Score:
{50/50}{0/50}
Score: 50
User: Shangbin
Problemset: จุดแวะพัก
Language: cpp
Time: 0.046 second
Submitted On: 2026-03-05 11:57:39
//จุดแวะพัก
//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;
map<int, vector<pair<int, string>>> mat;
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 {
mat[stoi(subs)].push_back({index, name});
}
subs = "";
index++;
}
else subs += c;
}
}
if (mat[k].size() == 0) return cout << -1, 0;
sort(mat[k].begin(), mat[k].end());
for (auto i : mat[k]) cout << i.second << ' ';
}