Problem
Here’s my code :
#include <bits/stdc++.h>
#define int long long
#define vi vector<int>
#define ii pair<int,int>
#define iii unordered_map<int,ii>
using namespace std;
void setIO() {
cin.tie(0)->ios_base::sync_with_stdio(0);
}
void solve() {
int n,x;
cin >> n >> x;
vi a(n);
iii si;
for(auto &e : a) cin >> e;
for(int i = 0;i < n;++i) {
for(int j = i+1;j < n;++j) {
int x2 = x-a[i]-a[j];
if(si.find(x2) != si.end()) {
cout << i+1 << ' ' << j+1 << ' ' << si[x2].first+1 << ' ' << si[x2].second+1;
return;
}
si[a[i]+a[j]] = {i,j};
}
}
cout << "IMPOSSIBLE";
}
int32_t main() {
setIO();
solve();
return 0;
}
There’s something wrong going the logic here. Help me identify n fix it