Submission
Status:
[PPPPP][-SSSS]
Score: 50
User: Jibhong
Problemset: จุดแวะพัก
Language: cpp
Time: 0.004 second
Submitted On: 2025-03-24 09:48:34
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
map<int,vector<string>>mp;
int main(){
ios::sync_with_stdio(0);cin.tie(0);
int n,q;
cin>>n>>q;
cin.ignore();
for(int i=0;i<n;++i){
string inp;
getline(cin,inp);
stringstream ss;
string e;
ss<<inp;
bool gay=0;
int cnt=0;
string name;
while(ss>>e){
if(!gay){
name=e;
gay=1;
continue;
}
if(stoi(e)!=q){
++cnt;
continue;
}
mp[cnt].emplace_back(name);
break;
}
}
bool gay=1;
for(auto e:mp){
sort(e.S.begin(),e.S.end());
for(auto f:e.S){
gay=0;
cout<<f<<' ';
}
}
if(gay)cout<<-1;
return 0;
}