Submission
Status:
[P-SSS][-SSSS]
Subtask/Task Score:
{0/50}{0/50}
Score: 0
User: qweqwe
Problemset: จุดแวะพัก
Language: cpp
Time: 0.008 second
Submitted On: 2025-10-21 19:35:31
#include <bits/stdc++.h>
#define speed cin.tie(0)->sync_with_stdio(0)
#define ll long long
#define pii pair<int,int>
using namespace std;
struct rest{
string s;int idx;
bool operator<(const rest &other) const{
if (idx!=other.idx) return idx>other.idx;
return s>other.s;
}
};
bool isint(const string &n){
if (n.empty()) return false;
for (char c:n){
if (c-'0'<0 || c-'0'>9) return false;
}return true;
}
int main(){
speed;
int n,k;cin >> n >> k;
cin.ignore();
vector<rest> v;
int j=0;
string s;
for (int i=0;i<n;i++){ // i understand it now
string input,t; // a bit odd?
getline(cin,input); // alr i got ts
stringstream cinn(input); // brother wth is this???
while (cinn >> t){
if (!isint(t)){
s=t;
}else{
int temp=stoi(t);
if (temp==k){
v.push_back({s,j});
}j++;
}
}
}sort(v.begin(),v.end());
for (rest i:v){
cout << i.s << " ";
}
return 0;
}