Submission #1939273


Source Code Expand

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}

//const double EPS = 1e-10;
const double INF = 1e+10;
//const double PI = acos(-1);
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
inline double ABS(double a){return max(a,-a);}
struct Pt {
	double x, y;
	Pt() {}
	Pt(double x, double y) : x(x), y(y) {}
	Pt operator+(const Pt &a) const { return Pt(x + a.x, y + a.y); }
	Pt operator-(const Pt &a) const { return Pt(x - a.x, y - a.y); }
	Pt operator*(const Pt &a) const { return Pt(x * a.x - y * a.y, x * a.y + y * a.x); }
	Pt operator-() const { return Pt(-x, -y); }
	Pt operator*(const double &k) const { return Pt(x * k, y * k); }
	Pt operator/(const double &k) const { return Pt(x / k, y / k); }
	double ABS() const { return sqrt(x * x + y * y); }
	double abs2() const { return x * x + y * y; }
	double arg() const { return atan2(y, x); }
	double dot(const Pt &a) const { return x * a.x + y * a.y; }
	double det(const Pt &a) const { return x * a.y - y * a.x; }
};
double tri(const Pt &a, const Pt &b, const Pt &c) { return (b - a).det(c - a); }

int iSP(Pt a, Pt b, Pt c) {
	int s = sig((b - a).det(c - a));
	if (s) return s;
	if (sig((b - a).dot(c - a)) < 0) return -2; // c-a-b
	if (sig((a - b).dot(c - b)) < 0) return +2; // a-b-c
	return 0;
}
int iLL(Pt a, Pt b, Pt c, Pt d) {
	if (sig((b - a).det(d - c))) return 1; // intersect
	if (sig((b - a).det(c - a))) return 0; // parallel
	return -1; // correspond
}
bool iLS(Pt a, Pt b, Pt c, Pt d) {
	return (sig(tri(a, b, c)) * sig(tri(a, b, d)) <= 0);
}
bool iSS(Pt a, Pt b, Pt c, Pt d) {
	return (iSP(a, b, c) * iSP(a, b, d) <= 0 && iSP(c, d, a) * iSP(c, d, b) <= 0);
}
bool iSSstrict(Pt a, Pt b, Pt c, Pt d) {
	return (sig(tri(a, b, c)) * sig(tri(a, b, d)) < 0 && sig(tri(c, d, a)) * sig(tri(c, d, b)) < 0);
}
Pt pLL(Pt a, Pt b, Pt c, Pt d) {
	b = b - a; d = d - c; return a + b * (c - a).det(d) / b.det(d);
}
Pt hLP(Pt a,Pt b,Pt c){
	return pLL(a,b,c,c+(b-a)*Pt(0,1));
}
double dLP(Pt a, Pt b, Pt c) {
	return ABS(tri(a, b, c)) / (b - a).ABS();
}
double dSP(Pt a, Pt b, Pt c) {
	if (sig((b - a).dot(c - a)) <= 0) return (c - a).ABS();
	if (sig((a - b).dot(c - b)) <= 0) return (c - b).ABS();
	return ABS(tri(a, b, c)) / (b - a).ABS();
}
double dLL(Pt a, Pt b, Pt c, Pt d) {
	return iLL(a, b, c, d) ? 0 : dLP(a, b, c);
}
double dLS(Pt a, Pt b, Pt c, Pt d) {
	return iLS(a, b, c, d) ? 0 : min(dLP(a, b, c), dLP(a, b, d));
}
double dSS(Pt a, Pt b, Pt c, Pt d) {
	return iSS(a, b, c, d) ? 0 : min(min(dSP(a, b, c), dSP(a, b, d)), min(dSP(c, d, a), dSP(c, d, b)));
}
int sGP(int n, Pt p[], Pt a) {
	int side = -1, i;
	p[n] = p[0];
	for (i = 0; i < n; ++i) {
		Pt p0 = p[i] - a, p1 = p[i + 1] - a;
		if (sig(p0.det(p1)) == 0 && sig(p0.dot(p1)) <= 0) return 0;
		if (p0.y > p1.y) swap(p0, p1);
		if (sig(p0.y) <= 0 && 0 < sig(p1.y) && sig(p0.det(p1)) > 0) side = -side;
	}
	return side;
}
Pt p[4];
Pt q[10];
int main(){
	for(int i=0;i<3;i++){
		double X,Y;
		scanf("%lf%lf",&X,&Y);
		p[i]=Pt(X,Y);
	}
	p[3]=p[0];
	if(iSP(p[0],p[1],p[2])<0)swap(p[1],p[2]);
	double left=0;
	double right=11000;
	for(int i=0;i<100;i++){
		double M=(left+right)/2;
		Pt v1=(p[1]-p[0])*Pt(0,1);
		v1=v1/v1.ABS()*M;
		pair<Pt,Pt> l1=make_pair(p[0]+v1,p[1]+v1);
		Pt v2=(p[2]-p[1])*Pt(0,1);
		v2=v2/v2.ABS()*M;
		pair<Pt,Pt> l2=make_pair(p[1]+v2,p[2]+v2);
		Pt v3=(p[0]-p[2])*Pt(0,1);
		v3=v3/v3.ABS()*M;
		pair<Pt,Pt> l3=make_pair(p[2]+v3,p[0]+v3);
		q[0]=pLL(l1.first,l1.second,l2.first,l2.second);
		q[1]=pLL(l2.first,l2.second,l3.first,l3.second);
		q[2]=pLL(l3.first,l3.second,l1.first,l1.second);
		bool ok=true;
		if(sGP(3,p,q[0])==-1)ok=false;
		if(sGP(3,p,q[1])==-1)ok=false;
		if(sGP(3,p,q[2])==-1)ok=false;
		if(dLP(p[0],p[1],q[0])<M-EPS)ok=false;
		if(dLP(p[0],p[1],q[1])<M-EPS)ok=false;
		if(dLP(p[0],p[1],q[2])<M-EPS)ok=false;
		if(dLP(p[2],p[1],q[0])<M-EPS)ok=false;
		if(dLP(p[2],p[1],q[1])<M-EPS)ok=false;
		if(dLP(p[2],p[1],q[2])<M-EPS)ok=false;
		if(dLP(p[0],p[2],q[0])<M-EPS)ok=false;
		if(dLP(p[0],p[2],q[1])<M-EPS)ok=false;
		if(dLP(p[0],p[2],q[2])<M-EPS)ok=false;
		
		if(max(max((q[0]-q[1]).ABS(),(q[2]-q[1]).ABS()),(q[0]-q[2]).ABS())<M*2)ok=false;
		if(ok)left=M;
		else right=M;
	}
	printf("%.12f\n",left);
}

Submission Info

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

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:106:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lf%lf",&X,&Y);
                        ^

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 128 KB
001.txt AC 1 ms 128 KB
002.txt AC 1 ms 128 KB
003.txt AC 1 ms 128 KB
004.txt AC 1 ms 128 KB
005.txt AC 1 ms 128 KB
006.txt AC 1 ms 128 KB
007.txt AC 1 ms 128 KB
008.txt AC 1 ms 128 KB
009.txt AC 1 ms 128 KB
010.txt AC 1 ms 128 KB
011.txt AC 1 ms 128 KB
012.txt AC 1 ms 128 KB
013.txt AC 1 ms 128 KB
014.txt AC 1 ms 128 KB
015.txt AC 1 ms 128 KB
example0.txt AC 1 ms 128 KB
example1.txt AC 1 ms 128 KB