Problem p00880 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
// cin.sync_with_stdio(false);
// streambuf
using namespace std;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using ti3 = tuple<int, int, int>;
using vti3 = vector<ti3>;
template <class T, int s> using va = vector<array<T, s>>;
template <class T, class T2> using umap = unordered_map<T, T2>;
template <class T> using uset = unordered_set<T>;
template <class T, class S> void cmin(T &a, const S &b) {
  if (a > b)
    a = b;
}
template <class T, class S> void cmax(T &a, const S &b) {
  if (a < b)
    a = b;
}
#define ALL(a) a.begin(), a.end()
#define rep(i, a) for (int i = 0; i < a; i++)
#define rep1(i, a) for (int i = 1; i <= a; i++)
#define rrep(i, a) for (int i = (a)-1; i >= 0; i--)
#define rrep1(i, a) for (int i = a; i; i--)
#define repi(i, a, b)                                                          \\
  for (int i = a; i < b; i++)                                                  \\
    ;
const ll mod = 1000000007;
template <class T> using heap = priority_queue<T, vector<T>, greater<T>>;
template <class T> using pque = priority_queue<T, vector<T>, function<T(T, T)>>;
template <class T> inline void hash_combine(size_t &seed, const T &v) {
  hash<T> hasher;
  seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
}
namespace std {
template <typename S, typename T> struct hash<pair<S, T>> {
  inline size_t operator()(const pair<S, T> &v) const {
    size_t seed = 0;
    hash_combine(seed, v.first);
    hash_combine(seed, v.second);
    return seed;
  }
};
// Recursive template code derived from Matthieu M.
template <class Tuple, size_t Index = std::tuple_size<Tuple>::value - 1>
struct HashValueImpl {
  static void apply(size_t &seed, Tuple const &tuple) {
    HashValueImpl<Tuple, Index - 1>::apply(seed, tuple);
    hash_combine(seed, std::get<Index>(tuple));
  }
};
template <class Tuple> struct HashValueImpl<Tuple, 0> {
  static void apply(size_t &seed, Tuple const &tuple) {
    hash_combine(seed, std::get<0>(tuple));
  }
};
template <typename... TT> struct hash<std::tuple<TT...>> {
  size_t operator()(std::tuple<TT...> const &tt) const {
    size_t seed = 0;
    HashValueImpl<std::tuple<TT...>>::apply(seed, tt);
    return seed;
  }
};
} // namespace std
template <class T> int id(vector<T> &a, T b) {
  return lower_bound(ALL(a), b) - a.begin();
}
ll pow(ll base, ll i, ll mod) {
  ll a = 1;
  while (i) {
    if (i & 1) {
      a *= base;
      a %= mod;
    }
    base *= base;
    base %= mod;
    i /= 2;
  }
  return a;
}
ll gcd(ll a, ll b) {
  while (b) {
    ll c = a % b;
    a = b;
    b = c;
  }
  return a;
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int popcnt(unsigned long long a) {
  a = (a & 0x5555555555555555) + (a >> 1 & 0x5555555555555555);
  a = (a & 0x3333333333333333) + (a >> 2 & 0x3333333333333333);
  a = (a & 0x0f0f0f0f0f0f0f0f) + (a >> 4 & 0x0f0f0f0f0f0f0f0f);
  a = (a & 0x00ff00ff00ff00ff) + (a >> 8 & 0x00ff00ff00ff00ff);
  a = (a & 0x0000ffff0000ffff) + (a >> 16 & 0x0000ffff0000ffff);
  return (a & 0xffffffff) + (a >> 32);
}
class unionfind {
  vector<int> par, rank,
      size_; //????????§??????????????¢???????????????????????????rank???????????????size?????????
public:
  unionfind(int n) : par(n), rank(n), size_(n, 1) { iota(ALL(par), 0); }
  int find(int x) {
    if (par[x] == x)
      return x;
    return par[x] = find(par[x]);
  }
  void unite(int x, int y) {
    x = find(x), y = find(y);
    if (x == y)
      return;
    if (rank[x] < rank[y])
      swap(x, y);
    par[y] = x;
    size_[x] += size_[y];
    if (rank[x] == rank[y])
      rank[x]++;
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return size_[find(x)]; }
};
typedef complex<ld> P;
typedef vector<P> VP;
const ld eps = 1e-11, pi = acos(-1.0);

ld dot(P a, P b) { return real(conj(a) * b); }
ld cross(P a, P b) { return imag(conj(a) * b); }

namespace std {
bool operator<(const P &a, const P &b) {
  return abs(a.real() - b.real()) < eps ? a.imag() < b.imag()
                                        : a.real() < b.real();
}
} // namespace std

struct L {
  P a, b;
}; // line->l,segment->s
struct C {
  P p;
  ld r;
};

int ccw(P a, P b, P c) {
  b -= a;
  c -= a;
  if (cross(b, c) > eps)
    return 1; // counter clockwise
  if (cross(b, c) < -eps)
    return -1; // clockwise
  if (dot(b, c) < 0)
    return 2; // c--a--b on line
  if (norm(b) < norm(c))
    return -2; // a--b--c on line
  return 0;    // a--c--b on line
}

bool isis_ll(L l, L m) { // is intersect
  return abs(cross(l.b - l.a, m.b - m.a)) > eps;
}

bool isis_ls(L l, L s) {
  ld a = cross(l.b - l.a, s.a - l.a);
  ld b = cross(l.b - l.a, s.b - l.a);
  return (a * b < eps);
}

bool isis_lp(L l, P p) { return abs(cross(l.b - p, l.a - p)) < eps; }

bool isis_ss(L s, L t) {
  return ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0 &&
         ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0;
}

P is_ll(L s, L t) { // intersect
  P sv = s.b - s.a, tv = t.b - t.a;
  return s.a + sv * cross(tv, t.a - s.a) / cross(tv, sv);
}

bool isis_sp(L s, P p) {
  return abs(s.a - p) + abs(s.b - p) - abs(s.b - s.a) < eps;
}

P proj(L l, P p) {
  ld t = dot(p - l.a, l.a - l.b) / norm(l.a - l.b);
  return l.a + t * (l.a - l.b);
}

ld dist_lp(L l, P p) { return abs(p - proj(l, p)); }

ld dist_ll(L l, L m) { return isis_ll(l, m) ? 0 : dist_lp(l, m.a); }

ld dist_ls(L l, L s) {
  if (isis_ls(l, s))
    return 0;
  return min(dist_lp(l, s.a), dist_lp(l, s.b));
}

ld dist_sp(L s, P p) {
  P r = proj(s, p);
  if (isis_sp(s, r))
    return abs(r - p);
  return min(abs(s.a - p), abs(s.b - p));
}

ld dist_ss(L s, L t) {
  if (isis_ss(s, t))
    return 0;
  ld a = min(dist_sp(s, t.a), dist_sp(t, s.a));
  ld b = min(dist_sp(s, t.b), dist_sp(t, s.b));
  return min(a, b);
}

VP is_cc(C c1, C c2) {
  VP res;
  ld d = abs(c1.p - c2.p);
  ld rc = (d * d + c1.r * c1.r - c2.r * c2.r) / (2 * d);
  ld dfr = c1.r * c1.r - rc * rc;
  if (abs(dfr) < eps)
    dfr = 0.0;
  else if (dfr < 0.0)
    return res; // no intersection
  ld rs = sqrt(dfr);
  P diff = (c2.p - c1.p) / d;
  res.push_back(c1.p + diff * P(rc, rs));
  if (dfr != 0.0)
    res.push_back(c1.p + diff * P(rc, -rs));
  return res;
}

bool isis_vc(vector<C> vc) {
  VP crs;
  int n = vc.size();
  rep(i, n) rep(j, i) for (P p : is_cc(vc[i], vc[j])) crs.push_back(p);
  rep(i, n) crs.push_back(vc[i].p);
  for (P p : crs) {
    bool valid = true;
    rep(i, n) if (abs(p - vc[i].p) > vc[i].r + eps) valid = false;
    if (valid)
      return true;
  }
  return false;
}

VP is_lc(C c, L l) {
  VP res;
  ld d = dist_lp(l, c.p);
  if (d < c.r + eps) {
    ld len = (d > c.r) ? 0.0 : sqrt(c.r * c.r - d * d); // safety;
    P nor = (l.a - l.b) / abs(l.a - l.b);
    res.push_back(proj(l, c.p) + len * nor);
    res.push_back(proj(l, c.p) - len * nor);
  }
  return res;
}

VP is_sc(C c, L l) {
  VP v = is_lc(c, l), res;
  for (P p : v)
    if (isis_sp(l, p))
      res.push_back(p);
  return res;
}

vector<L> tangent_cp(C c, P p) { //????????\\????
  vector<L> ret;
  P v = c.p - p;
  ld d = abs(v);
  ld l = sqrt(norm(v) - c.r * c.r);
  if (std::isnan(l)) {
    return ret;
  }
  P v1 = v * P(l / d, c.r / d);
  P v2 = v * P(l / d, -c.r / d);
  ret.push_back(L{p, p + v1});
  if (l < eps)
    return ret;
  ret.push_back(L{p, p + v2});
  return ret;
}

vector<L> tangent_cc(C c1, C c2) {
  vector<L> ret;
  if (abs(c1.p - c2.p) - (c1.r + c2.r) > -eps) {
    P center = (c1.p * c2.r + c2.p * c1.r) / (c1.r + c2.r);
    ret = tangent_cp(c1, center);
  }
  if (abs(c1.r - c2.r) > eps) {
    P out = (-c1.p * c2.r + c2.p * c1.r) / (c1.r - c2.r);
    vector<L> nret = tangent_cp(c1, out);
    ret.insert(ret.end(), ALL(nret));
  } else {
    P v = c2.p - c1.p;
    v /= abs(v);
    P q1 = c1.p + v * P(0, 1) * c1.r;
    P q2 = c1.p + v * P(0, -1) * c1.r;
    ret.push_back(L{q1, q1 + v});
    ret.push_back(L{q2, q2 + v});
  }
  return ret;
}

ld area(const VP &p) { //??¢?????
  ld res = 0;
  int n = p.size();
  rep(j, n) res += cross(p[j], p[(j + 1) % n]);
  return res / 2;
}

bool is_polygon(L l, VP &g) {
  int n = g.size();
  for (int i = 0; i < n; i++) {
    P a = g[i];
    P b = g[(i + 1) % n];
    if (isis_ss(l, L{a, b}))
      return true;
  }
  return false;
}

int is_in_Polygon(const VP &g, P p) {
  bool in = false;
  int n = g.size();
  for (int i = 0; i < n; i++) {
    P a = g[i] - p, b = g[(i + 1) % n] - p;
    if (imag(a) > imag(b))
      swap(a, b);
    if (imag(a) <= 0 && 0 < imag(b))
      if (cross(a, b) < 0)
        in = !in;
    if (abs(cross(a, b)) < eps && dot(a, b) < eps)
      return 0; // on
  }
  if (in)
    return 1; // in
  return -1;  // out
}

VP ConvexHull(VP ps) {
  int n = ps.size();
  int k = 0;
  sort(ps.begin(), ps.end());
  VP ch(2 * n);
  for (int i = 0; i < n; ch[k++] = ps[i++])
    while (k >= 2 && ccw(ch[k - 2], ch[k - 1], ps[i]) <= 0)
      --k;
  for (int i = n - 2, t = k + 1; i >= 0; ch[k++] = ps[i--])
    while (k >= t && ccw(ch[k - 2], ch[k - 1], ps[i]) <= 0)
      --k;
  ch.resize(k - 1);
  return ch;
}

VP ConvexCut(const VP &ps, L l) {
  VP Q;
  for (int i = 0; i < (int)ps.size(); i++) {
    P A = ps[i], B = ps[(i + 1) % ps.size()];
    if (ccw(l.a, l.b, A) != -1)
      Q.push_back(A);
    if (ccw(l.a, l.b, A) * ccw(l.a, l.b, B) < 0)
      Q.push_back(is_ll(L{A, B}, l));
  }
  return Q;
}
// end of lib
// template<class S=void,int ptr_num, class T = char>class trie {
//	umap<T, trie<S, ptr_num, T> next;
// public:
//	S key;
//	trie<S, ptr_num, T>* ptr[ptr_num] = {};
//	trie(S &&data) :key(data) {}
//	trie(const S &data) :key(data) {}
//	void add(T x,S data) {
//		if (!next.find(x))next.insert(x, data);
//	}
//	trie& operator[](T x) {
//		return next[x];
//	}
//	bool find(T x) {
//		retun next.find(x);
//	}
// };
// template<class T=char>class AhoCorasick {
//	trie<pair<bool,int>, 2, T> tree;
//	AhoCorasick(vector<string> p) {
//		int num = 0;
//		vector<decltype(&tree)> que(p.size(),&tree);
//		for (int i = 0;; i++) {
//			bool end = 1;
//			int i = 0;
//			for (auto a : p) {
//				if (i >= a.size())break;
//				end = ;0
//				que[i] = (*que[i])[a[i]];
//				i++;
//			}
//			if (end)break;
//		}
//	}
// };
#include <fstream>
#include <sstream>
class svg {
  ofstream f;
  stringstream s;
  double x1 = 1e9, y1 = 1e9, x2 = -1e9, y2 = -1e9;

public:
  svg(string path) : f(path, ios::trunc) {}
  ~svg() {
    f << "<?xml version=\\"1.0\\" standalone=\\"no\\"?><svg viewBox='"
      << x1 * 1.1 - x2 * 0.1 << " " << y1 * 1.1 - y2 * 0.1 << " "
      << (x2 - x1) * 1.2 << " " << (y2 - y1) * 1.2
      << "' xmlns = \\"http://www.w3.org/2000/svg\\" xmlns:xlink = "
         "\\"http://www.w3.org/1999/xlink\\" >\\n";
    f << s.str();
    f << "</svg>";
  }
  void circle(C c) {
    s << fixed << "<circle cx = \\"" << c.p.real() << "\\" cy = \\"" << c.p.imag()
      << "\\" r = \\"" << c.r
      << "\\" stroke=\\"black\\" stroke-width=\\"0.01\\" fill = \\"none\\"/>\\n";
    cmin(x1, c.p.real() - c.r);
    cmin(y1, c.p.imag() - c.r);
    cmax(x2, c.p.real() + c.r);
    cmax(y2, c.p.imag() + c.r);
  }
  void line(L l) {
    s << fixed << "<line x1=\\"" << l.a.real() << "\\" y1=\\"" << l.a.imag()
      << "\\" x2=\\"" << l.b.real() << "\\" y2=\\"" << l.b.imag()
      << "\\" stroke=\\"black\\" stroke-width=\\"0.01\\"/>\\n";
    cmin(x1, l.a.real());
    cmin(y1, l.a.imag());
    cmax(x2, l.a.real());
    cmax(y2, l.a.imag());
    cmin(x1, l.b.real());
    cmin(y1, l.b.imag());
    cmax(x2, l.b.real());
    cmax(y2, l.b.imag());
  }
};
int main() {
  VP p(3);
  for (;;) {
    rep(i, 3) {
      int x, y;
      cin >> x >> y;
      p[i] = {(double)x, (double)y};
    }
    if (p[0] == p[1])
      break;
    P up1 = (p[1] * abs(p[2] - p[0]) + p[2] * abs(p[1] - p[0])) /
            (abs(p[2] - p[0]) + abs(p[1] - p[0]));
    P dn1 = p[0];
    P up2, up3;
    double r1, r2, r3;
    rep(i, 50) {
      P m1 = (up1 + dn1) * 0.5;
      r1 = dist_lp({p[0], p[1]}, m1);
      up2 = (p[0] * abs(p[2] - p[1]) + p[2] * abs(p[0] - p[1])) /
            (abs(p[2] - p[1]) + abs(p[0] - p[1]));
      up3 = (p[0] * abs(p[2] - p[1]) + p[1] * abs(p[0] - p[2])) /
            (abs(p[2] - p[1]) + abs(p[0] - p[2]));
      P dn2 = p[1], dn3 = p[2];
      rep(j, 50) {
        P m2 = (up2 + dn2) * 0.5, m3 = (up3 + dn3) * 0.5;
        r2 = dist_lp({p[0], p[1]}, m2);
        r3 = dist_lp({p[0], p[2]}, m3);
        if (!isis_ls({p[0], up1}, {p[1], m2}) &&
            dist_lp({p[0], p[2]}, m2) > r2 && abs(m1 - m2) > r1 + r2)
          dn2 = m2;
        else
          up2 = m2;
        if (!isis_ls({p[0], up1}, {p[2], m3}) &&
            dist_lp({p[0], p[1]}, m3) > r3 && abs(m3 - m1) > r1 + r3)
          dn3 = m3;
        else
          up3 = m3;
      }
      if (dist_lp({p[1], p[2]}, m1) > r1 && abs(up2 - up3) < r2 + r3)
        dn1 = m1;
      else
        up1 = m1;
    }
    cout << fixed << setprecision(10) << r1 << " " << r2 << " " << r3 << endl;
    svg s("out.svg");
    rep(i, 3) s.line({p[i], p[(i + 1) % 3]});
    s.circle({up1, r1});
    s.circle({up2, r2});
    s.circle({up3, r3});
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
// cin.sync_with_stdio(false);
// streambuf
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using ti3 = tuple<int, int, int>;
using vti3 = vector<ti3>;
template <class T, int s> using va = vector<array<T, s>>;
template <class T, class T2> using umap = unordered_map<T, T2>;
template <class T> using uset = unordered_set<T>;
template <class T, class S> void cmin(T &a, const S &b) {
  if (a > b)
    a = b;
}
template <class T, class S> void cmax(T &a, const S &b) {
  if (a < b)
    a = b;
}
#define ALL(a) a.begin(), a.end()
#define rep(i, a) for (int i = 0; i < a; i++)
#define rep1(i, a) for (int i = 1; i <= a; i++)
#define rrep(i, a) for (int i = (a)-1; i >= 0; i--)
#define rrep1(i, a) for (int i = a; i; i--)
#define repi(i, a, b)                                                          \\
  for (int i = a; i < b; i++)                                                  \\
    ;
const ll mod = 1000000007;
template <class T> using heap = priority_queue<T, vector<T>, greater<T>>;
template <class T> using pque = priority_queue<T, vector<T>, function<T(T, T)>>;
template <class T> inline void hash_combine(size_t &seed, const T &v) {
  hash<T> hasher;
  seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
}
namespace std {
template <typename S, typename T> struct hash<pair<S, T>> {
  inline size_t operator()(const pair<S, T> &v) const {
    size_t seed = 0;
    hash_combine(seed, v.first);
    hash_combine(seed, v.second);
    return seed;
  }
};
// Recursive template code derived from Matthieu M.
template <class Tuple, size_t Index = std::tuple_size<Tuple>::value - 1>
struct HashValueImpl {
  static void apply(size_t &seed, Tuple const &tuple) {
    HashValueImpl<Tuple, Index - 1>::apply(seed, tuple);
    hash_combine(seed, std::get<Index>(tuple));
  }
};
template <class Tuple> struct HashValueImpl<Tuple, 0> {
  static void apply(size_t &seed, Tuple const &tuple) {
    hash_combine(seed, std::get<0>(tuple));
  }
};
template <typename... TT> struct hash<std::tuple<TT...>> {
  size_t operator()(std::tuple<TT...> const &tt) const {
    size_t seed = 0;
    HashValueImpl<std::tuple<TT...>>::apply(seed, tt);
    return seed;
  }
};
} // namespace std
template <class T> int id(vector<T> &a, T b) {
  return lower_bound(ALL(a), b) - a.begin();
}
ll pow(ll base, ll i, ll mod) {
  ll a = 1;
  while (i) {
    if (i & 1) {
      a *= base;
      a %= mod;
    }
    base *= base;
    base %= mod;
    i /= 2;
  }
  return a;
}
ll gcd(ll a, ll b) {
  while (b) {
    ll c = a % b;
    a = b;
    b = c;
  }
  return a;
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int popcnt(unsigned long long a) {
  a = (a & 0x5555555555555555) + (a >> 1 & 0x5555555555555555);
  a = (a & 0x3333333333333333) + (a >> 2 & 0x3333333333333333);
  a = (a & 0x0f0f0f0f0f0f0f0f) + (a >> 4 & 0x0f0f0f0f0f0f0f0f);
  a = (a & 0x00ff00ff00ff00ff) + (a >> 8 & 0x00ff00ff00ff00ff);
  a = (a & 0x0000ffff0000ffff) + (a >> 16 & 0x0000ffff0000ffff);
  return (a & 0xffffffff) + (a >> 32);
}
class unionfind {
  vector<int> par, rank,
      size_; //????????§??????????????¢???????????????????????????rank???????????????size?????????
public:
  unionfind(int n) : par(n), rank(n), size_(n, 1) { iota(ALL(par), 0); }
  int find(int x) {
    if (par[x] == x)
      return x;
    return par[x] = find(par[x]);
  }
  void unite(int x, int y) {
    x = find(x), y = find(y);
    if (x == y)
      return;
    if (rank[x] < rank[y])
      swap(x, y);
    par[y] = x;
    size_[x] += size_[y];
    if (rank[x] == rank[y])
      rank[x]++;
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return size_[find(x)]; }
};
typedef complex<ld> P;
typedef vector<P> VP;
const ld eps = 1e-11, pi = acos(-1.0);

ld dot(P a, P b) { return real(conj(a) * b); }
ld cross(P a, P b) { return imag(conj(a) * b); }

namespace std {
bool operator<(const P &a, const P &b) {
  return abs(a.real() - b.real()) < eps ? a.imag() < b.imag()
                                        : a.real() < b.real();
}
} // namespace std

struct L {
  P a, b;
}; // line->l,segment->s
struct C {
  P p;
  ld r;
};

int ccw(P a, P b, P c) {
  b -= a;
  c -= a;
  if (cross(b, c) > eps)
    return 1; // counter clockwise
  if (cross(b, c) < -eps)
    return -1; // clockwise
  if (dot(b, c) < 0)
    return 2; // c--a--b on line
  if (norm(b) < norm(c))
    return -2; // a--b--c on line
  return 0;    // a--c--b on line
}

bool isis_ll(L l, L m) { // is intersect
  return abs(cross(l.b - l.a, m.b - m.a)) > eps;
}

bool isis_ls(L l, L s) {
  ld a = cross(l.b - l.a, s.a - l.a);
  ld b = cross(l.b - l.a, s.b - l.a);
  return (a * b < eps);
}

bool isis_lp(L l, P p) { return abs(cross(l.b - p, l.a - p)) < eps; }

bool isis_ss(L s, L t) {
  return ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0 &&
         ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0;
}

P is_ll(L s, L t) { // intersect
  P sv = s.b - s.a, tv = t.b - t.a;
  return s.a + sv * cross(tv, t.a - s.a) / cross(tv, sv);
}

bool isis_sp(L s, P p) {
  return abs(s.a - p) + abs(s.b - p) - abs(s.b - s.a) < eps;
}

P proj(L l, P p) {
  ld t = dot(p - l.a, l.a - l.b) / norm(l.a - l.b);
  return l.a + t * (l.a - l.b);
}

ld dist_lp(L l, P p) { return abs(p - proj(l, p)); }

ld dist_ll(L l, L m) { return isis_ll(l, m) ? 0 : dist_lp(l, m.a); }

ld dist_ls(L l, L s) {
  if (isis_ls(l, s))
    return 0;
  return min(dist_lp(l, s.a), dist_lp(l, s.b));
}

ld dist_sp(L s, P p) {
  P r = proj(s, p);
  if (isis_sp(s, r))
    return abs(r - p);
  return min(abs(s.a - p), abs(s.b - p));
}

ld dist_ss(L s, L t) {
  if (isis_ss(s, t))
    return 0;
  ld a = min(dist_sp(s, t.a), dist_sp(t, s.a));
  ld b = min(dist_sp(s, t.b), dist_sp(t, s.b));
  return min(a, b);
}

VP is_cc(C c1, C c2) {
  VP res;
  ld d = abs(c1.p - c2.p);
  ld rc = (d * d + c1.r * c1.r - c2.r * c2.r) / (2 * d);
  ld dfr = c1.r * c1.r - rc * rc;
  if (abs(dfr) < eps)
    dfr = 0.0;
  else if (dfr < 0.0)
    return res; // no intersection
  ld rs = sqrt(dfr);
  P diff = (c2.p - c1.p) / d;
  res.push_back(c1.p + diff * P(rc, rs));
  if (dfr != 0.0)
    res.push_back(c1.p + diff * P(rc, -rs));
  return res;
}

bool isis_vc(vector<C> vc) {
  VP crs;
  int n = vc.size();
  rep(i, n) rep(j, i) for (P p : is_cc(vc[i], vc[j])) crs.push_back(p);
  rep(i, n) crs.push_back(vc[i].p);
  for (P p : crs) {
    bool valid = true;
    rep(i, n) if (abs(p - vc[i].p) > vc[i].r + eps) valid = false;
    if (valid)
      return true;
  }
  return false;
}

VP is_lc(C c, L l) {
  VP res;
  ld d = dist_lp(l, c.p);
  if (d < c.r + eps) {
    ld len = (d > c.r) ? 0.0 : sqrt(c.r * c.r - d * d); // safety;
    P nor = (l.a - l.b) / abs(l.a - l.b);
    res.push_back(proj(l, c.p) + len * nor);
    res.push_back(proj(l, c.p) - len * nor);
  }
  return res;
}

VP is_sc(C c, L l) {
  VP v = is_lc(c, l), res;
  for (P p : v)
    if (isis_sp(l, p))
      res.push_back(p);
  return res;
}

vector<L> tangent_cp(C c, P p) { //????????\\????
  vector<L> ret;
  P v = c.p - p;
  ld d = abs(v);
  ld l = sqrt(norm(v) - c.r * c.r);
  if (isnan(l)) {
    return ret;
  }
  P v1 = v * P(l / d, c.r / d);
  P v2 = v * P(l / d, -c.r / d);
  ret.push_back(L{p, p + v1});
  if (l < eps)
    return ret;
  ret.push_back(L{p, p + v2});
  return ret;
}

vector<L> tangent_cc(C c1, C c2) {
  vector<L> ret;
  if (abs(c1.p - c2.p) - (c1.r + c2.r) > -eps) {
    P center = (c1.p * c2.r + c2.p * c1.r) / (c1.r + c2.r);
    ret = tangent_cp(c1, center);
  }
  if (abs(c1.r - c2.r) > eps) {
    P out = (-c1.p * c2.r + c2.p * c1.r) / (c1.r - c2.r);
    vector<L> nret = tangent_cp(c1, out);
    ret.insert(ret.end(), ALL(nret));
  } else {
    P v = c2.p - c1.p;
    v /= abs(v);
    P q1 = c1.p + v * P(0, 1) * c1.r;
    P q2 = c1.p + v * P(0, -1) * c1.r;
    ret.push_back(L{q1, q1 + v});
    ret.push_back(L{q2, q2 + v});
  }
  return ret;
}

ld area(const VP &p) { //??¢?????
  ld res = 0;
  int n = p.size();
  rep(j, n) res += cross(p[j], p[(j + 1) % n]);
  return res / 2;
}

bool is_polygon(L l, VP &g) {
  int n = g.size();
  for (int i = 0; i < n; i++) {
    P a = g[i];
    P b = g[(i + 1) % n];
    if (isis_ss(l, L{a, b}))
      return true;
  }
  return false;
}

int is_in_Polygon(const VP &g, P p) {
  bool in = false;
  int n = g.size();
  for (int i = 0; i < n; i++) {
    P a = g[i] - p, b = g[(i + 1) % n] - p;
    if (imag(a) > imag(b))
      swap(a, b);
    if (imag(a) <= 0 && 0 < imag(b))
      if (cross(a, b) < 0)
        in = !in;
    if (abs(cross(a, b)) < eps && dot(a, b) < eps)
      return 0; // on
  }
  if (in)
    return 1; // in
  return -1;  // out
}

VP ConvexHull(VP ps) {
  int n = ps.size();
  int k = 0;
  sort(ps.begin(), ps.end());
  VP ch(2 * n);
  for (int i = 0; i < n; ch[k++] = ps[i++])
    while (k >= 2 && ccw(ch[k - 2], ch[k - 1], ps[i]) <= 0)
      --k;
  for (int i = n - 2, t = k + 1; i >= 0; ch[k++] = ps[i--])
    while (k >= t && ccw(ch[k - 2], ch[k - 1], ps[i]) <= 0)
      --k;
  ch.resize(k - 1);
  return ch;
}

VP ConvexCut(const VP &ps, L l) {
  VP Q;
  for (int i = 0; i < (int)ps.size(); i++) {
    P A = ps[i], B = ps[(i + 1) % ps.size()];
    if (ccw(l.a, l.b, A) != -1)
      Q.push_back(A);
    if (ccw(l.a, l.b, A) * ccw(l.a, l.b, B) < 0)
      Q.push_back(is_ll(L{A, B}, l));
  }
  return Q;
}
// end of lib
// template<class S=void,int ptr_num, class T = char>class trie {
//	umap<T, trie<S, ptr_num, T> next;
// public:
//	S key;
//	trie<S, ptr_num, T>* ptr[ptr_num] = {};
//	trie(S &&data) :key(data) {}
//	trie(const S &data) :key(data) {}
//	void add(T x,S data) {
//		if (!next.find(x))next.insert(x, data);
//	}
//	trie& operator[](T x) {
//		return next[x];
//	}
//	bool find(T x) {
//		retun next.find(x);
//	}
// };
// template<class T=char>class AhoCorasick {
//	trie<pair<bool,int>, 2, T> tree;
//	AhoCorasick(vector<string> p) {
//		int num = 0;
//		vector<decltype(&tree)> que(p.size(),&tree);
//		for (int i = 0;; i++) {
//			bool end = 1;
//			int i = 0;
//			for (auto a : p) {
//				if (i >= a.size())break;
//				end = ;0
//				que[i] = (*que[i])[a[i]];
//				i++;
//			}
//			if (end)break;
//		}
//	}
// };
int main() {
  VP p(3);
  for (;;) {
    rep(i, 3) {
      int x, y;
      cin >> x >> y;
      p[i] = {(double)x, (double)y};
    }
    if (p[0] == p[1])
      break;
    P up1 = (p[1] * abs(p[2] - p[0]) + p[2] * abs(p[1] - p[0])) /
            (abs(p[2] - p[0]) + abs(p[1] - p[0]));
    P dn1 = p[0];
    double r1, r2, r3;
    rep(i, 100) {
      P m1 = (up1 + dn1) * 0.5l;
      r1 = dist_lp({p[0], p[1]}, m1);
      P up2 = (p[0] * abs(p[2] - p[1]) + p[2] * abs(p[0] - p[1])) /
              (abs(p[2] - p[1]) + abs(p[0] - p[1]));
      P up3 = (p[0] * abs(p[2] - p[1]) + p[1] * abs(p[0] - p[2])) /
              (abs(p[2] - p[1]) + abs(p[0] - p[2]));
      P dn2 = p[1], dn3 = p[2];
      rep(j, 100) {
        P m2 = (up2 + dn2) * 0.5l, m3 = (up3 + dn3) * 0.5l;
        r2 = dist_lp({p[0], p[1]}, m2);
        r3 = dist_lp({p[0], p[2]}, m3);
        if (!isis_ss({p[0], m1}, {p[1], m2}) &&
            dist_lp({p[0], p[2]}, m2) > r2 && abs(m1 - m2) > r1 + r2)
          dn2 = m2;
        else
          up2 = m2;
        if (!isis_ss({p[0], m1}, {p[2], m3}) &&
            dist_lp({p[0], p[1]}, m3) > r3 && abs(m3 - m1) > r1 + r3)
          dn3 = m3;
        else
          up3 = m3;
      }
      if (isis_ss({p[1], up2}, {p[2], up3}) || abs(up2 - up3) < r2 + r3)
        dn1 = m1;
      else
        up1 = m1;
    }
    cout << fixed << setprecision(10) << r1 << " " << r2 << " " << r3 << endl;
  }
}