include iostream include vector include algorithm include math include

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<iomanip>
using namespace std;
const double e = 0.001;
struct Point{
double x, y;
};
struct Line{
double a, b, c;
};
bool pos(Line a, Point b)
{
return (a.a * b.x + a.b * b.y + a.c < e);
}
int main()
{
int n, m = 0;
cin >> n;
vector<Point> p(n);
vector<Line> bis(n);
for (int i = 0; i < n; ++i)
cin >> p[i].x >> p[i].y;
for (int i = 0; i < n; ++i)
{
int l = i - 1, r = (i + 1) % n;
if (i == 0)
l = n - 1;
double a, b;
Point v1 = { p[l].x - p[i].x, p[l].y - p[i].y }, v2 = { p[r].x - p[i].x, p[r].y - p[i].y }, mid;
a = sqrt(v1.x * v1.x + v1.y * v1.y );
b = sqrt(v2.x * v2.x + v2.y * v2.y);
v1.x /= a; v1.y /= a;
v2.x /= b; v2.y /= b;
mid.x = (v1.x + v2.x) / 2; mid.y = (v1.y + v2.y) / 2;
bis[m].a = mid.x - p[i].x;
bis[m].b = mid.y - p[i].y;
bis[m].c = -1 * (bis[m].a * p[i].x + bis[m].b * p[i].y);
m++;
}
Point rez;
rez.x = -1 * (bis[0].a * bis[1].c - bis[1].a * bis[0].c) / (bis[1].a * bis[0].b - bis[0].a * bis[1].b);
rez.y = -1 * (bis[1].c * bis[0].b - bis[0].c * bis[1].b) / (bis[1].a * bis[0].b - bis[0].a * bis[1].b);
bool t = true;
for (int i = 2; i < n; ++i)
if (!pos(bis[i], rez))
t = false;
if (t)
{
double d = abs(bis[0].a * rez.x + bis[0].b + rez.y + bis[0].c) / sqrt(bis[0].a * bis[0].a + bis[0].b * bis[0].b);
cout << "YES" << endl << fixed << setprecision(3) << rez.x << " " << rez.y << " " << d << endl;
}
else
cout << "NO" << endl;
}