Submission
Status:
[PPxSS][PPxSS]
Subtask/Task Score:
{0/50}{0/50}
Score: 0
User: theem1502
Problemset: จุดแวะพัก
Language: cpp
Time: 0.013 second
Submitted On: 2026-02-16 00:08:10
#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 (theval < currarray.size() && currarray[theval] == val) {
thearray.push_back(make_pair(theval, stringarray[i]));
}
}
sort(thearray.begin(), thearray.end());
// cout << "\n\n\n\n";
if (thearray.size() == 0) {
cout << -1;
return 0;
}
for (int i = 0; i < 3; i++) {
cout << thearray[i].second << " ";
}
return 0;
}