Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i=a;i<b;i++)
#define REP(i, n) FOR(i, 0, n)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
#define PB push_back
#define MP make_pair

ld dst(ld x1, ld y1, ld x2, ld y2){
	x1-=x2;
	y1-=y2;
	return sqrt(x1*x1+y1*y1);
}
int sgn(ld a){
	if(a>0) return 1;
	else if(a<0) return -1;
	else return 0;
}
int linsgn(ld a, ld b, ld c, ld d, ld x, ld y){
	return sgn((d-b)*x-(c-a)*y-a*d+b*c);
}
bool cross(ld x1, ld y1, ld x2, ld y2, ld x3, ld y3, ld x4, ld y4){
	return linsgn(x1,y1,x2,y2,x3,y3)*linsgn(x1,y1,x2,y2,x4,y4)<=0 &&
		linsgn(x3,y3,x4,y4,x1,y1)*linsgn(x3,y3,x4,y4,x2,y2)<=0;
}
void tim(ld &a, ld &b, ld c, ld d){
	ld e=a, f=b;
	a=c*e-d*f;
	b=c*f+d*e;
}
void flp(ld &p, ld &q, ld a, ld b, ld x, ld y){
	p-=a; x-=a;
	q-=b; y-=b;
	ld r=dst(0,0,x,y);
	tim(x, y, x, y);
	q*=-1;
	tim(p, q, x, y);
	p/=r*r; q/=r*r;
	p+=a;
	q+=b;
}
void cpt(ld &p, ld &q, ld x1, ld y1, ld x2, ld y2, ld x3, ld y3, ld x4, ld y4){
	ld a=y2-y1, b=x2-x1, c=x1*y2-x2*y1, d=y4-y3, e=x4-x3, f=x3*y4-x4*y3;
	p=(b*f-c*e)/(b*d-a*e);
	q=-(a*f-c*d)/(a*e-b*d);
}

struct edge{
	int to; ld cost;
};

#define N 240
int n;
ld x[N], y[N];
ld s[N], t[N];

vector<edge> e[N];
void add_edge(int p, int q, ld a, ld b, ld c, ld d){
	// printf("%d->%d: (%Lf, %Lf)-(%Lf, %Lf)\n", p, q, a, b, c, d);
	ld f=dst(a,b,c,d);
	e[p].PB(edge{q, f});
	e[q].PB(edge{p, f});
}

typedef pair<ld, int> pld;
bool used[N];
priority_queue<pld, vector<pld>, greater<pld>> que;
ld cst[N];

