CSES - Shared codeLink to this code: https://cses.fi/paste/a01de9d1338676682907de/
#include <iostream>
#include <unordered_map>
#include <vector>
constexpr int N = 5000;
int a[N];
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
int n, x;
std::cin >> n >> x;
for (int i = 0; i < n; ++i) {
std::cin >> a[i];
}
std::unordered_map<int, int> pos;
pos.reserve(n * 10);
for (int i = 0; i < n; ++i) {
pos[a[i]] = i;
}
for (int i = 0; i < n; ++i) {
for (int j = i + 1; j < n; ++j) {
auto it = pos.find(x - a[i] - a[j]);
if (it == pos.end() or it->second <= j) {
continue;
}
std::cout << i + 1 << ' ' << j + 1 << ' ' << it->second + 1 << '\n';
return 0;
}
}
std::cout << "IMPOSSIBLE\n";
return 0;
}