1#include <bits/stdc++.h>
2using namespace std;
3struct P { long long x, y; };
4long long orient(P a, P b, P c) { return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x); }
5int sgn(long long v) { return (v > 0) - (v < 0); }
6bool box(P p, P a, P b) { return min(a.x, b.x) <= p.x && p.x <= max(a.x, b.x) && min(a.y, b.y) <= p.y && p.y <= max(a.y, b.y); }
7bool intersect(P a, P b, P c, P d) {
8 int d1 = sgn(orient(c, d, a)), d2 = sgn(orient(c, d, b)), d3 = sgn(orient(a, b, c)), d4 = sgn(orient(a, b, d));
9 if (d1 * d2 < 0 && d3 * d4 < 0) return true;
10 return (d1 == 0 && box(a, c, d)) || (d2 == 0 && box(b, c, d)) || (d3 == 0 && box(c, a, b)) || (d4 == 0 && box(d, a, b));
11}
12double dist(P p, P a, P b) { // от точки p до отрезка ab
13 double dx = b.x - a.x, dy = b.y - a.y, L2 = dx * dx + dy * dy;
14 double t = L2 == 0 ? 0 : ((p.x - a.x) * dx + (p.y - a.y) * dy) / L2;
15 t = max(0.0, min(1.0, t));
16 return hypot(p.x - (a.x + t * dx), p.y - (a.y + t * dy));
17}
18int main() {
19 P a, b, c, d, p;
20 cin >> a.x >> a.y >> b.x >> b.y >> c.x >> c.y >> d.x >> d.y >> p.x >> p.y;
21 cout << (intersect(a, b, c, d) ? "YES" : "NO") << "\n";
22 printf("%.6f\n", dist(p, a, b));
23 double best = intersect(a, b, c, d) ? 0 : min(min(dist(a, c, d), dist(b, c, d)), min(dist(c, a, b), dist(d, a, b)));
24 printf("%.6f\n", best);
25}