int main(){
	REP(i, 2) scanf("%Lf%Lf", s+i, t+i);
	scanf("%d", &n);
	REP(i, n) scanf("%Lf%Lf", x+i, y+i);
	REP(i, n){
		add_edge(i, (i+1)%n, x[i], y[i], x[(i+1)%n], y[(i+1)%n]);
	}
	REP(i, n){
		REP(j, 2){
			FOR(k, i+1, i+n-1){
				if(cross(s[j],t[j],x[i],y[i],x[k%n],y[k%n],x[(k+1)%n],y[(k+1)%n]))
					goto nxt;
			}
			add_edge(n+j, i, s[j],t[j],x[i],y[i]);
			nxt:;
		}
	}
	REP(i, n){
		// printf("i=%d\n", i);
		ld p=s[1], q=t[1];
		flp(p, q, x[i], y[i], x[(i+1)%n], y[(i+1)%n]);
		// printf("(%Lf, %Lf)\n", p, q);
		if(!cross(s[0],t[0],p,q,x[i], y[i], x[(i+1)%n], y[(i+1)%n])) continue;
		ld u, v;
		cpt(u, v, s[0], t[0], p, q, x[i], y[i], x[(i+1)%n], y[(i+1)%n]);
		REP(j, 2){
			FOR(k, i+1, i+n-1){
				if(cross(s[j],t[j],u,v,x[k%n],y[k%n],x[(k+1)%n],y[(k+1)%n]))
					goto fal;
			}
		}
		REP(j, 2) add_edge(n+j, n+2+i, s[j], t[j], u, v);
fal:;
	}
	fill(cst, cst+N, 1e18);
	fill(used, used+N, false);
	cst[n]=0;
	que.push(MP(0, n));
	while(!used[n+1]){
		pld tp=que.top(); que.pop();
		int nw=tp.second;
		if(used[nw]) continue;
		used[nw]=true;
		REP(i, e[nw]){
			edge &ed=e[nw][i];
			ld ncst=cst[nw]+ed.cost;
			int dst=ed.to;
			if(cst[dst]>ncst){
				cst[dst]=ncst;
				que.push(MP(ncst, dst));
			}
		}
	}
	printf("%Lf\n", cst[n+1]);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:35: error: no match for 'operator<' (operand types are 'int' and 'std::vector<edge>')
    5 | #define FOR(i, a, b) for(int i=a;i<b;i++)
      |                                   ^
a.cc:6:19: note: in expansion of macro 'FOR'
    6 | #define REP(i, n) FOR(i, 0, n)
      |                   ^~~
a.cc:117:17: note: in expansion of macro 'REP'
  117 |                 REP(i, e[nw]){
      |                 ^~~
In file included from /usr/include/c++/14/regex:68,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181,
                 from a.cc:1:
/usr/include/c++/14/bits/regex.h:1143:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const sub_match<_BiIter>&)'
 1143 |     operator<(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1143:5: note:   template argument deduction/substitution failed:
a.cc:117:28: note:   mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int'
  117 |                 REP(i, e[nw]){
      |                            ^
a.cc:5:36: note: in definition of macro 'FOR'
    5 | #define FOR(i, a, b) for(int i=a;i<b;i++)
      |                                    ^
a.cc:117:17: note: in expansion of macro 'REP'
  117 |                 REP(i, e[nw]){
      |                 ^~~
/usr/include/c++/14/bits/regex.h:1224:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)'
 1224 |     operator<(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1224:5: note:   template argument deduction/substitution failed:
a.cc:117:28: note:   mismatched types 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>' and 'int'
  117 |                 REP(i, e[nw]){
      |                            ^
a.cc:5:36: note: in definition of macro 'FOR'
    5 | #define FOR(i, a, b) for(int i=a;i<b;i++)
      |                                    ^
a.cc:117:17: note: in expansion of macro 'REP'
  117 |                 REP(i, e[nw]){
      |                 ^~~
/usr/include/c++/14/bits/regex.h:1317:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)'
 1317 |     operator<(const sub_match<_Bi_iter>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1317:5: note:   template argument deduction/substitution failed:
a.cc:117:28: note:   mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int'
  117 |                 REP(i, e[nw]){
      |                            ^
a.cc:5:36: note: in definition of macro 'FOR'
    5 | #define FOR(i, a, b) for(int i=a;i<b;i++)
      |                                    ^
a.cc:117:17: note: in expansion of macro 'REP'
  117 |                 REP(i, e[nw]){
      |                 ^~~
/usr/include/c++/14/bits/regex.h:1391:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)'
 1391 |     operator<(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1391:5: note:   template argument deduction/substitution failed:
a.cc:117:28: note:   'std::vector<edge>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
  117 |                 REP(i, e[nw]){
      |                            ^
a.cc:5:36: note: in definition of macro 'FOR'
    5 | #define FOR(i, a, b) for(int i=a;i<b;i++)
      |                                    ^
a.cc:117:17: note: in expansion of macro 'REP'
  117 |                 REP(i, e[nw]){
      |                 ^~~
/usr/include/c++/14/bits/regex.h:1485:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)'
 1485 |     operator<(const sub_match<_Bi_iter>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1485:5: note:   template argument deduction/substitution failed:
a.cc:117:28: note:   mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int'
  117 |                 REP(i, e[nw]){
      |                            ^
a.cc:5:36: note: in definition of macro 'FOR'
    5 | #define FOR(i, a, b) for(int i=a;i<b;i++)
      |                                    ^
a.cc:117:17: note: in expansion of macro 'REP'
  117 |                 REP(i, e[nw]){
      |                 ^~~
/usr/include/c++/14/bits/regex.h:1560:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)'
 1560 |     operator<(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1560:5: note:   template argument deduction/substitution failed:
a.cc:117:28: note:   'std::vector<edge>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
  117 |                 REP(i, e[nw]){
      |                            ^
a.cc:5:36: note: in definition of macro 'FOR'
    5 | #define FOR(i, a, b) for(int i=a;i<b;i++)
      |                                    ^
a.cc:117:17: note: in expansion of macro 'REP'
  117 |                 REP(i, e[nw]){
      |                 ^~~
/usr/include/c++/14/bits/regex.h:1660:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)'
 1660 |     operator<(const sub_match<_Bi_iter>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1660:5: note:   template argument deduction/substitution failed:
a.cc:117:28: note:   mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int'
  117 |                 REP(i, e[nw]){
      |                            ^
a.cc:5:36: note: in definition of macro 'FOR'
    5 | #define FOR(i, a, b) for(int i=a;i<b;i++)
      |                                    ^
a.cc:117:17: note: in expansion of macro 'REP'
  117 |                 REP(i, e[nw]){
      |                 ^~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
 1045 |     operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1045:5: note:   template argument deduction/substitution failed:
a.cc:117:28: note:   mismatched types 'const std::pair<_T1, _T2>' and 'int'
  117 |                 REP(i, e[nw]){
      |                            ^
a.cc:5:36: note: in definition of macro 'FOR'
    5 | #define FOR(i, a, b) for(int i=a;i<b;i++)
      |                                    ^
a.cc:117:17: note: in expansion of macro 'REP'
  117 |                 REP(i, e[nw]){
      |                 ^~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:67:
/usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
  448 |     operator<(const reverse_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:448:5: note:   template argument deduction/substitution failed:
a.cc:117:28: note:   mismatched types 'const std::reverse_iterator<_Iterator>' and 'int'
  117 |                 REP(i, e[nw]){
      |                            ^
a.cc:5:36: note: in definition of macro 'FOR'
    5 | #define FOR(i, a, b) for(int i=a;i<b;i++)
      |                                    ^
a.cc:117:17: note: in expansion of macro 'REP'
  117 |                 REP(i, e[nw]){
      |                 ^~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
  493 |     operator<(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note:   template argument deduction/substitution failed:
a.cc:117:28: note:   mismatched types 'const std::reverse_iterator<_Iterator>' and 'int'
  117 |                 REP(i, e[nw]){
      |                            ^
a.cc:5:36: note: in definition of macro 'FOR'
    5 | #define FOR(i, a, b) for(int i=a;i<b;i++)
      |                                    ^
a.cc:117:17: note: in expansion of macro 'REP'
  117 |                 REP(i, e[nw]){
      |                 ^~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
 1694 |     operator<(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note:   template argument deduction/substitution failed:
a.cc:117:28: note:   mismatched types 'const std::move_iterator<_IteratorL>' and 'int'
  117 |                 REP(i, e[nw]){
      |                            ^
a.cc:5:36: note: in definition of macro 'FOR'
    5 | #define FOR(i, a, b) for(int i=a;i<b;i++)
      |                                    ^
a.cc:117:17: note: in expansion of macro 'REP'
  117 |                 REP(i, e[nw]){
      |                 ^~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
 1760 |     operator<(const move_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note:   template argument deduction/substitution failed:
a.cc:117:28: note:   misma