Submission

Status:

[P-SSS][-SSSS]

Subtask/Task Score:

{0/50}{0/50}

Score: 0

User: Nay-O

Problemset: จุดแวะพัก

Language: cpp

Time: 0.004 second

Submitted On: 2026-03-15 22:49:17

#include<bits/stdc++.h>
using namespace std;
using pis = pair<int,string>;

priority_queue<pis,vector<pis>,greater<pis>> pq;

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	
	int n,m; cin>>n>>m;
	cin.ignore();
	for(int i = 0; i < n; i++){
		string str;
		getline(cin,str);
		string a;
		int c = -1;
		int x = 0;
		bool b = true;
		for(auto value : str){
			if(value == ' '){
				b = false;
				x = 0;
				c++;
				continue;
			}
			if(b){
				a+=value;
			}
			else{
				x = 10*x+value-48;
				if(x == m){
					pq.push({c,a});
					break;
				}
			}
		}
	}
	
	while(!pq.empty()){
		cout << pq.top().second << " ";
		pq.pop();
	}
	
	return 0;
}