Professional Documents
Culture Documents
h>
using namespace std;
#define int long long
#define mod 1000000007
#define Time cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs"
<< endl;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define vi vector<int>
#define onesbits(x) __builtin_popcountll(x)
#define zerobits(x) __builtin_ctzll(x)
#define sp(x, y) fixed << setprecision(y) << x
#define w(x) int x;cin >> x;while (x--)
#define tk(x) int x;cin >> x;
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
#ifndef ONLINE_JUDGE
#define debug(x) cerr<< #x <<" ";_print(x);cerr<<endl;
#else
#define debug(x)
#endif
template <class T> void _print(T t){cerr<<t;}
template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.ff);
cerr << ","; _print(p.ss); cerr << "}";}
template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v)
{_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(vector < vector <T> > v){cerr<<"[\n";for(int
l=0;l<v.size();l++){{for(int k=0;k<v[l].size();k++)cerr<<v[l][k]<<" ";}cerr<<"\
n";}cerr<<"]";}
template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i :
v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i);
cerr << " ";} cerr << "]";}
int parent[N],sz[N];
int32_t main(){
fast
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
freopen("error.txt","w",stderr);
#endif
int t=1,n;
cin>>n;
vector<pair<int,int>>v(n+1);
for(int i=1;i<=n;i++){
int x,y;
cin>>x>>y;
v[i].first=x;
v[i].second=y;
}
vector<int>cost(n+1),costk(n+1);
for(int i=1;i<=n;i++) cin>>cost[i];
for(int i=1;i<=n;i++) cin>>costk[i];
vector<pair<int,pair<int,int>>>g;
for(int i=1;i<=n;i++){
g.pb({cost[i],{0,i}});
make(i);
}
for(int i=1;i<n;i++){
for(int j=i+1;j<=n;j++){
int dist= abs(v[i].first-v[j].first)+abs(v[i].second-v[j].second);
g.pb({dist*(costk[i]+costk[j]),{i,j}});
}
}
sort(g.begin(),g.end());
debug(g);
vector<int>station;
vector<pair<int,int>>connect;
int total_cost=0;
for(auto &eg:g){
int wt=eg.first;
int u=eg.second.first;
int v=eg.second.second;
if(find(u)!=find(v)){
total_cost+=wt;
Union(u,v);
if(u==0) station.pb(v);
else connect.pb({u,v});
}
}
cout<<total_cost<<"\n"<<station.size()<<"\n";
for(int i=0;i<station.size();i++) cout<<station[i]<<" ";
cout<<"\n"<<connect.size()<<"\n";
return 0;
}