Submission #2117406
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
# define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
# define DBG(fmt, ...)
#endif
const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
#define MAX_N 100010
// 2 点間の距離 (a, b) (c, d)
double DotDist(double a, double b, double c, double d) {
return sqrt((c-a)*(c-a)+(d-b)*(d-b));
}
// pair 版
double DotDist(pair<double, double> a, pair<double, double> b) {
return sqrt((b.first-a.first)*(b.first-a.first)+(b.second-a.second)*(b.second-a.second));
}
// 3 点 (ax, ay), (bx, by), (cx, cy) から三角形の面積を求める
double TriArea(double ax, double ay, double bx, double by, double cx, double cy) {
return (abs(ay * (bx - cx) + by * (cx - ax) + cy * ( ax - bx))) / 2;
}
// pair 版
double TriArea(pair<double, double> a, pair<double, double> b, pair<double, double> c) {
return (abs(a.second * (b.first - c.first) + b.second * (c.first - a.first) + c.second * ( a.first - b.first))) / 2;
}
// 3 点 (ax, ay), (bx, by), (cx, cy) から内接円の半径を求める
double IncircleArea(double ax, double ay, double bx, double by, double cx, double cy) {
double e = DotDist(ax, ay, bx, by) + DotDist(bx, by, cx, cy) + DotDist(cx, cy, ax, ay);
return (2 * TriArea(ax, ay, bx, by, cx, cy)) / e;
}
// pair 版
double IncircleArea(pair<double, double> a, pair<double, double> b, pair<double, double> c) {
double e = DotDist(a, b) + DotDist(b, c) + DotDist(c, a);
return (2 * TriArea(a, b, c)) / e;
}
signed main()
{
// 頂点
pair<double, double> v[3];
REP(i, 3) {
cin >> v[i].first >> v[i].second;
}
// 辺の長さの最大
double max_e = max({DotDist(v[0], v[1]), DotDist(v[1], v[2]), DotDist(v[2], v[0])});
// 内接円の半径
double r = IncircleArea(v[0], v[1], v[2]);
printf("%.10f\n", (double)(max_e * r / (2 * r + max_e)));
return 0;
}
Submission Info
Submission Time |
|
Task |
B - Inscribed Bicycle |
User |
VTR |
Language |
C++14 (GCC 5.4.1) |
Score |
500 |
Code Size |
2201 Byte |
Status |
AC |
Exec Time |
1 ms |
Memory |
256 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
500 / 500 |
Status |
|
|
Set Name |
Test Cases |
Sample |
example0.txt, example1.txt |
All |
000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, example0.txt, example1.txt |
Case Name |
Status |
Exec Time |
Memory |
000.txt |
AC |
1 ms |
256 KB |
001.txt |
AC |
1 ms |
256 KB |
002.txt |
AC |
1 ms |
256 KB |
003.txt |
AC |
1 ms |
256 KB |
004.txt |
AC |
1 ms |
256 KB |
005.txt |
AC |
1 ms |
256 KB |
006.txt |
AC |
1 ms |
256 KB |
007.txt |
AC |
1 ms |
256 KB |
008.txt |
AC |
1 ms |
256 KB |
009.txt |
AC |
1 ms |
256 KB |
010.txt |
AC |
1 ms |
256 KB |
011.txt |
AC |
1 ms |
256 KB |
012.txt |
AC |
1 ms |
256 KB |
013.txt |
AC |
1 ms |
256 KB |
014.txt |
AC |
1 ms |
256 KB |
015.txt |
AC |
1 ms |
256 KB |
example0.txt |
AC |
1 ms |
256 KB |
example1.txt |
AC |
1 ms |
256 KB |