Submission

Status:

[TSSSS][xSSSS]

Subtask/Task Score:

{0/50}{0/50}

Score: 0

User: Nay-O

Problemset: จุดแวะพัก

Language: cpp

Time: 1.097 second

Submitted On: 2026-03-15 22:43:25

#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;
	string str; cin >> str;
	
	for(int i = 0; i < n; i++){
		string a = str;
		int c = 0;
		while(true){
			cin >> str;
			if(str[0]>'9'||str[0]<'0'){
				break;
			}
			int x = stoi(str);
			if(x==m){
				pq.push({c,a});
			}
			
			c++;
		}
	}
	
	while(!pq.empty()){
		cout << pq.top().second << " ";
		pq.pop();
	}
	
	return 0;
}