Problem Code: https://www.codechef.com/NOV19B/problems/PHCUL

Can anyone help me with this code regarding Problem PHCUL

I am doing the same doing as stated in the Problem.

Code link:https://www.codechef.com/viewsolution/27845303

#include <bits/stdc++.h>

using namespace std;

int main()

{

ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int t;

cin>>t;

while(t–)

{

long double x,y,n,m,k,a,d1=0,d2=0,d3=0,minm=1000000001.0,s=0,ans1=0,ans2=0,s1=0,s2=0,s3=0,s4=0,s5=0;

cin>>x>>y;

cin>>n>>m>>k;

vectorn1;

vectorm1;

vectork1;

vector<pair<int,int>>n2;

vector<pair<int,int>>m2;

vector<pair<int,int>>k2;

```
for(int i=0;i<2*n;i++){cin>>a; n1.push_back(a);}
for(int i=0;i<2*m;i++){cin>>a; m1.push_back(a);}
for(int i=0;i<2*k;i++){cin>>a; k1.push_back(a);}
for(int i=0;i<2*n;i=i+2){ n2.push_back(make_pair(n1[i],n1[i+1])); }
for(int i=0;i<2*m;i=i+2){ m2.push_back(make_pair(m1[i],m1[i+1])); }
for(int i=0;i<2*k;i=i+2){ k2.push_back(make_pair(k1[i],k1[i+1]));}
//calculating distance from (x,y)
for(int i=0;i<n2.size();i++)
{
d1=sqrt((x-n2[i].first)*(x-n2[i].first) + (y-n2[i].second)*(y-n2[i].second));
if(d1<minm){ minm=d1;s=i;}
}
ans1+=minm;
minm=INT_MAX;
//calc. from (a,b)
for(int i=0;i<m2.size();i++)
{
d2=sqrt((n2[s].first-m2[i].first)*(n2[s].first-m2[i].first) + (n2[s].second-m2[i].second)*(n2[s].second-m2[i].second));
if(d2<minm){minm=d2;s1=i;}
}
ans1+=minm;
minm=INT_MAX;
//calc from (c,d)
for(int i=0;i<k2.size();i++)
{
d3=sqrt((m2[s1].first-k2[i].first)*(m2[s1].first-k2[i].first) + (m2[s1].second-k2[i].second)*(m2[s1].second-k2[i].second));
if(d3<minm){minm=d3;s2=i;}
}
ans1+=minm;
minm=INT_MAX;
//-------------------------------------------------------------
for(int i=0;i<m2.size();i++)
{
d1=sqrt((x-m2[i].first)*(x-m2[i].first) + (y-m2[i].second)*(y-m2[i].second));
if(d1<minm){minm=d1;s3=i;}
}
//cout<<m2[s].first<<" "<<m2[s].second<<endl;
ans2+=minm;
minm=INT_MAX;
//calc. from (c,d)
for(int i=0;i<n2.size();i++)
{
d2=sqrt((m2[s3].first-n2[i].first)*(m2[s3].first-n2[i].first) + (m2[s3].second-n2[i].second)*(m2[s3].first-n2[i].first));
if(d2<minm)
{
minm=d2;s4=i;
}
}
ans2+=minm;
minm=INT_MAX;
//calc from (a,b)
for(int i=0;i<k2.size();i++)
{
d3=sqrt((n2[s4].first-k2[i].first)*(n2[s4].first-k2[i].first) + (n2[s4].second-k2[i].second)*(n2[s4].second-k2[i].second));
if(d3<minm){minm=d3;s5=i;}
}
ans2+=minm;
cout<<fixed<<setprecision(16)<<min(ans1,ans2)<<endl;
}
return 0;
```

}