Submission
Status:
[PPP-S][-SSSS]
Score: 0
User: osensunny
Problemset: จุดแวะพัก
Language: cpp
Time: 0.003 second
Submitted On: 2025-03-22 22:10:09
#include<bits/stdc++.h>
using namespace std;
#define si pair<int, string>
vector<si> info;
string str;
int N, K;
int main(){
ios_base::sync_with_stdio(false); cin.tie(NULL);
cin >> N >> K;
for(int i=0; i<=N; i++){
getline(cin, str);
int cnt=0;
string name;
for(auto c: str){
if(c >= 'a' && c <= 'z') name.push_back(c);
else if(c == ' ') continue;
else{
if(c-'0' == K){
info.push_back({cnt, name});
break;
}
cnt++;
}
}
}
if(info.empty()){
cout << -1;
return 0;
}
sort(info.begin(), info.end());
for(auto x: info) cout << x.second << ' ';
return 0;
}