Submission

Status:

[P-SSS][-SSSS]

Subtask/Task Score:

{0/50}{0/50}

Score: 0

User: goine

Problemset: จุดแวะพัก

Language: cpp

Time: 0.011 second

Submitted On: 2026-03-12 10:55:52

#include <iostream>
#include <sstream>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int n, target;
    cin >> n >> target;
    cin.ignore();

    map<string, int> ans;

    for (int i = 0; i < n; i++) {
        string x;
        getline(cin, x);

        stringstream ss(x);
        string name;
        ss >> name;

        int cur;
        int idx = 1;

        while (ss >> cur) {
            if (cur == target) {
                ans[name] = idx;
                break;
            }
            idx++;
        }
    }

    vector<pair<string,int>> v(ans.begin(), ans.end());

    sort(v.begin(), v.end(), [](auto &a, auto &b){
        return a.second < b.second;
    });

    for (auto &[name,val] : v) {
        cout << name << " ";
    }

    return 0;
}