Submission #1002922


Source Code Expand

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <cstdlib>
#include <complex>

using namespace std;

typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repv(t,it,v) for(vector<t>::iterator it = v.begin() ; it != v.end() ; ++it)

typedef complex<double> vec2;

const double EA = 1e-9;

double dot(vec2 a , vec2 b){
	return a.real() * b.real() + a.imag() * b.imag();
}

double cross(vec2 a , vec2 b){
	return a.real() * b.imag() - a.imag() * b.real();
}

double pab(vec2 a , vec2 b){
	return abs(vec2(a - b));
}

double dis(vec2 a , vec2 b , vec2 c){
	return fabs(cross(a - c , b - c)) / pab(b , c);
}

vec2 p1,p2,p3;
vec2 q;
double h;
double d1,d2,d3;

bool eval(double a){
	return d3 * (h-a) / h >= 2 * a;
}

double BS(double a , double b , int t){
	double c = (a+b) / 2.0;
	if(t == 100) return c;
	return eval(c) ? BS(c,b,t+1) : BS(a,c,t+1);
}

int main(){
	int x1,x2,x3,y1,y2,y3;
	scanf("%d%d%d%d%d%d" , &x1 , &y1 , &x2 , &y2 , &x3 , &y3);
	p1 = vec2(1.*x1,1.*y1);
	p2 = vec2(1.*x2,1.*y2);
	p3 = vec2(1.*x3,1.*y3);
	d1 = pab(p2,p3);
	d2 = pab(p3,p1);
	d3 = pab(p1,p2);
	if(d1 >= d2 && d1 >= d3){
		swap(p1,p3);
		swap(d1,d3);
	} else if(d2 >= d3 && d2 >= d1){
		swap(p2,p3);
		swap(d2,d3);
	}
	double s = d1+d2+d3;
	q = d1 / s * p1 + d2 / s * p2 + d3 / s * p3;
	h = dis(q,p1,p2);
	if(h==0.0) return 0;
	printf("%.9f\n" , BS(0.0,h,0));
	return 0;
}

Submission Info

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

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:63:59: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d%d%d%d" , &x1 , &y1 , &x2 , &y2 , &x3 , &y3);
                                                           ^

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