Submission

Status:

[P-SSS][-SSSS]

Subtask/Task Score:

{0/50}{0/50}

Score: 0

User: theem1502

Problemset: จุดแวะพัก

Language: cpp

Time: 0.012 second

Submitted On: 2026-02-15 23:57:03

#include <bits/stdc++.h>
using namespace std;

int main() {
    int num, val;
    cin >> num >> val;
    vector<pair<int, string>> thearray;
    vector<string> valarray;
    vector<string> stringarray(num);
    for (int i = 0; i < num; i++) {
    int count = 0;
    vector<int> currarray;
        /*while(true) {
            string temp;
            cin.get() >> temp;
            if (i == num - 1 && temp == "\n") {
                break;
            }

            if (temp[0] < '0' || temp[0] > '9') {
                if (count == 0) {
                    stringarray[i] = temp;
                }
                else {
                    stringarray[i+1] = temp;
                    break;
                }
            }
            else {
                currarray.push_back(stoi(temp));

            }

            count++;
        }*/
        cin >> stringarray[i];
        string num;
        getline(cin, num);
      //  cout << "num " << num << "\n";
        int left= 1, right= 1;
        for (int i = 0; i < num.length(); i++) {
             //   cout << "n";
                 if (i == num.length() - 1) {
                    //cout << "here";
                    int t = 0;
                    char tt[100];
                    while(left < num.length()){
                        tt[t++] = num[left++];
                    }
                    tt[t] = '\0';
                    currarray.push_back(stoi(tt));
                }

                if (right >= num.length()) {
                  //      cout << "yes";
                    break;
                }



            right++;
            if (right < num.length() &&num[right] == ' ' ) {
                  // cout << "uh";
                    int c = 0;
                    char temp[100];
                while(left < right ) {
                    temp[c++] = num[left++];
                }

                currarray.push_back(stoi(temp));
                left = right + 1;

            }


        }
/*
        cout << "debug " << stringarray[i] << " ";
        for (int i = 0; i < currarray.size(); i++) {
            cout << currarray[i] << " ";
        }
*/

        int theval = lower_bound(currarray.begin(), currarray.end(), val) - currarray.begin();
        if (currarray[theval] == val) {
            thearray.push_back(make_pair(theval, stringarray[i]));
        }

    }


    sort(thearray.begin(), thearray.end());
   // cout << "\n\n\n\n";
    for (auto [w, v]: thearray) {
        cout << v << " ";
    }
    return 0;








}