Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define FRE(i,a,b) for(i = a; i <= b; i++)
- #define FRL(i,a,b) for(i = a; i < b; i++)
- #define mem(t, v) memset ((t) , v, sizeof(t))
- #define sqr(x) (x)*(x)
- #define all(x) x.begin(),x.end()
- #define un(x) x.erase(unique(all(x)), x.end())
- #define sf(n) scanf("%d", &n)
- #define sff(a,b) cin >> a >> b
- #define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
- //#define D(x) cout<<#x " = "<<(x)<<endl
- #define pf printf
- #define VI vector <int>
- #define pii pair <int, int>
- #define pll pair <LL, LL>
- #define pb push_back
- #define mp make_pair
- #define pi acos(-1.00)
- //#define DBG pf("Hi\n")
- #define sz size()
- #define ins insert
- #define fi first
- #define se second
- #define xx x
- #define yy y
- #define inf (1<<29)
- #define eps 1e-10
- typedef long long int LL;
- typedef long double db;
- /* Min Priority queue
- priority_queue<int, vector<int>, greater <int> > q;
- */
- //int dx[] = {+0,+1,+0,-1};
- //int dy[] = {+1,+0,-1,+0};
- //int dx[] = {-1,-1,-1,+0,+0,+1,+1,+1};
- //int dy[] = {-1,+0,+1,-1,+1,-1,+0,+1};
- //bool check(int n, int pos) {return (bool) (n & (1<<pos));}
- //int on(int n, int pos) {return n | (1<<pos); }
- //int off(int n, int pos) {return n & ~(1<<pos); }
- struct point // Creates normal 2D point
- {
- double x, y;
- };
- int order(point l, point r, point mid) // (l___r) -> mid
- {
- LL ret = 0;
- ret += l.xx*r.yy + r.xx*mid.yy + mid.xx*l.yy - l.xx*mid.yy - mid.xx*r.yy - r.xx*l.yy;
- if(ret < eps && ret > -eps)
- return 0;
- if(ret < 0) return -1;
- if(ret > 0) return +1;
- }
- struct line // Creates a line with equation ax + by + c = 0
- {
- double a, b, c;
- line() {}
- line( point p1,point p2 )
- {
- a = p1.y - p2.y;
- b = p2.x - p1.x;
- c = p1.x * p2.y - p2.x * p1.y;
- }
- };
- struct circle // Creates a circle with point 'center' as center and r as radius
- {
- point center;
- double r;
- circle() {}
- circle( point P, double rr )
- {
- center = P;
- r = rr;
- }
- };
- db dist(point a, point b)
- {
- return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
- }
- db dist2(point a, point b)
- {
- return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
- }
- vector <point> CLI; /// The points where the circle intersects the line.
- bool eq(db a, db b)
- {
- if(fabs(a-b) <= eps)
- return 1;
- return 0;
- }
- bool intersection(circle C,line L)
- {
- point p1, p2;
- double a, b, c, d, x = C.center.x, y = C.center.y;
- d = C.r*C.r - x*x - y*y;
- if( eq( L.a, 0) )
- {
- p1.y = p2.y = -L.c / L.b;
- a = 1;
- b = 2 * x;
- c = p1.y * p1.y - 2 * p1.y * y - d;
- d = b * b - 4 * a * c;
- d = sqrt( fabs (d) );
- p1.x = ( b + d ) / ( 2 * a );
- p2.x = ( b - d ) / ( 2 * a );
- }
- else
- {
- a = L.a *L.a + L.b * L.b;
- b = 2 * ( L.a * L.a * y - L.b * L.c - L.a * L.b * x);
- c = L.c * L.c + 2 * L.a * L.c * x - L.a * L.a * d;
- d = b * b - 4 * a * c;
- d = sqrt( fabs(d) );
- p1.y = ( b + d ) / ( 2 * a );
- p2.y = ( b - d ) / ( 2 * a );
- p1.x = ( -L.b * p1.y -L.c ) / L.a;
- p2.x = ( -L.b * p2.y -L.c ) / L.a;
- }
- CLI.pb(p1);
- CLI.pb(p2);
- return true;
- }
- bool gre(db a, db b)
- {
- if(fabs(a - b) <= eps)
- return true;
- if(a > b + eps)
- return true;
- return false;
- }
- bool lte(db a, db b)
- {
- if(fabs(a - b) <= eps)
- return true;
- if( a + eps < b )
- return true;
- return false;
- }
- db Evaluate(line L, point P)
- {
- return L.a * P.x + L.b * P.y + L.c;
- }
- point A1,B1,C1, C2;
- int main()
- {
- //freopen("in.txt", "r", stdin);
- //freopen("out.txt", "w", stdout);
- //ios_base::sync_with_stdio(0); cin.tie(0);
- int i, j, k, cs, t;
- sff(A1.x,A1.y);
- sff(B1.x,B1.y);
- sff(C1.x,C1.y);
- line AC = line(A1,C1);
- circle O = circle(B1,dist(B1,C1));
- intersection(O,AC);
- assert(CLI.sz > 0);
- if( eq(dist2(B1,A1) , dist2(A1,C1) + dist2(B1,C1)))
- {
- pf("YES\n");
- return 0;
- }
- if(eq(CLI[0].x, C1.x) && eq(CLI[0].y, C1.y))
- C2 = CLI[1];
- else
- C2 = CLI[0];
- mnx = min(A1.x, C1.x);
- mxx = max(A1.x, C1.x);
- mny = min(A1.y, C1.y);
- mxy = max(A1.y, C1.y);
- line AB = line(A1,B1);
- assert(C2.x < 1000 && C2.y < 1000);
- if(Evaluate(AB, C2) * Evaluate(AB,C1) >= eps)
- {
- if(!order(A1,C2,B1))
- {
- pf("YES\n");
- return 0;
- }
- pf("NO\n");
- cout << setprecision(20) << A1.x << " " << A1.y << endl;
- cout << setprecision(20) << B1.x << " " << B1.y << endl;
- cout << setprecision(20) << C2.x << " " << C2.y << endl;
- }
- else
- pf("YES\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement