답안 #119695

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
119695 2019-06-21T22:32:16 Z tutis 두 개의 원 (balkan11_2circles) C++17
10 / 100
179 ms 65536 KB
/*input
4
0 0
1 0
1 1
0 1
*/
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
struct point
{
	ld x, y;
	point() {}
	point(ld x, ld y): x(x), y(y) {}
	ld r()
	{
		return sqrtl(x * x + y * y);
	}
};
point operator+(const point &a, const point &b)
{
	return point(a.x + b.x, a.y + b.y);
}
point operator-(const point &a, const point &b)
{
	return point(a.x - b.x, a.y - b.y);
}
point operator*(const point &a, const point &b)
{
	return point(a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x);
}
point operator*(point a, ld k)
{
	return point(a.x * k, a.y * k);
}
ld dot(const point &a, const point &b)
{
	return a.x * b.x + a.y * b.y;
}
ld cross(const point &a, const point &b)
{
	return a.x * b.y - a.y * b.x;
}
point x(const point &a, point b, const point &c, point d)
{
	b = b - a;
	d = d - c;
	ld y = cross(a - c, b) / cross(d, b);
	return c + d * y;
}
struct line
{
	point a, b;
};
point x(const line &a, const line &b)
{
	return x(a.a, a.b, b.a, b.b);
}
int n;
point A[50505];
bool nereik(line a, line b, line c)
{
	return cross(x(a, c) - b.a, b.b - b.a) > 0;
}
deque<line> taisom(deque<line>a)
{
	if (a.size() <= 2)
		return {};
	for (int i = 0; i < (int)a.size(); i++)
	{
		for (int j = 0; j < (int)a.size(); j++)
		{
			for (int k = 0; k < (int)a.size(); k++)
			{
				if (i == j || i == k || j == k)
					continue;
				if (nereik(a[i], a[j], a[k]))
				{
					a.erase(a.begin() + j);
					return taisom(a);
				}
			}
		}
	}
	return a;
}
deque<point>x(deque<line>a)
{
	deque<point>ret;
	for (int i = 0; i < (int)a.size(); i++)
	{
		ret.push_back(x(a[i], a[(i + 1) % a.size()]));
	}
	return ret;
}
ld maxi(const deque<point> &a)
{
	ld ret = 0;
	for (int i = 0; i < (int)a.size(); i++)
	{
		for (int j = 0; j < i; j++)
		{
			ret = max(ret, (a[i] - a[j]).r());
		}
	}
	return ret;
}
bool ok(ld r)
{
	r = r;
	deque<line>tieses;
	for (int i = 0; i < n; i++)
	{
		point v = (A[i + 1] - A[i]) * point(0, 1);
		v = v * (r / v.r());
		tieses.push_back(line());
		tieses.back().a = A[i] + v;
		tieses.back().b = A[i + 1] + v;
	}
	return maxi(x(taisom(tieses))) >= 2 * r;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> A[i].x >> A[i].y;
	A[n] = A[0];
	ld lo = 0;
	ld hi = 3e7;
	for (int t = 0; t < 100; t++)
	{
		ld r = (lo + hi) / 2;
		if (ok(r))
			lo = r;
		else
			hi = r;
	}
	ld r = (lo + hi) / 2;
	cout << fixed << setprecision(15) << r << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 512 KB Output is correct
2 Incorrect 3 ms 384 KB Output isn't correct
3 Incorrect 86 ms 1588 KB Output isn't correct
4 Incorrect 179 ms 2704 KB Output isn't correct
5 Runtime error 72 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Runtime error 81 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
7 Runtime error 69 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
8 Runtime error 88 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
9 Runtime error 84 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Runtime error 102 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)