Language: C++

#include <iostream>
#include <complex>
#include <vector>
#include <cmath>
#include <cfloat>

using namespace std;

typedef complex<double> P;
const double PI = atan(1)*4;
const double EPS = 1e-9;

int cmp(double a, double b) {
    double diff = a-b;
    if(abs(diff) < EPS) return 0;
    if(diff < 0) return -1;
    return 1;
}

bool isnan_(double d) {
    return !(d == d);
}

bool in_angle(double start, double angle, double end) {
    if(start > end) {
        return in_angle(start, angle, PI) || in_angle(-PI, angle, end);
    } else {
        return cmp(start, angle) <= 0 && cmp(angle, end) <= 0;
    }
}

inline double dot(const P& a, const P& b) { return a.real()*b.real() + a.imag()*b.imag(); }
inline double cross(const P& a, const P& b) { return a.real()*b.imag() - b.real()*a.imag(); }
int ccw(const P& a, P b, P c)
{
  b -= a;
  c -= a;
  if (cross(b, c) > EPS) {
    return +1;
  } else if (cross(b, c) < -EPS) {
    return -1;
  } else if (dot(b, c) < -EPS) {
    return +2;
  } else if (dot(b, b) + EPS < dot(c, c)) {
    return -2;
  } else {
    return 0;
  }
}

struct line/*{{{*/
{
  P a, b;
  line() {}
  line(const P& p, const P& q) : a(p), b(q) {}

  inline bool parallel(const line& ln) const
  {
      return cmp(abs(cross(ln.b - ln.a, b - a)), 0) == 0;
  }

  inline bool intersects(const line& ln) const
  {
    return !parallel(ln);
  }

  inline P intersection(const line& ln) const
  {
    // assert(intersects(ln))
    const P x = b - a;
    const P y = ln.b - ln.a;
    return a + x*(cross(y, ln.a - a))/cross(y, x);
  }

  // AOJ 1171 Laser Beam Reflections
  inline P perpendicular(const P& p) const
  {
    // 点 p から直線上に下ろした垂線の足
    const double t = dot(p-a, a-b) / dot(b-a, b-a);
    return a + t*(a-b);
  }

  inline double distance(const P& p) const
  {
    return abs(cross(p - a, b - a)) / abs(b - a);
  }

};/*}}}*/

struct circle/*{{{*/
{
  P o;
  double r;
  circle() {}
  circle(const P& p, double x) : o(p), r(x) {}

  // POJ 1418 Viva Confetti
  // POJ 2149 Inherit the Spheres
  inline bool intersects(const circle& c) const
  {
    return !contains(c) && !c.contains(*this) && cmp(abs(o - c.o), r + c.r) <= 0;
  }

  pair<P,P> intersection(const circle& c) const
  {
    // assert(intersects(c))
    const double d = abs(o - c.o);
    const double cos_ = (d*d + r*r - c.r*c.r) / (2*d);
    const double sin_ = sqrt(r*r - cos_*cos_);
    const P e = (c.o - o) / d;
    return make_pair(o + e*P(cos_, sin_), o + e*P(cos_, -sin_));
  }

  inline bool contains(const circle& c) const
  {
      return cmp(abs(o - c.o)+c.r, r) <= 0;
  }

  inline bool intersects(const line& ln) const
  {
      return cmp(abs(ln.distance(o)), r) <= 0;
  }

  pair<P,P> intersection(const line& ln) const
  {
    // assert(intersects(ln))
    const P h = ln.perpendicular(o);
    const double d = abs(h - o);
    P ab = ln.b - ln.a;
    ab /= abs(ab);
    const double l = sqrt(r*r - d*d);
    return make_pair(h + l*ab, h - l*ab);
  }
};/*}}}*/

struct Arc {
    P center;
    double radius;
    double start, end;

    Arc(const P &c, double r, double s, double e) : center(c), radius(r), start(s), end(e) {}

    bool has(const P &p) const {
        P d = p - center;
        double angle = normalize(arg(d));
        return cmp(abs(d), radius) <= 0 && in_angle(start, angle, end);
    }

    vector<P> pseudo_intersections(const Arc &other) const {
        vector<P> res;
        circle c(center, radius), otherc(other.center, other.radius);
        if(c.intersects(otherc)) {
            pair<P,P> tmp = c.intersection(otherc);
            res.push_back(tmp.first);
            res.push_back(tmp.second);
        }
        if(c.contains(otherc)) {
            res.push_back(other.center);
        } else if(otherc.contains(c)) {
            res.push_back(center);
        }
        const line seg1(center, center+polar(radius, start));
        const line seg2(center, center+polar(radius, end));
        const line sego1(other.center, other.center+polar(other.radius, other.start));
        const line sego2(other.center, other.center+polar(other.radius, other.end));
#define ADD_INTERSECTION_SEGSEG(_seg1, _seg2) \
        do { \
            if(_seg1.intersects(_seg2)) res.push_back(_seg1.intersection(_seg2)); \
        } while(0)
        ADD_INTERSECTION_SEGSEG(seg1, sego1);
        ADD_INTERSECTION_SEGSEG(seg1, sego2);
        ADD_INTERSECTION_SEGSEG(seg2, sego1);
        ADD_INTERSECTION_SEGSEG(seg2, sego2);
#undef ADD_INTERSECTION_SEGSEG

#define ADD_INTERSECTION(_circle, _seg) \
        do { \
            if(_circle.intersects(_seg)) { \
                pair<P,P> tmp = _circle.intersection(_seg); \
                res.push_back(tmp.first); \
                res.push_back(tmp.second); \
            } \
        } while(0)
        ADD_INTERSECTION(c, sego1);
        ADD_INTERSECTION(c, sego2);
        ADD_INTERSECTION(otherc, seg1);
        ADD_INTERSECTION(otherc, seg2);
#undef ADD_INTERSECTION
        return res;
    }
};

double normalize(double angle) {
    if(angle > PI) return angle - 2*PI;
    if(angle < -PI) return angle + 2*PI;
    return angle;
}

void solve() {
    int M;
    cin >> M;
    vector<Arc> arcs;
    for(int i = 0; i < M; ++i) {
        int x, y, r, s, t;
        cin >> x >> y >> r >> s >> t;
        double srad = normalize(s*PI/180);
        double trad = normalize(t*PI/180);
        //cout << srad << " " << trad << endl;
        arcs.push_back(Arc(P(x, y), r, srad, trad));
    }
    vector<P> points;
    for(int i = 0; i < M; ++i) {
        const Arc &arc1 = arcs[i];
        points.push_back(arc1.center);
        points.push_back(arc1.center + polar(arc1.radius, arc1.start));
        points.push_back(arc1.center + polar(arc1.radius, arc1.end));
        for(int j = 0; j < i; ++j) {
            const Arc &arc2 = arcs[j];
            vector<P> tmp = arc1.pseudo_intersections(arc2);
            points.insert(points.end(), tmp.begin(), tmp.end());
        }
    }
    int ans = 0;
    for(const auto &p : points) {
        if(isnan_(p.real()) || isnan_(p.imag())) continue;
        {
            int cnt = 0;
            for(auto &arc : arcs) {
                if(arc.has(p)) ++cnt;
            }
            ans = max(ans, cnt);
        }
    }
    cout << ans << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);

    int N;
    cin >> N;
    while(N--) {
        solve();
    }
    return 0;
}

Compiler output:
a.cc: In member function 'bool Arc::has(const P&) const':
a.cc:145:24: error: 'normalize' was not declared in this scope
  145 |         double angle = normalize(arg(d));
      |                        ^~~~~~~~~