Language: C++

#include <bits/stdc++.h>
using namespace std;

struct point{
    double x, y;
};

double distance(double x1, double y1, double x2, double y2){
    double ans = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
    return ans;
}

int main(){
    
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    point p[10];
    int n;
    cin >> n;
    for(int i = 0; i < n; ++i)
        cin >> p[i].x >> p[i].y;
    
    double long sum = 0;
    do{
        for(int i = 0; i < n - 1; ++i)
            sum += distance(p[i].x, p[i].y, p[i + 1].x, p[i + 1].y);
        
    }while(next_permutation(p + 0, p + n));    
    cout << sum << '\n';
    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 = point*; _Iterator2 = point*]':
/usr/include/c++/14/bits/stl_algo.h:2905:14:   required from 'bool std::__next_permutation(_BidirectionalIterator, _BidirectionalIterator, _Compare) [with _BidirectionalIterator = point*; _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 = point*]'
 2950 |       return std::__next_permutation
      |              ~~~~~~~~~~~~~~~~~~~~~~~
 2951 |         (__first, __last, __gnu_cxx::__ops::__iter_less_iter());
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:29:28:   required from here
   29 |     }while(next_permutation(p + 0, p + n));
      |            ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/predefined_ops.h:45:23: error: no match for 'operator<' (operand types are 'point' and 'point')
   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:   'point' 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:   'point' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>'
   45 |       { return *__it1 < *__it2; }
      |                ~~~~~~~^~~~~~~~