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

#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
struct Point {
  long double px, py;
};
struct Circle {
  Point p;
  long double r;
};
inline Point pol(long double r, long double d) {
  return Point{cosl(d) * r, sinl(d) * r};
}
inline long double arg(const Point &a) { return atan2l(a.py, a.px); }
inline long double norm(const Point &a) { return a.px * a.px + a.py * a.py; }
inline long double abs(const Point &a) { return sqrtl(norm(a)); }
inline Point Minus(Point a, Point b) { return Point{a.px - b.px, a.py - b.py}; }
inline Point Plus(Point a, Point b) { return Point{a.px + b.px, a.py + b.py}; }
inline long double dst(const Point &a, const Point &b) {
  return abs(Minus(b, a));
}
inline vector<Point> crp(Circle c1, Circle c2) {
  double d = abs(Minus(c1.p, c2.p));
  double a = acos((c1.r * c1.r + d * d - c2.r * c2.r) / (2 * c1.r * d));
  double t = arg(Minus(c2.p, c1.p));
  return vector<Point>(
      {Plus(c1.p, pol(c1.r, t + a)), Plus(c1.p, pol(c1.r, t - a))});
}
int main() {
  Circle x[100];
  int n;
  while (true) {
    cin >> n;
    char ch;
    if (n == 0)
      break;
    for (int i = 0; i < n; i++) {
      cin >> x[i].p.px >> ch >> x[i].p.py;
      x[i].r = 1.0l;
    }
    int maxn = 1;
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        if (dst(x[i].p, x[j].p) > 2.0l + 1e-10)
          continue;
        vector<Point> z = crp(x[i], x[j]);
        for (int k = 0; k < 2; k++) {
          int cnt = 0;
          for (int l = 0; l < n; l++) {
            if (dst(z[k], x[l].p) <= 1.0l + 1e-10) {
              cnt++;
            }
          }
          maxn = max(maxn, cnt);
        }
      }
    }
    cout << maxn << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
struct Point {
  long double px, py;
};
struct Circle {
  Point p;
  long double r;
};
inline Point pol(long double r, long double d) {
  return Point{cosl(d) * r, sinl(d) * r};
}
inline long double arg(const Point &a) { return atan2l(a.py, a.px); }
inline long double norm(const Point &a) { return a.px * a.px + a.py * a.py; }
inline long double abs(const Point &a) { return sqrtl(norm(a)); }
inline Point Minus(Point a, Point b) { return Point{a.px - b.px, a.py - b.py}; }
inline Point Plus(Point a, Point b) { return Point{a.px + b.px, a.py + b.py}; }
inline long double dst(const Point &a, const Point &b) {
  return abs(Minus(b, a));
}
inline vector<Point> crp(Circle c1, Circle c2) {
  double d = abs(Minus(c1.p, c2.p));
  double a = acos((c1.r * c1.r + d * d - c2.r * c2.r) / (2 * c1.r * d));
  double t = arg(Minus(c2.p, c1.p));
  return vector<Point>(
      {Plus(c1.p, pol(c1.r, t + a)), Plus(c1.p, pol(c1.r, t - a))});
}
int main() {
  Circle x[100];
  int n;
  while (true) {
    cin >> n;
    char ch;
    if (n == 0)
      break;
    for (int i = 0; i < n; i++) {
      cin >> x[i].p.px >> ch >> x[i].p.py;
      x[i].r = 1.0l;
    }
    int maxn = 0;
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        vector<Point> z = crp(x[i], x[j]);
        for (int k = 0; k < 2; k++) {
          int cnt = 0;
          for (int l = 0; l < n; l++) {
            if (dst(z[k], x[l].p) <= 1.0l) {
              cnt++;
            }
          }
          maxn = max(maxn, cnt);
        }
      }
    }
    cout << maxn << endl;
  }
  return 0;
}