23520888
Giới thiệu
include<bits/stdc++.h>
using namespace std;
map<pair\<int,int>,int> M;
vector<int> v;
bool checkDiffIndex(map<pair\<int,int>,int>::iterator i1,map<pair\<int,int>,int>::iterator i2)
{
int a = i1->first.first,b = i1->first.second,c = i2->first.first,d = i2->first.second;
return (a!=c)&&(a!=d)&&(b!=c)&&(b!=d);
}
int sum4Values(map<pair\<int,int>,int>::iterator i1,map<pair\<int,int>,int>::iterator i2)
{
int a = i1->second;
int b = i2->second;
return a+b;
}
void print4Values(map<pair\<int,int>,int>::iterator i1,map<pair\<int,int>,int>::iterator i2)
{
int a = i1->first.first,b = i1->first.second,c = i2->first.first,d = i2->first.second;
cout<<a+1<<' '<<b+1<<' '<<c+1<<' '<<d+1;
}
int main()
{
int n,x;
cin>>n>>x;
v.resize(n);
for(int i=0;i<n;i++)cin>>v[i];
for(int i = 0;i<n;i++)
for(int j = i+1;j<n;j++)
{
M[{i,j}] = v[i]+v[j];
}
for(auto i = M.begin();i!=M.end();++i)
for(auto j = next(i);j!=M.end();++j)
{
if(sum4Values(i,j)==x&&checkDiffIndex(i,j))
{
print4Values(i,j);
return 0;
}
}
cout<<"IMPOSSIBLE";
return 0;
}