Language: C++

#include<bits/stdc++.h>
using namespace std;
int n;
struct P{
	int xi,yi;
}a[45];
int num[45];
double count(P x,P y)
{
	double t=1.0*(x.xi-y.xi)*(x.xi-y.xi)+1.0*(x.yi-y.yi)*(x.yi-y.yi);
	double left=0,midle,right=t;
	for(int i=1;i<=500;i++)
	{
		midle=(left+right)/2;
		if(midle*midle<t)left=midle;
		else right=midle;
	}
	return right;
}
void average()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i].xi>>a[i].yi;
	for(int i=1;i<=n;i++)
		num[i]=i;
	double ans=0;
	int cnt=0;
	do		//next_permutation(a,a+n)全排列函数	如果还有全排列才继续 
	{
		++cnt;
		for(int i=2;i<=n;i++)
		{
			ans+=count(a[num[i]],a[num[i-1]]); 
		}
	} while(next_permutation(a+1,a+n+1));
	cout<<ans/cnt;
}
int main()
{
	cout<<fixed<<setprecision(10);
	average();
	return 0; 
}

Compiler output:
In file included from /usr/include/c++/14/bits/stl_algobase.h:71,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_less_iter::operator()(_Iterator1, _Iterator2) const [with _Iterator1 = P*; _Iterator2 = P*]':
/usr/include/c++/14/bits/stl_algo.h:2905:14:   required from 'bool std::__next_permutation(_BidirectionalIterator, _BidirectionalIterator, _Compare) [with _BidirectionalIterator = P*; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
 2905 |           if (__comp(__i, __ii))
      |               ~~~~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:2951:2:   required from 'bool std::next_permutation(_BIter, _BIter) [with _BIter = P*]'
 2950 |       return std::__next_permutation
      |              ~~~~~~~~~~~~~~~~~~~~~~~
 2951 |         (__first, __last, __gnu_cxx::__ops::__iter_less_iter());
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:36:26:   required from here
   36 |         } while(next_permutation(a+1,a+n+1));
      |                 ~~~~~~~~~~~~~~~~^~~~~~~~~~~
/usr/include/c++/14/bits/predefined_ops.h:45:23: error: no match for 'operator<' (operand types are 'P' and 'P')
   45 |       { return *__it1 < *__it2; }
      |                ~~~~~~~^~~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:67:
/usr/include/c++/14/bits/stl_iterator.h:1241:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&)'
 1241 |     operator<(const __normal_iterator<_IteratorL, _Container>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1241:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:45:23: note:   'P' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>'
   45 |       { return *__it1 < *__it2; }
      |                ~~~~~~~^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1249:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)'
 1249 |     operator<(const __normal_iterator<_Iterator, _Container>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1249:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:45:23: note:   'P' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>'
   45 |       { return *__it1 < *__it2; }
      |                ~~~~~~~^~~~~~~~