Advertisement
mehedi1

LU_CSE2019 K. Five Brothers' Kingdom (WA)

Oct 23rd, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.00 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define x first
  4. #define y second
  5. #define pdd pair<double, double>
  6.  
  7. double sqr(double a) {
  8.     return a*a;
  9. }
  10. double dist(auto a, auto b) {
  11.     double ret = sqr(a.x-b.x) + sqr(a.y-b.y);
  12.     return sqrt(ret);
  13. }
  14. pdd third_point(auto a, auto b, auto p) {
  15.     pdd c;
  16.     //p(x, y) = (x1+x2+x3)/3, (y1+y2+y3)/3
  17.     c.x = p.x*3.0-(a.x+b.x);
  18.     c.y = p.y*3.0-(a.y+b.y);
  19.     return c;
  20. }
  21. double calc(auto a, auto b, auto c) {
  22.     double area = abs((a.x*(b.y-c.y) + b.x*(c.y-a.y) + c.x*(a.y-b.y))/2.0);
  23.     return area*2.0/dist(b, c);
  24. }
  25.  
  26. int main() {
  27.     ios_base::sync_with_stdio(false);
  28.     int T;
  29.     pdd a, b, c, i, j;
  30.     cin>>T;
  31.     while(T--) {
  32.         cin>>a.x>>a.y>>b.x>>b.y>>c.x>>c.y>>i.x>>i.y>>j.x>>j.y;
  33.         pdd h = third_point(a, c, i);
  34.         pdd f = third_point(b, c, j);
  35.         double height = calc(b, h, f);
  36.  
  37.         double ac = dist(a, c);
  38.         double bc = dist(b, c);
  39.         double agdc = ac * height;
  40.         double bgec = bc * height;
  41.         cout<<fixed<<setprecision(9)<<abs(agdc - bgec)<<endl;
  42.     }
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement