Submission #2233541


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

typedef pair<double, double> Point;
Point p[3], I;

double distance_of_Point_to_Point(Point A, Point B) { // 点 A と点 B の距離
	return hypot(A.FI - B.FI, A.SE - B.SE);
}

double distance_of_Point_to_Line(Point P, Point A, Point B) { // 点 P と直線 AB の距離
	double a = B.SE - A.SE;
	double b = A.FI - B.FI;
	double c = A.SE * B.FI - A.FI * B.SE;
	// 直線 AB の方程式は ax + by + c = 0
	return abs(a * P.FI + b * P.SE + c) / hypot(a, b);
}

Point triangle_incenter(Point A, Point B, Point C) { // 三角形 ABC の内心の座標
	double a = distance_of_Point_to_Point(B, C);
	double b = distance_of_Point_to_Point(C, A);
	double c = distance_of_Point_to_Point(A, B);
	return MP(
		(a * A.FI + b * B.FI + c * C.FI) / (a + b + c), 
		(a * A.SE + b * B.SE + c * C.SE) / (a + b + c)
	);
}

double f(int a, int b) {
	double l = distance_of_Point_to_Point(p[a], p[b]);
	double h = distance_of_Point_to_Line(I, p[a], p[b]);
	return l / (2.0 + l / h);
}

int main() {
	inc(i, 3) { cin >> p[i].FI >> p[i].SE; }
	
	I = triangle_incenter(p[0], p[1], p[2]);
	
	double ans = 0.0;
	inc(i, 3) { setmax(ans, f(i, (i + 1) % 3)); }
	
	printf("%.12f\n", ans);
	
	return 0;
}

Submission Info

Submission Time
Task B - Inscribed Bicycle
User FF256grhy
Language C++14 (GCC 5.4.1)
Score 500
Code Size 2785 Byte
Status AC
Exec Time 1 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 2
AC × 18
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