Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

0?

Posted by 400ACpj at 2019-01-12 23:47:31 on Problem 3714
#include<iostream>
#include<iomanip>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<utility>
using namespace std;
typedef pair<double,double> xypnt;
int T;
int n;
istream& operator>>(istream& my,xypnt& p){
	my>>p.first>>p.second;
	return my; 
}
xypnt a[100010],b[100010];
double minn=static_cast<double>(INT_MAX);
inline double dist(int i,int j){
	xypnt x=a[i],y=b[j];
	return 
	  sqrt((x.first-y.first)*(x.first-y.first) +
		   (x.second-y.second)*(x.second-y.second))
	  ;
}
int main(){
	cin>>T;
	while(T--){
		cin>>n;
		for(int i=1;i<=n;++i)
		  cin>>*(a+i);
		for(int i=1;i<=n;++i)
		  cin>>*(b+i);
		sort(a+1,a+1+n);
		sort(b+1,b+1+n);
		for(int i=1;i<=n;++i){
			for(int j=1;j<=n;++j){
				double now=dist(i,j);
				if(now>minn)break;
				minn=now;
			}
		}
		cout<<fixed<<setprecision(3)<<minn<<endl;
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator