Submission
Status:
[P-SSS][-SSSS]
Score: 0
User: Nozomi_boundfortokyo
Problemset: จุดแวะพัก
Language: cpp
Time: 0.025 second
Submitted On: 2025-03-19 23:07:16
#include <bits/stdc++.h>
using namespace std;
vector<pair<string,int>> before;
bool cmp(pair<string,int> a,pair<string,int> b)
{
if(a.second==b.second)
{
return a.first<b.first;
}
return a.second<b.second;
}
int main()
{
int n,k;
cin>>n>>k;
for(int i=0;i<n;i++)
{
string str;
int cnt=0;
int stop;
bool stopatk=false;
cin>>str;
for(int j=0;;j++)
{
if(cin.peek()=='\n' || cin.peek()==EOF) break;
cin>>stop;
if(stop<k)
{
cnt++;
}
else if(stop==k)
{
stopatk=true;
}
}
if(stopatk)
{
before.push_back({str,cnt});
}
}
sort(before.begin(),before.end(),cmp);
for(auto x:before)
{
cout<<x.first<<' ';
}
}