Download uva_cpp_clean/10034/10034-5.cpp from slayone/uva_spoj_raw: direct link, hf CLI and curl.
- Browser
- Download file 6.08 kB
-
https://huggingface.co/datasets/slayone/uva_spoj_raw/resolve/main/uva_cpp_clean/10034/10034-5.cpp
- Command line
-
hf download hf://datasets/slayone/uva_spoj_raw/uva_cpp_clean/10034/10034-5.cpp
-
curl -L -o 10034-5.cpp https://huggingface.co/datasets/slayone/uva_spoj_raw/resolve/main/uva_cpp_clean/10034/10034-5.cpp
6.08 kB
| /****************************************************************** | |
| *** Problem : *** | |
| *** Author : Shipu Ahamed (Psycho Timekiller) *** | |
| *** E-mail : shipuahamed01@gmail.com *** | |
| *** University : BUBT,Dept. of CSE *** | |
| *** Team : BUBT_Psycho *** | |
| *** My Blog : http://shipuahamed.blogspot.com *** | |
| *** Facebook : http://www.facebook.com/DeesheharaShipu *** | |
| ******************************************************************/ | |
| using namespace std; | |
| //input | |
| //Output | |
| typedef long long ll; | |
| typedef unsigned long long ull; | |
| typedef vector<int> vi; | |
| typedef vector<ll> vll; | |
| typedef vector<string> vs; | |
| typedef set<int> si; | |
| typedef set<string> ss; | |
| typedef map<int,int> mii; | |
| typedef map<ll,ll> mll; | |
| typedef map<string,int> msi; | |
| typedef map<char,int> mci; | |
| template <typename T>string toString( T Number ){stringstream st;st << Number;return st.str();} | |
| template <typename T> T SOD(T n) {__typeof(n) sum=0;for(__typeof(n) i=1;i*i<=n;i++)sum+=(n%i)?0:((i*i==n)?i:i+n/i);return sum;} | |
| //For Define | |
| //File input/output | |
| //upper bound and lower bound | |
| //Test Case & New line | |
| int stringconvert(string s){int p; istringstream st(s); st>>p ; return p;} | |
| ll pow(ll a,ll b, ll m) { ll res = 1; while(b) { if(b & 1) { res = ( (res % m) * (a % m) ) %m ; } a= ((a%m) * (a%m)) %m; b >>= 1; } return res; } | |
| ll modInverse(ll a, ll m){return pow(a,m-2,m);} | |
| ////============ CONSTANT ===============//// | |
| ////=====================================//// | |
| int par[1000005]; | |
| struct point { | |
| double x,y; | |
| }; | |
| struct f{ | |
| int a,b; | |
| double d; | |
| f(int x,int y,double z) | |
| { | |
| a=x,b=y,d=z; | |
| } | |
| }; | |
| int Find(int n) | |
| { | |
| if(par[n]==n) | |
| return n; | |
| return par[n]=Find(par[n]); | |
| } | |
| void Union(int a,int b) | |
| { | |
| int u= Find(a); | |
| int v= Find(b); | |
| if(u!=v) | |
| { | |
| par[u]=v; | |
| } | |
| } | |
| double dis(point a,point b) | |
| { | |
| return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)); | |
| } | |
| bool cmp(f a,f b) | |
| { | |
| return a.d<b.d; | |
| } | |
| int main() | |
| { | |
| int t; | |
| si(t); | |
| while(t--) | |
| { | |
| int n; | |
| si(n); | |
| for0(i,100) | |
| par[i]=i; | |
| point a[110]; | |
| for0(i,n) | |
| { | |
| sd(a[i].x),sd(a[i].y); | |
| } | |
| vector<f> v; | |
| for0(i,n) | |
| { | |
| for0(j,n) | |
| { | |
| if(i==j) continue; | |
| double p = dis(a[i],a[j]); | |
| v.pb(f(i,j,p)); | |
| } | |
| } | |
| sort(v.begin(),v.end(),cmp); | |
| int len = v.size(); | |
| double res = 0.0; | |
| for0(i,len) | |
| { | |
| int x= Find(v[i].a); | |
| int y= Find(v[i].b); | |
| if(x!=y) | |
| { | |
| Union(x,y); | |
| res+=v[i].d; | |
| } | |
| } | |
| printf("%.2lf\n",res); | |
| if(t) | |
| nl; | |
| } | |
| return 0; | |
| } | |