Problem:
Ciel, an idol whose appearance and behavior are similar to a fox, is participating in a rehearsal for the live concert which takes place in a few days.
To become a top idol, a large amount of effort is required!
The live stage can be expressed as a two-dimensional surface.
The live stage has
N
spotlights to illuminate the stage.
The
i
-th spotlight casts a light in the range of a circle with radius
r_{i}
.
The center of the light cast by the
i
-th spotlight moves along an orbital path
R_{i}
.
R_{i}
is described as a closed polygon, though
R_{i}
might contain self-intersections.
The spotlight begins to move from the first vertex of
R_{i}
.
All of the orbital period of each spotlight are the same.
Each spotlight moves at a constant speed, and all of them return to the starting point at the same time.
In the rehearsal, Ciel has to move from the starting point to the ending point indicated on the live stage.
To achieve her goal, it is not allowed to fall out from the area illuminated with the spotlight.
But, she doesn't have to be illuminated with the spotlight as long as she is standing on the starting point.
You may assume that she can move fast enough.
Answer if it is possible for her to move to the ending point.
Input
Each input dataset is given in the following format:
N
sx
sy
ex
ey
r_{1}
K_{1}
x_{11}
y_{11}
x_{12}
y_{12}
...
x_{1K_{1}}
y_{1K_{1}}
r_{2}
K_{2}
x_{21}
y_{21}
x_{22}
y_{22}
...
x_{2K_{2}}
y_{2K_{2}}
:
:
r_{N}
K_{N}
x_{N1}
y_{N1}
x_{N2}
y_{N2}
...
x_{NK_{N}}
y_{NK_{N}}
All inputs are integer. All coordinate information satisfies
-10,000 \leq x
,
y \leq 10,000
.
N
(
1 \leq N \leq 100
) indicates the number of spotlights.
(sx, sy)
and
(ex, ey)
indicate the starting point and the ending point of Ciel's path, respectively.
The following
N
lines denote the information of each spotlight.
r_{i}
(
1 \leq r_{i} \leq 100
) indicates the radius of the spotlight.
K_{i}
(
2 \leq K_{i} \leq 10
) indicates the number of vertices in the orbital path.
Then,
K_{i}
vertices are given. Two consecutive vertices on the same orbital path are located at different places.
The spotlight moves from the first point
(x_{i1}, y_{i1})
to the second point
(x_{i2}, y_{i2})
, then moves to the third point
(x_{i3}, y_{i3})
, and so on.
After moving to the
K_{i}
-th point
(x_{iK_{i}}, y_{iK_{i}})
, the spotlight returns to the first point
(x_{i1}, y_{i1})
and repeats again its movement.
Let
d_{ij}
be the closest distance between two central points of spotlight
i
and spotlight
j
.
d_{ij}
satisfies either of the following:
d_{ij} > r_{i} + r_{j} + 0.000001
d_{ij} < r_{i} + r_{j} - 0.000001
Furthermore, let
d_{i}
be the closest distance between a central point of spotlight
i
and either the starting point or the ending point.
d_{i}
satisfies either of the following:
d_{i} > r_{i} + 0.000001
d_{i} < r_{i} - 0.000001
Output
If it is possible for Ciel to move the ending point without falling out from the illuminated area,
output
Yes
in one line.
Otherwise, output
No
.
Sample 
...(truncated)

Submitted solutions:

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; --i)

#define all(c) std::begin(c), std::end(c)

#ifdef LOCAL
#define debug(...) debug_impl(#__VA_ARGS__, __VA_ARGS__)
template <class T, class ...Args> void debug_impl(string s, T&& f, Args &&...args) {
    cerr << "(" << s << "): " << "(" << forward<T>(f);
    ((cerr << ", " << forward<Args>(args)), ..., (cerr << ")\n"));
}
#else
#define debug(...) void(0)
#endif

template <class T> bool chmax(T& a, const T& b) { return b > a ? (a = b, true) : false; }
template <class T> bool chmin(T& a, const T& b) { return b < a ? (a = b, true) : false; }


template <class T> istream& operator>>(istream& in, vector<T>& v) {
    for (auto& e : v) in >> e;
    return in;
}
template <class ...Args> void read(Args&... args) {
    (cin >> ... >> args);
}

template <class T> ostream& operator<<(ostream& out, const vector<T>& v) {
    int n = v.size();
    rep(i, n) {
        out << v[i];
        if (i + 1 != n) out << ' ';
    }
    return out;
}

template <class T, class ...Tails> void print(T&& h, Tails &&... tails) {
    cout << h, ((cout << ' ' << forward<Tails>(tails)), ..., (cout << '\n'));
}

using ld = long double;
using point = complex<ld>;

constexpr ld eps = 1e-10;

ld dot(point const& a, point const& b) {
    return real(conj(a) * b);
}

ld cross(point const& a, point const& b) {
    return imag(conj(a) * b);
}

int ccw(point a, point b, point c) {
    b -= a; c -= a;
    if (cross(b, c) > eps) return 1;
    if (cross(b, c) < -eps) return -1;
    if (dot(b, c) < 0) return 2;
    if (norm(b) < norm(c)) return -2;
    return 0;
}

struct segment {
    point a, b;
    segment() : a(point{}), b(point{}) {}
    segment(point a, point b) : a(a), b(b) {}
};
struct line {
    point a, b;
    line() : a(point{}), b(point{}) {}
    line(point a, point b) : a(a), b(b) {}
    line(segment s) : a(s.a), b(s.b) {}
};

bool isis_ss(segment s, segment 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;
}

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

point proj(line l, point 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_sp(segment s, point p) {
    point r = proj(line(s), p);
    return isis_sp(s, r) ? abs(r - p) : min(abs(s.a - p), abs(s.b - p));
}

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

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

    int n;
    ld sx, sy, tx, ty;
    read(n, sx, sy, tx, ty);

    vector<vector<int>> g(n + 2);
    const int src = n, dst = n + 1;

    vector<pair<int, vector<point>>> polygon(n);
    rep(i, n) {
        int r, k;
        read(r, k);
        vector<point> vs(k);
        rep(i, k) {
            ld x, y;
            read(x, y);
            vs[i] = { x, y };
        }
        polygon[i] = { r, move(vs) };
    }

    vector<vector<ld>> len(n);
    vector<ld> v(n);
    rep(i, n) {
        auto [r, p] = polygon[i];

        rep(j, int(p.size())) {
            point a = p[j];
            point b = p[(j + 1) % p.size()];
            v[i] += abs(b - a);
            len[i].push_back(abs(b - a));
        }
    }

    int ri, rj;
    vector<point> pi, pj;

    rep(i, n) {
        tie(ri, pi) = polygon[i];
        const int si = pi.size();
        ld ti_fr = 0;
        rep(a, si) {
            ld ti_to = ti_fr + len[i][a] / v[i];
            const point pi_fr = pi[a], pi_to = pi[(a + 1) % si];
            const point di = (pi_to - pi_fr) / len[i][a];

            auto get_pi = [&](ld t) {
                // return pi_fr + di * (t - ti_fr);
                return pi_fr - v[i] * di * ti_fr + t * v[i] * di;
            };

            segment s(get_pi(ti_fr), get_pi(ti_to));

            debug(s.a, "=>", s.b);

            if (dist_sp(s, point(sx, sy)) <= ri) {
                debug(src, i);
                g[i].push_back(src);
                g[src].push_back(i);
            }
            if (dist_sp(s, point(tx, ty)) <= ri) {
                debug(dst, i);
                g[i].push_back(dst);
                g[dst].push_back(i);
            }

            ti_fr = ti_to;
        }
    }

    rep(i, n) rep(j, i) {
        tie(ri, pi) = polygon[i];
        tie(rj, pj) = polygon[j];
        const int si = pi.size(), sj = pj.size();


        ld ti_fr = 0;
        rep(a, si) {
            ld ti_to = ti_fr + len[i][a] / v[i];

            const point pi_fr = pi[a], pi_to = pi[(a + 1) % si];
            const point di = (pi_to - pi_fr) / abs(pi_to - pi_fr);

            auto get_pi = [&](ld t) {
                // return pi_fr + di * (t - ti_fr);
                return pi_fr - v[i] * di * ti_fr + t * v[i] * di;
            };

            ld tj_fr = 0;
            rep(b, sj) {
                ld tj_to = tj_fr + len[j][b] / v[j];

                ld tmin = max(ti_fr, tj_fr);
                ld tmax = min(ti_to, tj_to);

                if (tmin <= tmax) {
                    const point pj_fr = pj[b], pj_to = pj[(b + 1) % sj];
                    const point dj = (pj_to - pj_fr) / abs(pj_to - pj_fr);

                    auto get_pj = [&](ld t) {
                        // return pj_fr + dj * (t - tj_fr);
                        return pj_fr - v[j] * dj * tj_fr + t * v[j] * dj;
                    };

                    point a0 = pi_fr - di * v[i] * ti_fr;
                    point a1 = pj_fr - dj * v[j] * tj_fr;
                    point b0 = v[i] * di;
                    point b1 = v[j] * dj;

                    ld ax = (a0 - a1).real(), ay = (a0 - a1).imag();
                    ld bx = (b0 - b1).real(), by = (b0 - b1).imag();

                    // ld c0 = ax * ax + ay * ay;
                    ld c1 = 2 * (ax * bx + ay * by);
                    ld c2 = bx * bx + by * by;

                    ld dmin = min(abs(get_pi(tmin) - get_pj(tmin)), abs(get_pi(tmax) - get_pj(tmax)));
                    if (abs(c2) > eps) {
                        ld t = clamp(-c1 / (2 * c2), tmin, tmax);
                        chmin(dmin, abs(get_pi(t) - get_pj(t)));
                    }

                    debug(i, j, ri + rj, dmin, tmin, tmax);

                    if (dmin <= (ri + rj)) {
                        debug(i, j);
                        g[i].push_back(j);
                        g[j].push_back(i);
                    }
                }

                tj_fr = tj_to;
            }

            ti_fr = ti_to;
        }
    }

    vector<int8_t> vis(n + 2);
    vis[src] = true;
    deque<int> dq{ src };

    while (dq.size()) {
        int u = dq.front();
        dq.pop_front();
        for (int v : g[u]) if (not vis[v]) {
            vis[v] = true;
            dq.push_back(v);
        }
    }

    if (vis[dst]) {
        print("Yes");
    } else {
        print("No");
    }
}
accuracy: 1
time_ms: 20
memory_kb: 4260
final_rank: 7

code_snippet: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=500005,INF=1<<30;

#define double long double

//幾何ライブラリ
// define double ll をするときは Point の < と == も書き換えよう！

const double eps=1e-8;
const double pi=acos((double)-1.0L);
#define equals(a,b) (fabs((a)-(b))<eps)

double torad(double deg) {return (double)(deg)*pi/180.0;}
double todeg(double ang) {return ang*180.0/pi;}

class Point{
public:
    double x,y;
    
    Point(double x=0,double y=0):x(x),y(y){}
    
    Point operator + (Point p){return Point(x+p.x,y+p.y);}
    Point operator - (Point p){return Point(x-p.x,y-p.y);}
    Point operator * (double a){return Point(a*x,a*y);}
    Point operator / (double a){return Point(x/a,y/a);}
    
    double abs(){return sqrt(norm());}
    double norm(){return x*x+y*y;}
    
    bool operator < (const Point &p)const{
        return x+eps<p.x||(equals(x,p.x)&&y+eps<p.y);
    }
    
    bool operator == (const Point &p)const{
        return fabs(x-p.x)<eps/100000&&fabs(y-p.y)<eps/100000;
    }
};

typedef Point Vector;

double norm(Vector a){
    return a.x*a.x+a.y*a.y;
}

double abs(Vector a){
    return sqrt(norm(a));
}

double dot(Vector a,Vector b){
    return a.x*b.x+a.y*b.y;
}

double cross(Vector a,Vector b){
    return a.x*b.y-a.y*b.x;
}

struct Segment{
    Point p1,p2;
};

bool isOrthogonal(Vector a,Vector b){
    return equals(dot(a,b),0.0);
}

bool isOrthogonal(Point a1,Point a2,Point b1,Point b2){
    return isOrthogonal(a1-a2,b1-b2);
}

bool isOrthogonal(Segment s1,Segment s2){
    return equals(dot(s1.p2-s1.p1,s2.p2-s2.p1),0.0);
}

bool isParallel(Vector a,Vector b){
    return equals(cross(a,b),0.0);
}

bool isParallel(Point a1,Point a2,Point b1,Point b2){
    return isParallel(a1-a2,b1-b2);
}

bool isParallel(Segment s1,Segment s2){
    return equals(cross(s1.p2-s1.p1,s2.p2-s2.p1),0.0);
}

Point project(Segment s,Point p){
    Vector base=s.p2-s.p1;
    double r=dot(p-s.p1,base)/norm(base);
    return s.p1+base*r;
}

Point reflect(Segment s,Point p){
    return p+(project(s,p)-p)*2.0;
}

Point turn(Point p,Point c,double pi){
    double q=atan2(p.y-c.y,p.x-c.x);
    q+=pi;
    p=c+Point{cos(q)*abs(p-c),sin(q)*abs(p-c)};
    
    return p;
}
//pをcを中心としてpi回転させる(1周で2π)
//p=cのときnan

//p0,p1,p2の順に見たときどうなるか？

static const int counter_clockwise=1;
static const int clockwise=-1;
static const int online_back=2;
static const int online_front=-2;
static const int on_segment=0;

int ccw(Point p0,Point p1,Point p2){
    Vector a=p1-p0;
    Vector b=p2-p0;
    
    if(cross(a,b)>eps) return counter_clockwise;
    if(cross(a,b)<-eps) return clockwise;
    if(dot(a,b)<-eps) return online_back;
    if(a.norm()<b.norm()) return online_front;
    
    return on_segment;
}

bool intersect(Point p1,Point p2,Point p3,Point p4){
    return(ccw(p1,p2,p3)*ccw(p1,p2,p4)<=0&&ccw(p3,p4,p1)*ccw(p3,p4,p2)<=0);
}

bool intersect(Segment s1,Segment s2){
    return intersect(s1.p1,s1.p2,s2.p1,s2.p2);
}

bool overlap(Segment s1,Segment s2){
    int a=ccw(s1.p1,s1.p2,s2.p1),b=ccw(s1.p1,s1.p2,s2.p2);
    if(a&1||b&1) return 0;
    if(a==2){
        if(b==-2||(b==0&&!(s2.p2==s1.p1))) return 1;
        else return 0;
    }
    if(a==-2){
        if(b==2||(b==0&&!(s2.p2==s1.p2))) return 1;
        else return 0;
    }
    if(a==0){
        if(s1.p1==s2.p1){
            if(b!=2) return 1;
            else return 0;
        }
        else if(s1.p2==s2.p1){
            if(b!=-2) return 1;
            else return 0;
        }
        else return 1;
    }
    return 0;
}
//s1とs2の共通の線分(長さ0より大きい)があるかどうか

typedef Segment Line;

double getDistance(Point a,Point b){
    return abs(a-b);
}

double getDistanceLP(Line l,Point p){
    return abs(cross(l.p2-l.p1,p-l.p1)/abs(l.p2-l.p1));
}

double getDistanceSP(Segment s,Point p){
    if(dot(s.p2-s.p1,p-s.p1)<0.0) return abs(p-s.p1);
    if(dot(s.p1-s.p2,p-s.p2)<0.0) return abs(p-s.p2);
    return getDistanceLP(s,p);
}

double getDistance(Segment s1,Segment s2){
    if(intersect(s1,s2)) return 0.0;
    return min({getDistanceSP(s1,s2.p1),getDistanceSP(s1,s2.p2),getDistanceSP(s2,s1.p1),getDistanceSP(s2,s1.p2)});
}

Point getCrossPointS(Segment s1,Segment s2){
    //if(ccw(s1.p1,s1.p2,s2.p1)==0&&ccw(s1.p1,s1.p2,s2.p2)==0) return s1.p1;
    Vector base=s2.p2-s2.p1;
    double d1=abs(cross(base,s1.p1-s2.p1));
    double d2=abs(cross(base,s1.p2-s2.p1));
    double t=d1/(d1+d2);
    return s1.p1+(s1.p2-s1.p1)*t;
}//同じ時壊れます

Point getCrossPointL(Line l1,Line l2){
    //if(ccw(s1.p1,s1.p2,s2.p1)==0&&ccw(s1.p1,s1.p2,s2.p2)==0) return s1.p1;
    
    Vector v1=l1.p2-l1.p1,v2=l2.p2-l2.p1;
    
    return l1.p1+v1*cross(v2,l2.p1-l1.p1)/cross(v2,v1);
}

Segment ParallelSegment(Segment s,double d){
    Vector v={-(s.p2-s.p1).y,(s.p2-s.p1).x};
    v=v/abs(v);
    
    s.p1=s.p1+v*d;
    s.p2=s.p2+v*d;
    
    return s;
}

Point naisin(Point p1,Point p2,Point p3){
    if(p1==p2&&p2==p3&&p3==p1) return p1;
    
    return (p1*abs(p2-p3)+p2*abs(p1-p3)+p3*abs(p1-p2))/(abs(p2-p3)+abs(p1-p3)+abs(p1-p2));
}

Point naisin(Line l1,Line l2,Line l3){
    //平行でない前提
    
    Point p1=getCrossPointL(l1,l2),p2=getCrossPointL(l1,l3),p3=getCrossPointL(l2,l3);
    return naisin(p1,p2,p3);
}

//ネットの適当を書いたのであってるか全く知りません→あってそう

class Circle{
public:
    Point c;
    double r;
    Circle(Point c=Point(),double r=0.0):c(c),r(r){}
};

Point CircleCenter(Point a,Point b,Point c){
    Point u=a-b,v=a-c;
    double m1=(norm(a)-norm(b))/2.0,m2=(norm(a)-norm(c))/2.0;
    
    Point res;
    if(cross(u,v)==0.0){
        res.x=1e9;
        res.y=1e9;
        
        return res;
    }
    res.x=(m1*v.y-m2*u.y)/cross(u,v);
    res.y=(m1*v.x-m2*u.x)/cross(v,u);
    
    return res;
}
//3点を通る円の中心を返す

//交わる 0
// c1がc2のinside 1
// c1がc2のoutside 2
// 交わらない 3

int not_intersect(Circle c1,Circle c2){
    double d=getDistance(c1.c,c2.c);
    double r1=c1.r,r2=c2.r;
    if(r1<r2){
        if(d<(r2-r1)) return 1;
    }
    if(r1>r2){
        if(d<(r1-r2)) return 2;
    }
    if(d<=r1+r2) return 0;
    else return 3;
}

pair<Point,Point> segCrossPpoints(Circle c,Line l){
    //assert(intersect(c,l));
    Vector pr=project(l,c.c);
    Vector e=(l.p2-l.p1)/abs(l.p2-l.p1);
    double base=sqrt(c.r*c.r-norm(pr-c.c));
    return make_pair(pr+e*base,pr-e*base);
}

double arg(Vector p){return atan2(p.y,p.x);}
Vector polar(double a,double r){return Point(cos(r)*a,sin(r)*a);}

//inside(outside)

pair<Point,Point> getCrossPoints(Circle c1,Circle c2){
    //assert(intersect(c1,c2));
    double d=abs(c1.c-c2.c);
    double a=acos((c1.r*c1.r+d*d-c2.r*c2.r)/(2*c1.r*d));
    double t=arg(c2.c-c1.c);
    return make_pair(c1.c+polar(c1.r,t+a),c1.c+polar(c1.r,t-a));
}

vector<Line> Commontangent(Circle c1,Circle c2){
    vector<Line> res;
    Point p=c2.c-c1.c;
    
    if(abs(p)>=(c1.r+c2.r)){
        Point a,b;
        a.x=c1.r*(p.x*(c1.r+c2.r)+p.y*sqrt(norm(p)-(c1.r+c2.r)*(c1.r+c2.r)))/norm(p);
        a.y=c1.r*(p.y*(c1.r+c2.r)-p.x*sqrt(norm(p)-(c1.r+c2.r)*(c1.r+c2.r)))/norm(p);
        
        b.x=c1.r*(p.x*(c1.r+c2.r)-p.y*sqrt(norm(p)-(c1.r+c2.r)*(c1.r+c2.r)))/norm(p);
        b.y=c1.r*(p.y*(c1.r+c2.r)+p.x*sqrt(norm(p)-(c1.r+c2.r)*(c1.r+c2.r)))/norm(p);
        
        res.push_back(Line{a+c1.c,a+c1.c+Point{-a.y,a.x}});
        if(!(a==b)){
            res.push_back(Line{b+c1.c,b+c1.c+Point{-b.y,b.x}});
        }
    }
    
    if(abs(p)>=abs(c1.r-c2.r)){
        Point a,b;
        a.x=c1.r*(p.x*(c1.r-c2.r)+p.y*sqrt(norm(p)-(c1.r-c2.r)*(c1.r-c2.r)))/norm(p);
        a.y=c1.r*(p.y*(c1.r-c2.r)-p.x*sqrt(norm(p)-(c1.r-c2.r)*(c1.r-c2.r)))/norm(p);
        
        b.x=c1.r*(p.x*(c1.r-c2.r)-p.y*sqrt(norm(p)-(c1.r-c2.r)*(c1.r-c2.r)))/norm(p);
        b.y=c1.r*(p.y*(c1.r-c2.r)+p.x*sqrt(norm(p)-(c1.r-c2.r)*(c1.r-c2.r)))/norm(p);
        
        res.push_back(Line{a+c1.c,a+c1.c+Point{-a.y,a.x}});
        if(!(a==b)){
            res.push_back(Line{b+c1.c,b+c1.c+Point{-b.y,b.x}});
        }
    }
    
    return res;
}

typedef vector<Point> Polygon;

/*
 IN 2
 ON 1
 OUT 0
 */

int contains(Polygon g,Point p){
    int n=int(g.size());
    bool x=false;
    for(int i=0;i<n;i++){
        Point a=g[i]-p,b=g[(i+1)%n]-p;
        if(a.y>b.y) swap(a,b);
        if(a.y<eps&&0<b.y&&cross(a,b)<0) x=!x;
        if(abs(cross(a,b))<eps&&dot(a,b)<eps) return 1;
    }
    return (x?2:0);
}

Polygon andrewScan(Polygon s,bool ok){
    Polygon u,l;
    sort(all(s));
    
    if(int(s.size())<3) return s;
    int n=int(s.size());
    
    u.push_back(s[0]);
    u.push_back(s[1]);
    
    l.push_back(s[n-1]);
    l.push_back(s[n-2]);
    
    if(ok){
        for(int i=2;i<n;i++){
            for(int j=int(u.size());j>=2&&ccw(u[j-2],u[j-1],s[i])==counter_clockwise;j--){
                u.pop_back();
            }
            u.push_back(s[i]);
        }
        
        for(int i=int(s.size())-3;i>=0;i--){
            for(int j=int(l.size());j>=2&&ccw(l[j-2],l[j-1],s[i])==counter_clockwise;j--){
                l.pop_back();
            }
            l.push_back(s[i]);
        }
    }
    
    if(!ok){
        for(int i=2;i<n;i++){
            for(int j=int(u.size());j>=2&&ccw(u[j-2],u[j-1],s[i])!=clockwise;j--){
                u.pop_back();
            }
            u.push_back(s[i]);
        }
        
        for(int i=int(s.size())-3;i>=0;i--){
            for(int j=int(l.size());j>=2&&ccw(l[j-2],l[j-1],s[i])!=clockwise;j--){
                l.pop_back();
            }
            l.push_back(s[i]);
        }
    }
    
    reverse(all(l));
    
    for(int i=int(u.size())-2;i>=1;i--) l.push_back(u[i]);
    
    return l;
}//ok==1なら辺の上も含める

Polygon convex_cut(const Polygon& P, const Line& l) {
    Polygon Q;
    for(int i=0;i<si(P);i++){
        Point A=P[i],B=P[(i+1)%si(P)];
        if(ccw(l.p1,l.p2,A)!=-1)Q.push_back(A);
        if(ccw(l.p1,l.p2,A)*ccw(l.p1,l.p2,B)<0) Q.push_back(getCrossPointL(Line{A,B},l));
    }
    return Q;
}

double area(Point a,Point b,Point c){
    b=b-a;
    c=c-a;
    return abs(b.x*c.y-b.y*c.x)/2.0;
}

double area(Polygon &P){
    if(si(P)==0) return 0.0;
    double res=0;
    Point c={0.0,0.0};
    for(int i=0;i<si(P);i++){
        c=c+P[i];
    }
    c=c/si(P);
    
    for(int i=0;i<si(P);i++){
        res+=area(c,P[i],P[(i+1)%si(P)]);
    }
    
    return res;
}

ll gcd(ll a,ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}

pair<Point,Vector> perpendicular_bisector(Point a,Point b){
    Point c=(a+b)/2;
    Vector v=b-c;
    swap(v.x,v.y);
    v.x*=-1;
    
    Point p=c;
    if(v.x==0){
        v.y=1;
        p.y=0;
    }
    else if(v.y==0){
        v.x=1;
        p.x=0;
    }
    else{
        if(v.x<0){
            v.x*=-1;
            v.y*=-1;
        }
        ll g=gcd(abs(ll(v.x)),abs(ll(v.y)));
        v.x/=g;
        v.y/=g;
        if(p.x>=0){
            ll d=p.x/v.x;
            p=p-v*d;
        }else{
            ll d=abs(p.x)/v.x;
            p=p+v*d;
            
            if(p.x<0){
                p=p+v;
            }
        }
    }
    
    return mp(p,v);
}
//2倍するなりして整数にしておくこと

//Union Find

struct UF{
    int n;
    vector<int> par,size;
    
    void init(int n_){
        n=n_;
        par.assign(n,-1);
        size.assign(n,1);
        
        for(int i=0;i<n;i++){
            par[i]=i;
        }
    }
    
    int root(int a){
        if(par[a]==a) return a;
        else return par[a]=root(par[a]);
    }
    
    void unite(int a,int b){
        if(root(a)!=root(b)){
            size[root(a)]+=size[root(b)];
            par[root(b)]=root(a);
        }
    }
    
    bool check(int a,int b){
        return root(a)==root(b);
    }
};

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    Point s,g;cin>>s.x>>s.y>>g.x>>g.y;
    vector<double> r(N),len(N);
    vector<vector<Point>> P(N);
    vector<int> cans(N),cang(N);
    for(int i=0;i<N;i++){
        cin>>r[i];
        int K;cin>>K;
        for(int j=0;j<K;j++){
            Point a;cin>>a.x>>a.y;
            P[i].push_back(a);
        }
        P[i].push_back(P[i][0]);
        for(int j=0;j<K;j++){
            Point a=P[i][j],b=P[i][j+1];
            len[i]+=getDistance(a,b);
            if(getDistanceSP({a,b},s)<r[i]) cans[i]=true;
            if(getDistanceSP({a,b},g)<r[i]) cang[i]=true;
        }
    }
    
    UF uf;uf.init(N);
    
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            vector<double> wheni,whenj;
            double sum=0;
            for(int k=0;k+1<si(P[i]);k++){
                wheni.push_back(sum/len[i]);
                Point a=P[i][k],b=P[i][(k+1)];
                sum+=getDistance(a,b);
            }
            sum=0;
            for(int k=0;k+1<si(P[j]);k++){
                whenj.push_back(sum/len[j]);
                Point a=P[j][k],b=P[j][(k+1)];
                sum+=getDistance(a,b);
            }
            
            int a=0,b=0;
            bool f=false;
            double now=0;
            while(a+1<si(wheni)&&b+1<si(whenj)){
                double left=now,right=min(wheni[a+1],whenj[b+1]);
                for(int q=0;q<40;q++){
                    double m1=(left*2+right)/3,m2=(left+right*2)/3;
                    Point pa1=P[i][a]+(P[i][a+1]-P[i][a])*(m1-wheni[a])/(wheni[a+1]-wheni[a]);
                    Point pa2=P[i][a]+(P[i][a+1]-P[i][a])*(m2-wheni[a])/(wheni[a+1]-wheni[a]);
                    Point pb1=P[j][b]+(P[j][b+1]-P[j][b])*(m1-whenj[b])/(whenj[b+1]-whenj[b]);
                    Point pb2=P[j][b]+(P[j][b+1]-P[j][b])*(m2-whenj[b])/(whenj[b+1]-whenj[b]);
                    if(getDistance(pa1,pb1)<r[i]+r[j]) f=true;
                    if(getDistance(pa2,pb2)<r[i]+r[j]) f=true;
                    double d1=getDistance(pa1,pb1);
                    double d2=getDistance(pa2,pb2);
                    if(d1<d2) right=m2;
                    else left=m1;
                }
                if(wheni[a+1]<=whenj[b+1]){
                    now=wheni[a+1];
                    a++;
                }else{
                    now=whenj[b+1];
                    b++;
                }
            }
            
            if(f) uf.unite(i,j);
            
        }
    }
    
    bool ans=false;
    
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(cans[i]&&cang[j]&&uf.check(i,j)) ans=true;
        }
    }
    
    if(ans) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
accuracy: 1
time_ms: 110
memory_kb: 3616
final_rank: 6

code_snippet: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=500005,INF=1<<30;

#define double long double

//幾何ライブラリ
// define double ll をするときは Point の < と == も書き換えよう！

const double eps=1e-10;
const double pi=acos((double)-1.0L);
#define equals(a,b) (fabs((a)-(b))<eps)

double torad(double deg) {return (double)(deg)*pi/180.0;}
double todeg(double ang) {return ang*180.0/pi;}

class Point{
public:
    double x,y;
    
    Point(double x=0,double y=0):x(x),y(y){}
    
    Point operator + (Point p){return Point(x+p.x,y+p.y);}
    Point operator - (Point p){return Point(x-p.x,y-p.y);}
    Point operator * (double a){return Point(a*x,a*y);}
    Point operator / (double a){return Point(x/a,y/a);}
    
    double abs(){return sqrt(norm());}
    double norm(){return x*x+y*y;}
    
    bool operator < (const Point &p)const{
        return x+eps<p.x||(equals(x,p.x)&&y+eps<p.y);
    }
    
    bool operator == (const Point &p)const{
        return fabs(x-p.x)<eps/100000&&fabs(y-p.y)<eps/100000;
    }
};

typedef Point Vector;

double norm(Vector a){
    return a.x*a.x+a.y*a.y;
}

double abs(Vector a){
    return sqrt(norm(a));
}

double dot(Vector a,Vector b){
    return a.x*b.x+a.y*b.y;
}

double cross(Vector a,Vector b){
    return a.x*b.y-a.y*b.x;
}

struct Segment{
    Point p1,p2;
};

bool isOrthogonal(Vector a,Vector b){
    return equals(dot(a,b),0.0);
}

bool isOrthogonal(Point a1,Point a2,Point b1,Point b2){
    return isOrthogonal(a1-a2,b1-b2);
}

bool isOrthogonal(Segment s1,Segment s2){
    return equals(dot(s1.p2-s1.p1,s2.p2-s2.p1),0.0);
}

bool isParallel(Vector a,Vector b){
    return equals(cross(a,b),0.0);
}

bool isParallel(Point a1,Point a2,Point b1,Point b2){
    return isParallel(a1-a2,b1-b2);
}

bool isParallel(Segment s1,Segment s2){
    return equals(cross(s1.p2-s1.p1,s2.p2-s2.p1),0.0);
}

Point project(Segment s,Point p){
    Vector base=s.p2-s.p1;
    double r=dot(p-s.p1,base)/norm(base);
    return s.p1+base*r;
}

Point reflect(Segment s,Point p){
    return p+(project(s,p)-p)*2.0;
}

Point turn(Point p,Point c,double pi){
    double q=atan2(p.y-c.y,p.x-c.x);
    q+=pi;
    p=c+Point{cos(q)*abs(p-c),sin(q)*abs(p-c)};
    
    return p;
}
//pをcを中心としてpi回転させる(1周で2π)
//p=cのときnan

//p0,p1,p2の順に見たときどうなるか？

static const int counter_clockwise=1;
static const int clockwise=-1;
static const int online_back=2;
static const int online_front=-2;
static const int on_segment=0;

int ccw(Point p0,Point p1,Point p2){
    Vector a=p1-p0;
    Vector b=p2-p0;
    
    if(cross(a,b)>eps) return counter_clockwise;
    if(cross(a,b)<-eps) return clockwise;
    if(dot(a,b)<-eps) return online_back;
    if(a.norm()<b.norm()) return online_front;
    
    return on_segment;
}

bool intersect(Point p1,Point p2,Point p3,Point p4){
    return(ccw(p1,p2,p3)*ccw(p1,p2,p4)<=0&&ccw(p3,p4,p1)*ccw(p3,p4,p2)<=0);
}

bool intersect(Segment s1,Segment s2){
    return intersect(s1.p1,s1.p2,s2.p1,s2.p2);
}

bool overlap(Segment s1,Segment s2){
    int a=ccw(s1.p1,s1.p2,s2.p1),b=ccw(s1.p1,s1.p2,s2.p2);
    if(a&1||b&1) return 0;
    if(a==2){
        if(b==-2||(b==0&&!(s2.p2==s1.p1))) return 1;
        else return 0;
    }
    if(a==-2){
        if(b==2||(b==0&&!(s2.p2==s1.p2))) return 1;
        else return 0;
    }
    if(a==0){
        if(s1.p1==s2.p1){
            if(b!=2) return 1;
            else return 0;
        }
        else if(s1.p2==s2.p1){
            if(b!=-2) return 1;
            else return 0;
        }
        else return 1;
    }
    return 0;
}
//s1とs2の共通の線分(長さ0より大きい)があるかどうか

typedef Segment Line;

double getDistance(Point a,Point b){
    return abs(a-b);
}

double getDistanceLP(Line l,Point p){
    return abs(cross(l.p2-l.p1,p-l.p1)/abs(l.p2-l.p1));
}

double getDistanceSP(Segment s,Point p){
    if(dot(s.p2-s.p1,p-s.p1)<0.0) return abs(p-s.p1);
    if(dot(s.p1-s.p2,p-s.p2)<0.0) return abs(p-s.p2);
    return getDistanceLP(s,p);
}

double getDistance(Segment s1,Segment s2){
    if(intersect(s1,s2)) return 0.0;
    return min({getDistanceSP(s1,s2.p1),getDistanceSP(s1,s2.p2),getDistanceSP(s2,s1.p1),getDistanceSP(s2,s1.p2)});
}

Point getCrossPointS(Segment s1,Segment s2){
    //if(ccw(s1.p1,s1.p2,s2.p1)==0&&ccw(s1.p1,s1.p2,s2.p2)==0) return s1.p1;
    Vector base=s2.p2-s2.p1;
    double d1=abs(cross(base,s1.p1-s2.p1));
    double d2=abs(cross(base,s1.p2-s2.p1));
    double t=d1/(d1+d2);
    return s1.p1+(s1.p2-s1.p1)*t;
}//同じ時壊れます

Point getCrossPointL(Line l1,Line l2){
    //if(ccw(s1.p1,s1.p2,s2.p1)==0&&ccw(s1.p1,s1.p2,s2.p2)==0) return s1.p1;
    
    Vector v1=l1.p2-l1.p1,v2=l2.p2-l2.p1;
    
    return l1.p1+v1*cross(v2,l2.p1-l1.p1)/cross(v2,v1);
}

Segment ParallelSegment(Segment s,double d){
    Vector v={-(s.p2-s.p1).y,(s.p2-s.p1).x};
    v=v/abs(v);
    
    s.p1=s.p1+v*d;
    s.p2=s.p2+v*d;
    
    return s;
}

Point naisin(Point p1,Point p2,Point p3){
    if(p1==p2&&p2==p3&&p3==p1) return p1;
    
    return (p1*abs(p2-p3)+p2*abs(p1-p3)+p3*abs(p1-p2))/(abs(p2-p3)+abs(p1-p3)+abs(p1-p2));
}

Point naisin(Line l1,Line l2,Line l3){
    //平行でない前提
    
    Point p1=getCrossPointL(l1,l2),p2=getCrossPointL(l1,l3),p3=getCrossPointL(l2,l3);
    return naisin(p1,p2,p3);
}

//ネットの適当を書いたのであってるか全く知りません→あってそう

class Circle{
public:
    Point c;
    double r;
    Circle(Point c=Point(),double r=0.0):c(c),r(r){}
};

Point CircleCenter(Point a,Point b,Point c){
    Point u=a-b,v=a-c;
    double m1=(norm(a)-norm(b))/2.0,m2=(norm(a)-norm(c))/2.0;
    
    Point res;
    if(cross(u,v)==0.0){
        res.x=1e9;
        res.y=1e9;
        
        return res;
    }
    res.x=(m1*v.y-m2*u.y)/cross(u,v);
    res.y=(m1*v.x-m2*u.x)/cross(v,u);
    
    return res;
}
//3点を通る円の中心を返す

//交わる 0
// c1がc2のinside 1
// c1がc2のoutside 2
// 交わらない 3

int not_intersect(Circle c1,Circle c2){
    double d=getDistance(c1.c,c2.c);
    double r1=c1.r,r2=c2.r;
    if(r1<r2){
        if(d<(r2-r1)) return 1;
    }
    if(r1>r2){
        if(d<(r1-r2)) return 2;
    }
    if(d<=r1+r2) return 0;
    else return 3;
}

pair<Point,Point> segCrossPpoints(Circle c,Line l){
    //assert(intersect(c,l));
    Vector pr=project(l,c.c);
    Vector e=(l.p2-l.p1)/abs(l.p2-l.p1);
    double base=sqrt(c.r*c.r-norm(pr-c.c));
    return make_pair(pr+e*base,pr-e*base);
}

double arg(Vector p){return atan2(p.y,p.x);}
Vector polar(double a,double r){return Point(cos(r)*a,sin(r)*a);}

//inside(outside)

pair<Point,Point> getCrossPoints(Circle c1,Circle c2){
    //assert(intersect(c1,c2));
    double d=abs(c1.c-c2.c);
    double a=acos((c1.r*c1.r+d*d-c2.r*c2.r)/(2*c1.r*d));
    double t=arg(c2.c-c1.c);
    return make_pair(c1.c+polar(c1.r,t+a),c1.c+polar(c1.r,t-a));
}

vector<Line> Commontangent(Circle c1,Circle c2){
    vector<Line> res;
    Point p=c2.c-c1.c;
    
    if(abs(p)>=(c1.r+c2.r)){
        Point a,b;
        a.x=c1.r*(p.x*(c1.r+c2.r)+p.y*sqrt(norm(p)-(c1.r+c2.r)*(c1.r+c2.r)))/norm(p);
        a.y=c1.r*(p.y*(c1.r+c2.r)-p.x*sqrt(norm(p)-(c1.r+c2.r)*(c1.r+c2.r)))/norm(p);
        
        b.x=c1.r*(p.x*(c1.r+c2.r)-p.y*sqrt(norm(p)-(c1.r+c2.r)*(c1.r+c2.r)))/norm(p);
        b.y=c1.r*(p.y*(c1.r+c2.r)+p.x*sqrt(norm(p)-(c1.r+c2.r)*(c1.r+c2.r)))/norm(p);
        
        res.push_back(Line{a+c1.c,a+c1.c+Point{-a.y,a.x}});
        if(!(a==b)){
            res.push_back(Line{b+c1.c,b+c1.c+Point{-b.y,b.x}});
        }
    }
    
    if(abs(p)>=abs(c1.r-c2.r)){
        Point a,b;
        a.x=c1.r*(p.x*(c1.r-c2.r)+p.y*sqrt(norm(p)-(c1.r-c2.r)*(c1.r-c2.r)))/norm(p);
        a.y=c1.r*(p.y*(c1.r-c2.r)-p.x*sqrt(norm(p)-(c1.r-c2.r)*(c1.r-c2.r)))/norm(p);
        
        b.x=c1.r*(p.x*(c1.r-c2.r)-p.y*sqrt(norm(p)-(c1.r-c2.r)*(c1.r-c2.r)))/norm(p);
        b.y=c1.r*(p.y*(c1.r-c2.r)+p.x*sqrt(norm(p)-(c1.r-c2.r)*(c1.r-c2.r)))/norm(p);
        
        res.push_back(Line{a+c1.c,a+c1.c+Point{-a.y,a.x}});
        if(!(a==b)){
            res.push_back(Line{b+c1.c,b+c1.c+Point{-b.y,b.x}});
        }
    }
    
    return res;
}

typedef vector<Point> Polygon;

/*
 IN 2
 ON 1
 OUT 0
 */

int contains(Polygon g,Point p){
    int n=int(g.size());
    bool x=false;
    for(int i=0;i<n;i++){
        Point a=g[i]-p,b=g[(i+1)%n]-p;
        if(a.y>b.y) swap(a,b);
        if(a.y<eps&&0<b.y&&cross(a,b)<0) x=!x;
        if(abs(cross(a,b))<eps&&dot(a,b)<eps) return 1;
    }
    return (x?2:0);
}

Polygon andrewScan(Polygon s,bool ok){
    Polygon u,l;
    sort(all(s));
    
    if(int(s.size())<3) return s;
    int n=int(s.size());
    
    u.push_back(s[0]);
    u.push_back(s[1]);
    
    l.push_back(s[n-1]);
    l.push_back(s[n-2]);
    
    if(ok){
        for(int i=2;i<n;i++){
            for(int j=int(u.size());j>=2&&ccw(u[j-2],u[j-1],s[i])==counter_clockwise;j--){
                u.pop_back();
            }
            u.push_back(s[i]);
        }
        
        for(int i=int(s.size())-3;i>=0;i--){
            for(int j=int(l.size());j>=2&&ccw(l[j-2],l[j-1],s[i])==counter_clockwise;j--){
                l.pop_back();
            }
            l.push_back(s[i]);
        }
    }
    
    if(!ok){
        for(int i=2;i<n;i++){
            for(int j=int(u.size());j>=2&&ccw(u[j-2],u[j-1],s[i])!=clockwise;j--){
                u.pop_back();
            }
            u.push_back(s[i]);
        }
        
        for(int i=int(s.size())-3;i>=0;i--){
            for(int j=int(l.size());j>=2&&ccw(l[j-2],l[j-1],s[i])!=clockwise;j--){
                l.pop_back();
            }
            l.push_back(s[i]);
        }
    }
    
    reverse(all(l));
    
    for(int i=int(u.size())-2;i>=1;i--) l.push_back(u[i]);
    
    return l;
}//ok==1なら辺の上も含める

Polygon convex_cut(const Polygon& P, const Line& l) {
    Polygon Q;
    for(int i=0;i<si(P);i++){
        Point A=P[i],B=P[(i+1)%si(P)];
        if(ccw(l.p1,l.p2,A)!=-1)Q.push_back(A);
        if(ccw(l.p1,l.p2,A)*ccw(l.p1,l.p2,B)<0) Q.push_back(getCrossPointL(Line{A,B},l));
    }
    return Q;
}

double area(Point a,Point b,Point c){
    b=b-a;
    c=c-a;
    return abs(b.x*c.y-b.y*c.x)/2.0;
}

double area(Polygon &P){
    if(si(P)==0) return 0.0;
    double res=0;
    Point c={0.0,0.0};
    for(int i=0;i<si(P);i++){
        c=c+P[i];
    }
    c=c/si(P);
    
    for(int i=0;i<si(P);i++){
        res+=area(c,P[i],P[(i+1)%si(P)]);
    }
    
    return res;
}

ll gcd(ll a,ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}

pair<Point,Vector> perpendicular_bisector(Point a,Point b){
    Point c=(a+b)/2;
    Vector v=b-c;
    swap(v.x,v.y);
    v.x*=-1;
    
    Point p=c;
    if(v.x==0){
        v.y=1;
        p.y=0;
    }
    else if(v.y==0){
        v.x=1;
        p.x=0;
    }
    else{
        if(v.x<0){
            v.x*=-1;
            v.y*=-1;
        }
        ll g=gcd(abs(ll(v.x)),abs(ll(v.y)));
        v.x/=g;
        v.y/=g;
        if(p.x>=0){
            ll d=p.x/v.x;
            p=p-v*d;
        }else{
            ll d=abs(p.x)/v.x;
            p=p+v*d;
            
            if(p.x<0){
                p=p+v;
            }
        }
    }
    
    return mp(p,v);
}
//2倍するなりして整数にしておくこと

//Union Find

struct UF{
    int n;
    vector<int> par,size;
    
    void init(int n_){
        n=n_;
        par.assign(n,-1);
        size.assign(n,1);
        
        for(int i=0;i<n;i++){
            par[i]=i;
        }
    }
    
    int root(int a){
        if(par[a]==a) return a;
        else return par[a]=root(par[a]);
    }
    
    void unite(int a,int b){
        if(root(a)!=root(b)){
            size[root(a)]+=size[root(b)];
            par[root(b)]=root(a);
        }
    }
    
    bool check(int a,int b){
        return root(a)==root(b);
    }
};

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    Point s,g;cin>>s.x>>s.y>>g.x>>g.y;
    vector<double> r(N),len(N);
    vector<vector<Point>> P(N);
    vector<int> cans(N),cang(N);
    for(int i=0;i<N;i++){
        cin>>r[i];
        int K;cin>>K;
        for(int j=0;j<K;j++){
            Point a;cin>>a.x>>a.y;
            P[i].push_back(a);
        }
        P[i].push_back(P[i][0]);
        for(int j=0;j<K;j++){
            Point a=P[i][j],b=P[i][j+1];
            len[i]+=getDistance(a,b);
            if(getDistanceSP({a,b},s)<=r[i]) cans[i]=true;
            if(getDistanceSP({a,b},g)<=r[i]) cang[i]=true;
        }
    }
    
    UF uf;uf.init(N);
    
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            vector<double> wheni,whenj;
            double sum=0;
            for(int k=0;k+1<si(P[i]);k++){
                wheni.push_back(sum/len[i]);
                Point a=P[i][k],b=P[i][(k+1)];
                sum+=getDistance(a,b);
            }
            sum=0;
            for(int k=0;k+1<si(P[j]);k++){
                whenj.push_back(sum/len[j]);
                Point a=P[j][k],b=P[j][(k+1)];
                sum+=getDistance(a,b);
            }
            
            int a=0,b=0;
            bool f=false;
            double now=0;
            while(a<si(P[i])-1&&b<si(P[j])-1){
                double left=now,right=min(wheni[a+1],whenj[b+1]);
                for(int q=0;q<40;q++){
                    double m1=(left*2+right)/3,m2=(left+right*2)/3;
                    Point pa1=P[i][a]+(P[i][a+1]-P[i][a])*(m1-wheni[a])/(wheni[a+1]-wheni[a]);
                    Point pa2=P[i][a]+(P[i][a+1]-P[i][a])*(m2-wheni[a])/(wheni[a+1]-wheni[a]);
                    Point pb1=P[j][b]+(P[j][b+1]-P[j][b])*(m1-whenj[b])/(whenj[b+1]-whenj[b]);
                    Point pb2=P[j][b]+(P[j][b+1]-P[j][b])*(m2-whenj[b])/(whenj[b+1]-whenj[b]);
                    if(getDistance(pa1,pb1)<=r[i]+r[j]) f=true;
                    if(getDistance(pa2,pb2)<=r[i]+r[j]) f=true;
                    double d1=getDistance(pa1,pb1);
                    double d2=getDistance(pa2,pb2);
                    if(d1<d2) right=m2;
                    else left=m1;
                }
                if(wheni[a+1]<=whenj[b+1]){
                    a++;
                }else{
                    b++;
                }
            }
            
            if(f) uf.unite(i,j);
            
        }
    }
    
    
    
    bool ans=false;
    
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(cans[i]&&cang[j]&&uf.check(i,j)) ans=true;
        }
    }
    
    if(ans) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
accuracy: 0.7027027027027027
time_ms: 1050
memory_kb: 3616
final_rank: 20

code_snippet: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=500005,INF=1<<30;

//幾何ライブラリ
// define double ll をするときは Point の < と == も書き換えよう！

const double eps=1e-10;
const double pi=acos((double)-1.0L);
#define equals(a,b) (fabs((a)-(b))<eps)

double torad(double deg) {return (double)(deg)*pi/180.0;}
double todeg(double ang) {return ang*180.0/pi;}

class Point{
public:
    double x,y;
    
    Point(double x=0,double y=0):x(x),y(y){}
    
    Point operator + (Point p){return Point(x+p.x,y+p.y);}
    Point operator - (Point p){return Point(x-p.x,y-p.y);}
    Point operator * (double a){return Point(a*x,a*y);}
    Point operator / (double a){return Point(x/a,y/a);}
    
    double abs(){return sqrt(norm());}
    double norm(){return x*x+y*y;}
    
    bool operator < (const Point &p)const{
        return x+eps<p.x||(equals(x,p.x)&&y+eps<p.y);
    }
    
    bool operator == (const Point &p)const{
        return fabs(x-p.x)<eps/100000&&fabs(y-p.y)<eps/100000;
    }
};

typedef Point Vector;

double norm(Vector a){
    return a.x*a.x+a.y*a.y;
}

double abs(Vector a){
    return sqrt(norm(a));
}

double dot(Vector a,Vector b){
    return a.x*b.x+a.y*b.y;
}

double cross(Vector a,Vector b){
    return a.x*b.y-a.y*b.x;
}

struct Segment{
    Point p1,p2;
};

bool isOrthogonal(Vector a,Vector b){
    return equals(dot(a,b),0.0);
}

bool isOrthogonal(Point a1,Point a2,Point b1,Point b2){
    return isOrthogonal(a1-a2,b1-b2);
}

bool isOrthogonal(Segment s1,Segment s2){
    return equals(dot(s1.p2-s1.p1,s2.p2-s2.p1),0.0);
}

bool isParallel(Vector a,Vector b){
    return equals(cross(a,b),0.0);
}

bool isParallel(Point a1,Point a2,Point b1,Point b2){
    return isParallel(a1-a2,b1-b2);
}

bool isParallel(Segment s1,Segment s2){
    return equals(cross(s1.p2-s1.p1,s2.p2-s2.p1),0.0);
}

Point project(Segment s,Point p){
    Vector base=s.p2-s.p1;
    double r=dot(p-s.p1,base)/norm(base);
    return s.p1+base*r;
}

Point reflect(Segment s,Point p){
    return p+(project(s,p)-p)*2.0;
}

Point turn(Point p,Point c,double pi){
    double q=atan2(p.y-c.y,p.x-c.x);
    q+=pi;
    p=c+Point{cos(q)*abs(p-c),sin(q)*abs(p-c)};
    
    return p;
}
//pをcを中心としてpi回転させる(1周で2π)
//p=cのときnan

//p0,p1,p2の順に見たときどうなるか？

static const int counter_clockwise=1;
static const int clockwise=-1;
static const int online_back=2;
static const int online_front=-2;
static const int on_segment=0;

int ccw(Point p0,Point p1,Point p2){
    Vector a=p1-p0;
    Vector b=p2-p0;
    
    if(cross(a,b)>eps) return counter_clockwise;
    if(cross(a,b)<-eps) return clockwise;
    if(dot(a,b)<-eps) return online_back;
    if(a.norm()<b.norm()) return online_front;
    
    return on_segment;
}

bool intersect(Point p1,Point p2,Point p3,Point p4){
    return(ccw(p1,p2,p3)*ccw(p1,p2,p4)<=0&&ccw(p3,p4,p1)*ccw(p3,p4,p2)<=0);
}

bool intersect(Segment s1,Segment s2){
    return intersect(s1.p1,s1.p2,s2.p1,s2.p2);
}

bool overlap(Segment s1,Segment s2){
    int a=ccw(s1.p1,s1.p2,s2.p1),b=ccw(s1.p1,s1.p2,s2.p2);
    if(a&1||b&1) return 0;
    if(a==2){
        if(b==-2||(b==0&&!(s2.p2==s1.p1))) return 1;
        else return 0;
    }
    if(a==-2){
        if(b==2||(b==0&&!(s2.p2==s1.p2))) return 1;
        else return 0;
    }
    if(a==0){
        if(s1.p1==s2.p1){
            if(b!=2) return 1;
            else return 0;
        }
        else if(s1.p2==s2.p1){
            if(b!=-2) return 1;
            else return 0;
        }
        else return 1;
    }
    return 0;
}
//s1とs2の共通の線分(長さ0より大きい)があるかどうか

typedef Segment Line;

double getDistance(Point a,Point b){
    return abs(a-b);
}

double getDistanceLP(Line l,Point p){
    return abs(cross(l.p2-l.p1,p-l.p1)/abs(l.p2-l.p1));
}

double getDistanceSP(Segment s,Point p){
    if(dot(s.p2-s.p1,p-s.p1)<0.0) return abs(p-s.p1);
    if(dot(s.p1-s.p2,p-s.p2)<0.0) return abs(p-s.p2);
    return getDistanceLP(s,p);
}

double getDistance(Segment s1,Segment s2){
    if(intersect(s1,s2)) return 0.0;
    return min({getDistanceSP(s1,s2.p1),getDistanceSP(s1,s2.p2),getDistanceSP(s2,s1.p1),getDistanceSP(s2,s1.p2)});
}

Point getCrossPointS(Segment s1,Segment s2){
    //if(ccw(s1.p1,s1.p2,s2.p1)==0&&ccw(s1.p1,s1.p2,s2.p2)==0) return s1.p1;
    Vector base=s2.p2-s2.p1;
    double d1=abs(cross(base,s1.p1-s2.p1));
    double d2=abs(cross(base,s1.p2-s2.p1));
    double t=d1/(d1+d2);
    return s1.p1+(s1.p2-s1.p1)*t;
}//同じ時壊れます

Point getCrossPointL(Line l1,Line l2){
    //if(ccw(s1.p1,s1.p2,s2.p1)==0&&ccw(s1.p1,s1.p2,s2.p2)==0) return s1.p1;
    
    Vector v1=l1.p2-l1.p1,v2=l2.p2-l2.p1;
    
    return l1.p1+v1*cross(v2,l2.p1-l1.p1)/cross(v2,v1);
}

Segment ParallelSegment(Segment s,double d){
    Vector v={-(s.p2-s.p1).y,(s.p2-s.p1).x};
    v=v/abs(v);
    
    s.p1=s.p1+v*d;
    s.p2=s.p2+v*d;
    
    return s;
}

Point naisin(Point p1,Point p2,Point p3){
    if(p1==p2&&p2==p3&&p3==p1) return p1;
    
    return (p1*abs(p2-p3)+p2*abs(p1-p3)+p3*abs(p1-p2))/(abs(p2-p3)+abs(p1-p3)+abs(p1-p2));
}

Point naisin(Line l1,Line l2,Line l3){
    //平行でない前提
    
    Point p1=getCrossPointL(l1,l2),p2=getCrossPointL(l1,l3),p3=getCrossPointL(l2,l3);
    return naisin(p1,p2,p3);
}

//ネットの適当を書いたのであってるか全く知りません→あってそう

class Circle{
public:
    Point c;
    double r;
    Circle(Point c=Point(),double r=0.0):c(c),r(r){}
};

Point CircleCenter(Point a,Point b,Point c){
    Point u=a-b,v=a-c;
    double m1=(norm(a)-norm(b))/2.0,m2=(norm(a)-norm(c))/2.0;
    
    Point res;
    if(cross(u,v)==0.0){
        res.x=1e9;
        res.y=1e9;
        
        return res;
    }
    res.x=(m1*v.y-m2*u.y)/cross(u,v);
    res.y=(m1*v.x-m2*u.x)/cross(v,u);
    
    return res;
}
//3点を通る円の中心を返す

//交わる 0
// c1がc2のinside 1
// c1がc2のoutside 2
// 交わらない 3

int not_intersect(Circle c1,Circle c2){
    double d=getDistance(c1.c,c2.c);
    double r1=c1.r,r2=c2.r;
    if(r1<r2){
        if(d<(r2-r1)) return 1;
    }
    if(r1>r2){
        if(d<(r1-r2)) return 2;
    }
    if(d<=r1+r2) return 0;
    else return 3;
}

pair<Point,Point> segCrossPpoints(Circle c,Line l){
    //assert(intersect(c,l));
    Vector pr=project(l,c.c);
    Vector e=(l.p2-l.p1)/abs(l.p2-l.p1);
    double base=sqrt(c.r*c.r-norm(pr-c.c));
    return make_pair(pr+e*base,pr-e*base);
}

double arg(Vector p){return atan2(p.y,p.x);}
Vector polar(double a,double r){return Point(cos(r)*a,sin(r)*a);}

//inside(outside)

pair<Point,Point> getCrossPoints(Circle c1,Circle c2){
    //assert(intersect(c1,c2));
    double d=abs(c1.c-c2.c);
    double a=acos((c1.r*c1.r+d*d-c2.r*c2.r)/(2*c1.r*d));
    double t=arg(c2.c-c1.c);
    return make_pair(c1.c+polar(c1.r,t+a),c1.c+polar(c1.r,t-a));
}

vector<Line> Commontangent(Circle c1,Circle c2){
    vector<Line> res;
    Point p=c2.c-c1.c;
    
    if(abs(p)>=(c1.r+c2.r)){
        Point a,b;
        a.x=c1.r*(p.x*(c1.r+c2.r)+p.y*sqrt(norm(p)-(c1.r+c2.r)*(c1.r+c2.r)))/norm(p);
        a.y=c1.r*(p.y*(c1.r+c2.r)-p.x*sqrt(norm(p)-(c1.r+c2.r)*(c1.r+c2.r)))/norm(p);
        
        b.x=c1.r*(p.x*(c1.r+c2.r)-p.y*sqrt(norm(p)-(c1.r+c2.r)*(c1.r+c2.r)))/norm(p);
        b.y=c1.r*(p.y*(c1.r+c2.r)+p.x*sqrt(norm(p)-(c1.r+c2.r)*(c1.r+c2.r)))/norm(p);
        
        res.push_back(Line{a+c1.c,a+c1.c+Point{-a.y,a.x}});
        if(!(a==b)){
            res.push_back(Line{b+c1.c,b+c1.c+Point{-b.y,b.x}});
        }
    }
    
    if(abs(p)>=abs(c1.r-c2.r)){
        Point a,b;
        a.x=c1.r*(p.x*(c1.r-c2.r)+p.y*sqrt(norm(p)-(c1.r-c2.r)*(c1.r-c2.r)))/norm(p);
        a.y=c1.r*(p.y*(c1.r-c2.r)-p.x*sqrt(norm(p)-(c1.r-c2.r)*(c1.r-c2.r)))/norm(p);
        
        b.x=c1.r*(p.x*(c1.r-c2.r)-p.y*sqrt(norm(p)-(c1.r-c2.r)*(c1.r-c2.r)))/norm(p);
        b.y=c1.r*(p.y*(c1.r-c2.r)+p.x*sqrt(norm(p)-(c1.r-c2.r)*(c1.r-c2.r)))/norm(p);
        
        res.push_back(Line{a+c1.c,a+c1.c+Point{-a.y,a.x}});
        if(!(a==b)){
            res.push_back(Line{b+c1.c,b+c1.c+Point{-b.y,b.x}});
        }
    }
    
    return res;
}

typedef vector<Point> Polygon;

/*
 IN 2
 ON 1
 OUT 0
 */

int contains(Polygon g,Point p){
    int n=int(g.size());
    bool x=false;
    for(int i=0;i<n;i++){
        Point a=g[i]-p,b=g[(i+1)%n]-p;
        if(a.y>b.y) swap(a,b);
        if(a.y<eps&&0<b.y&&cross(a,b)<0) x=!x;
        if(abs(cross(a,b))<eps&&dot(a,b)<eps) return 1;
    }
    return (x?2:0);
}

Polygon andrewScan(Polygon s,bool ok){
    Polygon u,l;
    sort(all(s));
    
    if(int(s.size())<3) return s;
    int n=int(s.size());
    
    u.push_back(s[0]);
    u.push_back(s[1]);
    
    l.push_back(s[n-1]);
    l.push_back(s[n-2]);
    
    if(ok){
        for(int i=2;i<n;i++){
            for(int j=int(u.size());j>=2&&ccw(u[j-2],u[j-1],s[i])==counter_clockwise;j--){
                u.pop_back();
            }
            u.push_back(s[i]);
        }
        
        for(int i=int(s.size())-3;i>=0;i--){
            for(int j=int(l.size());j>=2&&ccw(l[j-2],l[j-1],s[i])==counter_clockwise;j--){
                l.pop_back();
            }
            l.push_back(s[i]);
        }
    }
    
    if(!ok){
        for(int i=2;i<n;i++){
            for(int j=int(u.size());j>=2&&ccw(u[j-2],u[j-1],s[i])!=clockwise;j--){
                u.pop_back();
            }
            u.push_back(s[i]);
        }
        
        for(int i=int(s.size())-3;i>=0;i--){
            for(int j=int(l.size());j>=2&&ccw(l[j-2],l[j-1],s[i])!=clockwise;j--){
                l.pop_back();
            }
            l.push_back(s[i]);
        }
    }
    
    reverse(all(l));
    
    for(int i=int(u.size())-2;i>=1;i--) l.push_back(u[i]);
    
    return l;
}//ok==1なら辺の上も含める

Polygon convex_cut(const Polygon& P, const Line& l) {
    Polygon Q;
    for(int i=0;i<si(P);i++){
        Point A=P[i],B=P[(i+1)%si(P)];
        if(ccw(l.p1,l.p2,A)!=-1)Q.push_back(A);
        if(ccw(l.p1,l.p2,A)*ccw(l.p1,l.p2,B)<0) Q.push_back(getCrossPointL(Line{A,B},l));
    }
    return Q;
}

double area(Point a,Point b,Point c){
    b=b-a;
    c=c-a;
    return abs(b.x*c.y-b.y*c.x)/2.0;
}

double area(Polygon &P){
    if(si(P)==0) return 0.0;
    double res=0;
    Point c={0.0,0.0};
    for(int i=0;i<si(P);i++){
        c=c+P[i];
    }
    c=c/si(P);
    
    for(int i=0;i<si(P);i++){
        res+=area(c,P[i],P[(i+1)%si(P)]);
    }
    
    return res;
}

ll gcd(ll a,ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}

pair<Point,Vector> perpendicular_bisector(Point a,Point b){
    Point c=(a+b)/2;
    Vector v=b-c;
    swap(v.x,v.y);
    v.x*=-1;
    
    Point p=c;
    if(v.x==0){
        v.y=1;
        p.y=0;
    }
    else if(v.y==0){
        v.x=1;
        p.x=0;
    }
    else{
        if(v.x<0){
            v.x*=-1;
            v.y*=-1;
        }
        ll g=gcd(abs(ll(v.x)),abs(ll(v.y)));
        v.x/=g;
        v.y/=g;
        if(p.x>=0){
            ll d=p.x/v.x;
            p=p-v*d;
        }else{
            ll d=abs(p.x)/v.x;
            p=p+v*d;
            
            if(p.x<0){
                p=p+v;
            }
        }
    }
    
    return mp(p,v);
}
//2倍するなりして整数にしておくこと

//Union Find

struct UF{
    int n;
    vector<int> par,size;
    
    void init(int n_){
        n=n_;
        par.assign(n,-1);
        size.assign(n,1);
        
        for(int i=0;i<n;i++){
            par[i]=i;
        }
    }
    
    int root(int a){
        if(par[a]==a) return a;
        else return par[a]=root(par[a]);
    }
    
    void unite(int a,int b){
        if(root(a)!=root(b)){
            size[root(a)]+=size[root(b)];
            par[root(b)]=root(a);
        }
    }
    
    bool check(int a,int b){
        return root(a)==root(b);
    }
};

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    Point s,g;cin>>s.x>>s.y>>g.x>>g.y;
    vector<double> r(N),len(N);
    vector<vector<Point>> P(N);
    vector<int> cans(N),cang(N);
    for(int i=0;i<N;i++){
        cin>>r[i];
        int K;cin>>K;
        for(int j=0;j<K;j++){
            Point a;cin>>a.x>>a.y;
            P[i].push_back(a);
        }
        P[i].push_back(P[i][0]);
        for(int j=0;j<K;j++){
            Point a=P[i][j],b=P[i][j+1];
            len[i]+=getDistance(a,b);
            if(getDistanceSP({a,b},s)<=r[i]) cans[i]=true;
            if(getDistanceSP({a,b},g)<=r[i]) cang[i]=true;
        }
    }
    
    UF uf;uf.init(N);
    
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            vector<double> wheni,whenj;
            double sum=0;
            for(int k=0;k+1<si(P[i]);k++){
                wheni.push_back(sum/len[i]);
                Point a=P[i][k],b=P[i][(k+1)];
                sum+=getDistance(a,b);
            }
            sum=0;
            for(int k=0;k+1<si(P[j]);k++){
                whenj.push_back(sum/len[j]);
                Point a=P[j][k],b=P[j][(k+1)];
                sum+=getDistance(a,b);
            }
            
            int a=0,b=0;
            bool f=false;
            double now=0;
            while(a<si(P[i])-1&&b<si(P[j])-1){
                double left=now,right=min(wheni[a+1],whenj[b+1]);
                for(int q=0;q<40;q++){
                    double m1=(left*2+right)/3,m2=(left+right*2)/3;
                    Point pa1=P[i][a]+(P[i][a+1]-P[i][a])*(m1-wheni[a])/(wheni[a+1]-wheni[a]);
                    Point pa2=P[i][a]+(P[i][a+1]-P[i][a])*(m2-wheni[a])/(wheni[a+1]-wheni[a]);
                    Point pb1=P[j][b]+(P[j][b+1]-P[j][b])*(m1-whenj[b])/(whenj[b+1]-whenj[b]);
                    Point pb2=P[j][b]+(P[j][b+1]-P[j][b])*(m2-whenj[b])/(whenj[b+1]-whenj[b]);
                    if(getDistance(pa1,pb1)<=r[i]+r[j]) f=true;
                    if(getDistance(pa2,pb2)<=r[i]+r[j]) f=true;
                    double d1=getDistance(pa1,pb1);
                    double d2=getDistance(pa2,pb2);
                    if(d1<d2) right=m2;
                    else left=m1;
                }
                if(wheni[a+1]<=whenj[b+1]){
                    a++;
                }else{
                    b++;
                }
            }
            
            if(f) uf.unite(i,j);
            
        }
    }
    
    
    
    bool ans=false;
    
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(cans[i]&&cang[j]&&uf.check(i,j)) ans=true;
        }
    }
    
    if(ans) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
accuracy: 0.7027027027027027
time_ms: 90
memory_kb: 3616
final_rank: 15

code_snippet: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=500005,INF=1<<30;

//幾何ライブラリ
// define double ll をするときは Point の < と == も書き換えよう！

const double eps=1e-8;
const double pi=acos((double)-1.0L);
#define equals(a,b) (fabs((a)-(b))<eps)

double torad(double deg) {return (double)(deg)*pi/180.0;}
double todeg(double ang) {return ang*180.0/pi;}

class Point{
public:
    double x,y;
    
    Point(double x=0,double y=0):x(x),y(y){}
    
    Point operator + (Point p){return Point(x+p.x,y+p.y);}
    Point operator - (Point p){return Point(x-p.x,y-p.y);}
    Point operator * (double a){return Point(a*x,a*y);}
    Point operator / (double a){return Point(x/a,y/a);}
    
    double abs(){return sqrt(norm());}
    double norm(){return x*x+y*y;}
    
    bool operator < (const Point &p)const{
        return x+eps<p.x||(equals(x,p.x)&&y+eps<p.y);
    }
    
    bool operator == (const Point &p)const{
        return fabs(x-p.x)<eps/100000&&fabs(y-p.y)<eps/100000;
    }
};

typedef Point Vector;

double norm(Vector a){
    return a.x*a.x+a.y*a.y;
}

double abs(Vector a){
    return sqrt(norm(a));
}

double dot(Vector a,Vector b){
    return a.x*b.x+a.y*b.y;
}

double cross(Vector a,Vector b){
    return a.x*b.y-a.y*b.x;
}

struct Segment{
    Point p1,p2;
};

bool isOrthogonal(Vector a,Vector b){
    return equals(dot(a,b),0.0);
}

bool isOrthogonal(Point a1,Point a2,Point b1,Point b2){
    return isOrthogonal(a1-a2,b1-b2);
}

bool isOrthogonal(Segment s1,Segment s2){
    return equals(dot(s1.p2-s1.p1,s2.p2-s2.p1),0.0);
}

bool isParallel(Vector a,Vector b){
    return equals(cross(a,b),0.0);
}

bool isParallel(Point a1,Point a2,Point b1,Point b2){
    return isParallel(a1-a2,b1-b2);
}

bool isParallel(Segment s1,Segment s2){
    return equals(cross(s1.p2-s1.p1,s2.p2-s2.p1),0.0);
}

Point project(Segment s,Point p){
    Vector base=s.p2-s.p1;
    double r=dot(p-s.p1,base)/norm(base);
    return s.p1+base*r;
}

Point reflect(Segment s,Point p){
    return p+(project(s,p)-p)*2.0;
}

Point turn(Point p,Point c,double pi){
    double q=atan2(p.y-c.y,p.x-c.x);
    q+=pi;
    p=c+Point{cos(q)*abs(p-c),sin(q)*abs(p-c)};
    
    return p;
}
//pをcを中心としてpi回転させる(1周で2π)
//p=cのときnan

//p0,p1,p2の順に見たときどうなるか？

static const int counter_clockwise=1;
static const int clockwise=-1;
static const int online_back=2;
static const int online_front=-2;
static const int on_segment=0;

int ccw(Point p0,Point p1,Point p2){
    Vector a=p1-p0;
    Vector b=p2-p0;
    
    if(cross(a,b)>eps) return counter_clockwise;
    if(cross(a,b)<-eps) return clockwise;
    if(dot(a,b)<-eps) return online_back;
    if(a.norm()<b.norm()) return online_front;
    
    return on_segment;
}

bool intersect(Point p1,Point p2,Point p3,Point p4){
    return(ccw(p1,p2,p3)*ccw(p1,p2,p4)<=0&&ccw(p3,p4,p1)*ccw(p3,p4,p2)<=0);
}

bool intersect(Segment s1,Segment s2){
    return intersect(s1.p1,s1.p2,s2.p1,s2.p2);
}

bool overlap(Segment s1,Segment s2){
    int a=ccw(s1.p1,s1.p2,s2.p1),b=ccw(s1.p1,s1.p2,s2.p2);
    if(a&1||b&1) return 0;
    if(a==2){
        if(b==-2||(b==0&&!(s2.p2==s1.p1))) return 1;
        else return 0;
    }
    if(a==-2){
        if(b==2||(b==0&&!(s2.p2==s1.p2))) return 1;
        else return 0;
    }
    if(a==0){
        if(s1.p1==s2.p1){
            if(b!=2) return 1;
            else return 0;
        }
        else if(s1.p2==s2.p1){
            if(b!=-2) return 1;
            else return 0;
        }
        else return 1;
    }
    return 0;
}
//s1とs2の共通の線分(長さ0より大きい)があるかどうか

typedef Segment Line;

double getDistance(Point a,Point b){
    return abs(a-b);
}

double getDistanceLP(Line l,Point p){
    return abs(cross(l.p2-l.p1,p-l.p1)/abs(l.p2-l.p1));
}

double getDistanceSP(Segment s,Point p){
    if(dot(s.p2-s.p1,p-s.p1)<0.0) return abs(p-s.p1);
    if(dot(s.p1-s.p2,p-s.p2)<0.0) return abs(p-s.p2);
    return getDistanceLP(s,p);
}

double getDistance(Segment s1,Segment s2){
    if(intersect(s1,s2)) return 0.0;
    return min({getDistanceSP(s1,s2.p1),getDistanceSP(s1,s2.p2),getDistanceSP(s2,s1.p1),getDistanceSP(s2,s1.p2)});
}

Point getCrossPointS(Segment s1,Segment s2){
    //if(ccw(s1.p1,s1.p2,s2.p1)==0&&ccw(s1.p1,s1.p2,s2.p2)==0) return s1.p1;
    Vector base=s2.p2-s2.p1;
    double d1=abs(cross(base,s1.p1-s2.p1));
    double d2=abs(cross(base,s1.p2-s2.p1));
    double t=d1/(d1+d2);
    return s1.p1+(s1.p2-s1.p1)*t;
}//同じ時壊れます

Point getCrossPointL(Line l1,Line l2){
    //if(ccw(s1.p1,s1.p2,s2.p1)==0&&ccw(s1.p1,s1.p2,s2.p2)==0) return s1.p1;
    
    Vector v1=l1.p2-l1.p1,v2=l2.p2-l2.p1;
    
    return l1.p1+v1*cross(v2,l2.p1-l1.p1)/cross(v2,v1);
}

Segment ParallelSegment(Segment s,double d){
    Vector v={-(s.p2-s.p1).y,(s.p2-s.p1).x};
    v=v/abs(v);
    
    s.p1=s.p1+v*d;
    s.p2=s.p2+v*d;
    
    return s;
}

Point naisin(Point p1,Point p2,Point p3){
    if(p1==p2&&p2==p3&&p3==p1) return p1;
    
    return (p1*abs(p2-p3)+p2*abs(p1-p3)+p3*abs(p1-p2))/(abs(p2-p3)+abs(p1-p3)+abs(p1-p2));
}

Point naisin(Line l1,Line l2,Line l3){
    //平行でない前提
    
    Point p1=getCrossPointL(l1,l2),p2=getCrossPointL(l1,l3),p3=getCrossPointL(l2,l3);
    return naisin(p1,p2,p3);
}

//ネットの適当を書いたのであってるか全く知りません→あってそう

class Circle{
public:
    Point c;
    double r;
    Circle(Point c=Point(),double r=0.0):c(c),r(r){}
};

Point CircleCenter(Point a,Point b,Point c){
    Point u=a-b,v=a-c;
    double m1=(norm(a)-norm(b))/2.0,m2=(norm(a)-norm(c))/2.0;
    
    Point res;
    if(cross(u,v)==0.0){
        res.x=1e9;
        res.y=1e9;
        
        return res;
    }
    res.x=(m1*v.y-m2*u.y)/cross(u,v);
    res.y=(m1*v.x-m2*u.x)/cross(v,u);
    
    return res;
}
//3点を通る円の中心を返す

//交わる 0
// c1がc2のinside 1
// c1がc2のoutside 2
// 交わらない 3

int not_intersect(Circle c1,Circle c2){
    double d=getDistance(c1.c,c2.c);
    double r1=c1.r,r2=c2.r;
    if(r1<r2){
        if(d<(r2-r1)) return 1;
    }
    if(r1>r2){
        if(d<(r1-r2)) return 2;
    }
    if(d<=r1+r2) return 0;
    else return 3;
}

pair<Point,Point> segCrossPpoints(Circle c,Line l){
    //assert(intersect(c,l));
    Vector pr=project(l,c.c);
    Vector e=(l.p2-l.p1)/abs(l.p2-l.p1);
    double base=sqrt(c.r*c.r-norm(pr-c.c));
    return make_pair(pr+e*base,pr-e*base);
}

double arg(Vector p){return atan2(p.y,p.x);}
Vector polar(double a,double r){return Point(cos(r)*a,sin(r)*a);}

//inside(outside)

pair<Point,Point> getCrossPoints(Circle c1,Circle c2){
    //assert(intersect(c1,c2));
    double d=abs(c1.c-c2.c);
    double a=acos((c1.r*c1.r+d*d-c2.r*c2.r)/(2*c1.r*d));
    double t=arg(c2.c-c1.c);
    return make_pair(c1.c+polar(c1.r,t+a),c1.c+polar(c1.r,t-a));
}

vector<Line> Commontangent(Circle c1,Circle c2){
    vector<Line> res;
    Point p=c2.c-c1.c;
    
    if(abs(p)>=(c1.r+c2.r)){
        Point a,b;
        a.x=c1.r*(p.x*(c1.r+c2.r)+p.y*sqrt(norm(p)-(c1.r+c2.r)*(c1.r+c2.r)))/norm(p);
        a.y=c1.r*(p.y*(c1.r+c2.r)-p.x*sqrt(norm(p)-(c1.r+c2.r)*(c1.r+c2.r)))/norm(p);
        
        b.x=c1.r*(p.x*(c1.r+c2.r)-p.y*sqrt(norm(p)-(c1.r+c2.r)*(c1.r+c2.r)))/norm(p);
        b.y=c1.r*(p.y*(c1.r+c2.r)+p.x*sqrt(norm(p)-(c1.r+c2.r)*(c1.r+c2.r)))/norm(p);
        
        res.push_back(Line{a+c1.c,a+c1.c+Point{-a.y,a.x}});
        if(!(a==b)){
            res.push_back(Line{b+c1.c,b+c1.c+Point{-b.y,b.x}});
        }
    }
    
    if(abs(p)>=abs(c1.r-c2.r)){
        Point a,b;
        a.x=c1.r*(p.x*(c1.r-c2.r)+p.y*sqrt(norm(p)-(c1.r-c2.r)*(c1.r-c2.r)))/norm(p);
        a.y=c1.r*(p.y*(c1.r-c2.r)-p.x*sqrt(norm(p)-(c1.r-c2.r)*(c1.r-c2.r)))/norm(p);
        
        b.x=c1.r*(p.x*(c1.r-c2.r)-p.y*sqrt(norm(p)-(c1.r-c2.r)*(c1.r-c2.r)))/norm(p);
        b.y=c1.r*(p.y*(c1.r-c2.r)+p.x*sqrt(norm(p)-(c1.r-c2.r)*(c1.r-c2.r)))/norm(p);
        
        res.push_back(Line{a+c1.c,a+c1.c+Point{-a.y,a.x}});
        if(!(a==b)){
            res.push_back(Line{b+c1.c,b+c1.c+Point{-b.y,b.x}});
        }
    }
    
    return res;
}

typedef vector<Point> Polygon;

/*
 IN 2
 ON 1
 OUT 0
 */

int contains(Polygon g,Point p){
    int n=int(g.size());
    bool x=false;
    for(int i=0;i<n;i++){
        Point a=g[i]-p,b=g[(i+1)%n]-p;
        if(a.y>b.y) swap(a,b);
        if(a.y<eps&&0<b.y&&cross(a,b)<0) x=!x;
        if(abs(cross(a,b))<eps&&dot(a,b)<eps) return 1;
    }
    return (x?2:0);
}

Polygon andrewScan(Polygon s,bool ok){
    Polygon u,l;
    sort(all(s));
    
    if(int(s.size())<3) return s;
    int n=int(s.size());
    
    u.push_back(s[0]);
    u.push_back(s[1]);
    
    l.push_back(s[n-1]);
    l.push_back(s[n-2]);
    
    if(ok){
        for(int i=2;i<n;i++){
            for(int j=int(u.size());j>=2&&ccw(u[j-2],u[j-1],s[i])==counter_clockwise;j--){
                u.pop_back();
            }
            u.push_back(s[i]);
        }
        
        for(int i=int(s.size())-3;i>=0;i--){
            for(int j=int(l.size());j>=2&&ccw(l[j-2],l[j-1],s[i])==counter_clockwise;j--){
                l.pop_back();
            }
            l.push_back(s[i]);
        }
    }
    
    if(!ok){
        for(int i=2;i<n;i++){
            for(int j=int(u.size());j>=2&&ccw(u[j-2],u[j-1],s[i])!=clockwise;j--){
                u.pop_back();
            }
            u.push_back(s[i]);
        }
        
        for(int i=int(s.size())-3;i>=0;i--){
            for(int j=int(l.size());j>=2&&ccw(l[j-2],l[j-1],s[i])!=clockwise;j--){
                l.pop_back();
            }
            l.push_back(s[i]);
        }
    }
    
    reverse(all(l));
    
    for(int i=int(u.size())-2;i>=1;i--) l.push_back(u[i]);
    
    return l;
}//ok==1なら辺の上も含める

Polygon convex_cut(const Polygon& P, const Line& l) {
    Polygon Q;
    for(int i=0;i<si(P);i++){
        Point A=P[i],B=P[(i+1)%si(P)];
        if(ccw(l.p1,l.p2,A)!=-1)Q.push_back(A);
        if(ccw(l.p1,l.p2,A)*ccw(l.p1,l.p2,B)<0) Q.push_back(getCrossPointL(Line{A,B},l));
    }
    return Q;
}

double area(Point a,Point b,Point c){
    b=b-a;
    c=c-a;
    return abs(b.x*c.y-b.y*c.x)/2.0;
}

double area(Polygon &P){
    if(si(P)==0) return 0.0;
    double res=0;
    Point c={0.0,0.0};
    for(int i=0;i<si(P);i++){
        c=c+P[i];
    }
    c=c/si(P);
    
    for(int i=0;i<si(P);i++){
        res+=area(c,P[i],P[(i+1)%si(P)]);
    }
    
    return res;
}

ll gcd(ll a,ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}

pair<Point,Vector> perpendicular_bisector(Point a,Point b){
    Point c=(a+b)/2;
    Vector v=b-c;
    swap(v.x,v.y);
    v.x*=-1;
    
    Point p=c;
    if(v.x==0){
        v.y=1;
        p.y=0;
    }
    else if(v.y==0){
        v.x=1;
        p.x=0;
    }
    else{
        if(v.x<0){
            v.x*=-1;
            v.y*=-1;
        }
        ll g=gcd(abs(ll(v.x)),abs(ll(v.y)));
        v.x/=g;
        v.y/=g;
        if(p.x>=0){
            ll d=p.x/v.x;
            p=p-v*d;
        }else{
            ll d=abs(p.x)/v.x;
            p=p+v*d;
            
            if(p.x<0){
                p=p+v;
            }
        }
    }
    
    return mp(p,v);
}
//2倍するなりして整数にしておくこと

//Union Find

struct UF{
    int n;
    vector<int> par,size;
    
    void init(int n_){
        n=n_;
        par.assign(n,-1);
        size.assign(n,1);
        
        for(int i=0;i<n;i++){
            par[i]=i;
        }
    }
    
    int root(int a){
        if(par[a]==a) return a;
        else return par[a]=root(par[a]);
    }
    
    void unite(int a,int b){
        if(root(a)!=root(b)){
            size[root(a)]+=size[root(b)];
            par[root(b)]=root(a);
        }
    }
    
    bool check(int a,int b){
        return root(a)==root(b);
    }
};

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    Point s,g;cin>>s.x>>s.y>>g.x>>g.y;
    vector<double> r(N),len(N);
    vector<vector<Point>> P(N);
    vector<int> cans(N),cang(N);
    for(int i=0;i<N;i++){
        cin>>r[i];
        int K;cin>>K;
        for(int j=0;j<K;j++){
            Point a;cin>>a.x>>a.y;
            P[i].push_back(a);
        }
        P[i].push_back(P[i][0]);
        for(int j=0;j<K;j++){
            Point a=P[i][j],b=P[i][j+1];
            len[i]+=getDistance(a,b);
            if(getDistanceSP({a,b},s)<=r[i]) cans[i]=true;
            if(getDistanceSP({a,b},g)<=r[i]) cang[i]=true;
        }
    }
    
    UF uf;uf.init(N);
    
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            vector<double> wheni,whenj;
            double sum=0;
            for(int k=0;k+1<si(P[i]);k++){
                wheni.push_back(sum/len[i]);
                Point a=P[i][k],b=P[i][(k+1)];
                sum+=getDistance(a,b);
            }
            sum=0;
            for(int k=0;k+1<si(P[j]);k++){
                whenj.push_back(sum/len[j]);
                Point a=P[j][k],b=P[j][(k+1)];
                sum+=getDistance(a,b);
            }
            
            int a=0,b=0;
            bool f=false;
            double now=0;
            while(a<si(P[i])-1&&b<si(P[j])-1){
                double left=now,right=min(wheni[a+1],whenj[b+1]);
                for(int q=0;q<40;q++){
                    double m1=(left*2+right)/3,m2=(left+right*2)/3;
                    Point pa1=P[i][a]+(P[i][a+1]-P[i][a])*(m1-wheni[a])/(wheni[a+1]-wheni[a]);
                    Point pa2=P[i][a]+(P[i][a+1]-P[i][a])*(m2-wheni[a])/(wheni[a+1]-wheni[a]);
                    Point pb1=P[j][b]+(P[j][b+1]-P[j][b])*(m1-whenj[b])/(whenj[b+1]-whenj[b]);
                    Point pb2=P[j][b]+(P[j][b+1]-P[j][b])*(m2-whenj[b])/(whenj[b+1]-whenj[b]);
                    if(getDistance(pa1,pb1)<=r[i]+r[j]) f=true;
                    if(getDistance(pa2,pb2)<=r[i]+r[j]) f=true;
                    double d1=getDistance(pa1,pb1);
                    double d2=getDistance(pa2,pb2);
                    if(d1<d2) right=m2;
                    else left=m1;
                }
                if(wheni[a+1]<=whenj[b+1]){
                    a++;
                }else{
                    b++;
                }
            }
            
            if(f) uf.unite(i,j);
            
        }
    }
    
    
    
    bool ans=false;
    
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(cans[i]&&cang[j]&&uf.check(i,j)) ans=true;
        }
    }
    
    if(ans) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
accuracy: 0.7027027027027027
time_ms: 90
memory_kb: 3624
final_rank: 16

code_snippet: //#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
#include<array>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int>P;

#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;
const ld pi = acosl(-1.0);

ll mod_pow(ll x, ll n, ll m = mod) {
	if (n < 0) {
		ll res = mod_pow(x, -n, m);
		return mod_pow(res, m - 2, m);
	}
	if (abs(x) >= m)x %= m;
	if (x < 0)x += m;
	ll res = 1;
	while (n) {
		if (n & 1)res = res * x % m;
		x = x * x % m; n >>= 1;
	}
	return res;
}
struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n % mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint& a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint& a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint& a, modint b) { a.n = ((ll)a.n * b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, ll n) {
	if (n == 0)return modint(1);
	modint res = (a * a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }
modint operator/=(modint& a, modint b) { a = a / b; return a; }
const int max_n = 1 << 2;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
modint combP(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[a - b];
}

struct uf {
private:
	vector<int> par, ran;
public:
	uf(int n) {
		par.resize(n, 0);
		ran.resize(n, 0);
		rep(i, n) {
			par[i] = i;
		}
	}
	int find(int x) {
		if (par[x] == x)return x;
		else return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x), y = find(y);
		if (x == y)return;
		if (ran[x] < ran[y]) {
			par[x] = y;
		}
		else {
			par[y] = x;
			if (ran[x] == ran[y])ran[x]++;
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};




typedef complex<ld> Point;
ld dot(Point a, Point b) { return real(conj(a) * b); }
ld cross(Point a, Point b) { return imag(conj(a) * b); }
namespace std {
	bool operator<(const Point& lhs, const Point& rhs) {
		return lhs.real() == rhs.real() ? lhs.imag() < rhs.imag() : lhs.real() < rhs.real();
	}
}
struct Line {
	Point a, b;
};
struct Circle {
	Point p; ld r;
};
int ccw(Point a, Point b, Point c) {
	b -= a; c -= a;
	if (cross(b, c) > eps)return 1;//counter clockwise
	if (cross(b, c) < -eps)return -1;//clock wise
	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 eq(ld a, ld b) {
	return abs(a - b) < eps;
}
//2直線の交差判定
bool isis_ll(Line l, Line m) {
	return !eq(cross(l.b - l.a, m.b - m.a), 0);
}
//直線と線分の交差判定
bool isis_ls(Line l, Line s) {
	return (cross(l.b - l.a, s.a - l.a) * cross(l.b - l.a, s.b - l.a) < eps);
}
//点が直線上に存在するか
bool isis_lp(Line l, Point p) {
	return (abs(cross(l.b - p, l.a - p)) < eps);
}
//点が線分上に存在するか
bool isis_sp(Line s, Point p) {
	return (abs(s.a - p) + abs(s.b - p) - abs(s.b - s.a) < eps);
}
//線分と線分の交差判定
//bool isis_ss(Line s, Line t) {
//	return(cross(s.b - s.a, t.a - s.a)*cross(s.b - s.a, t.b - s.a) < -eps && cross(t.b - t.a, s.a - t.a)*cross(t.b - t.a, s.b - t.a) < -eps);
//}
//線分と線分の交差判定2
bool isis_ss(Line s, Line 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;
}
//点から直線への垂線の足
Point proj(Line l, Point p) {
	ld t = dot(p - l.a, l.a - l.b) / norm(l.a - l.b);
	return l.a + t * (l.a - l.b);
}
//直線と直線の交点
//平行な２直線に対しては使うな！！！！
Point is_ll(Line s, Line t) {
	Point sv = s.b - s.a; Point tv = t.b - t.a;
	return s.a + sv * cross(tv, t.a - s.a) / cross(tv, sv);
}
//直線と点の距離
ld dist_lp(Line l, Point p) {
	return abs(p - proj(l, p));
}
//直線と直線の距離
ld dist_ll(Line l, Line m) {
	return isis_ll(l, m) ? 0 : dist_lp(l, m.a);
}
//線分と直線の距離
ld dist_ls(Line l, Line s) {
	return isis_ls(l, s) ? 0 : min(dist_lp(l, s.a), dist_lp(l, s.b));
}
//線分と点の距離
ld dist_sp(Line s, Point p) {
	Point r = proj(s, p);
	return isis_sp(s, r) ? abs(p - r) : min(abs(p - s.a), abs(p - s.b));
}
//線分と線分の距離
ld dist_ss(Line s, Line t) {
	if (isis_ss(s, t))return 0;
	return min({ dist_sp(s,t.a),dist_sp(s,t.b),dist_sp(t,s.a),dist_sp(t,s.b) });
}

ld dist_ex(Line s, Line t) {
	s.b -= t.b - t.a;
	//cout << dist_sp(s, t.a) << "\n";
	return dist_sp(s, t.a);
}
void solve() {
	int n, sx, sy, gx, gy;
	cin >> n >> sx >> sy >> gx >> gy;
	
	vector<vector<Point>> vp(n);
	vector<int> r(n);
	rep(i, n) {
		cin >> r[i];
		int len; cin >> len;
		vp[i].resize(len);
		rep(j, len) {
			int x, y; cin >> x >> y;
			vp[i][j] = { (ld)x,(ld)y };
		}
	}
	vector<vector<ld>> ad(n);
	vector<vector<ld>> d(n);

	vector<ld> coef(n);
	vector<vector<Point>> dv(n);
	rep(i, n) {
		d[i].resize(vp[i].size());
		dv[i].resize(vp[i].size());
		rep(j, vp[i].size()) {
			int nj = j + 1 == vp[i].size() ? 0 : j + 1;
			d[i][j] = abs(vp[i][j] - vp[i][nj]);
			dv[i][j] = (vp[i][nj] - vp[i][j]) / d[i][j];
		}
		ld sum = 0;
		rep(j, vp[i].size()) {
			sum += d[i][j];
		}
		coef[i] = 1 / sum;
		ad[i].resize(vp[i].size() + 1);
		rep(j, vp[i].size()) {
			ad[i][j + 1] = ad[i][j] + d[i][j] / sum;
			dv[i][j] *= sum;
		}
	}
	uf u(n + 2);
	rep(i, n)Rep(j, i + 1, n) {
		bool can = false;
		int ci = 0;
		int cj = 0;
		Point a = vp[i][0];
		Point b = vp[j][0];
		ld t = 0;
		while (ci < vp[i].size() && cj < vp[j].size()) {
			//cout << a << " " << b << " " << t << "\n";
			if (ad[i][ci + 1] < ad[j][cj + 1]) {
				ld dif = ad[i][ci + 1] - t;
				Line l1 = { a,a + dif * dv[i][ci] };
				Line l2 = { b,b + dif * dv[j][cj] };
				ld dist = dist_ex(l1, l2);
				if (dist <= r[i] + r[j])can = true;

				a +=dif * dv[i][ci];
				b += dif * dv[j][cj];
				ci++;
				t += dif;
			}
			else {
				ld dif = ad[j][cj + 1] - t;
				Line l1 = { a,a + dif * dv[i][ci] };
				Line l2 = { b,b + dif * dv[j][cj] };
				ld dist = dist_ex(l1, l2);
				if (dist <= r[i] + r[j])can = true;

				a += dif * dv[i][ci];
				b += dif * dv[j][cj];
				cj++;
				t+= dif;
			}
		}
		if (can) {
			//cout << i << " " << j << "\n";
			u.unite(i, j);
		}
	}
	rep(i, n) {
		Point sp = { (ld)sx,(ld)sy };
		Point gp = { (ld)gx,(ld)gy };
		rep(j, vp[i].size()) {
			int nj = j + 1 == vp[i].size() ? 0 : j + 1;
			Line l = { vp[i][j],vp[i][nj] };
			ld dist = dist_sp(l, sp);
			if (dist <= r[i])u.unite(i, n);
			dist = dist_sp(l, gp);
			//cout << l.a << " " << l.b << " " << gp << " " << dist << "\n";
			//cout << dist << "\n";
			if (dist <= r[i])u.unite(i, n + 1);
		}
	}
	if (u.same(n, n + 1)) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(8);
	//init_f();
	//init();
	//int t; cin >> t; rep(i, t)
	solve();
	return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3636
final_rank: 5

code_snippet: #include <bits/stdc++.h>
using namespace std;
const double EPS = 0.0000001;
struct point{
  double x, y;
  point(){
  }
  point(double x, double y): x(x), y(y){
  }
  point operator +(point P){
    return point(x + P.x, y + P.y);
  }
  point operator -(point P){
    return point(x - P.x, y - P.y);
  }
  point operator *(double k){
    return point(x * k, y * k);
  }
  point operator /(double k){
    return point(x / k, y / k);
  }
  bool operator <(point P) const{
    return x < P.x || x == P.x && y < P.y;
  }
};
double abs(point P){
  return sqrt(P.x * P.x + P.y * P.y);
}
double dist(point P, point Q){
  return abs(Q - P);
}
point unit(point P){
  return P / abs(P);
}
double dot(point P, point Q){
  return P.x * Q.x + P.y * Q.y;
}
double cross(point P, point Q){
  return P.x * Q.y - P.y * Q.x;
}
struct line{
  point A, B;
  line(point A, point B): A(A), B(B){
  }
};
point vec(line L){
  return L.B - L.A;
}
double point_line_distance(point P, line L){
  return abs(cross(P - L.A, vec(L))) / abs(vec(L));
}
double point_segment_distance(point P, line L){
  if (dot(P - L.A, vec(L)) < 0){
    return dist(P, L.A);
  } else if (dot(P - L.B, vec(L)) > 0){
    return dist(P, L.B);
  } else {
    return point_line_distance(P, L);
  }
}
int main(){
  int N;
  point S, T;
  cin >> N >> S.x >> S.y >> T.x >> T.y;
  vector<double> r(N);
  vector<int> K(N);
  vector<vector<point>> P(N);
  for (int i = 0; i < N; i++){
    cin >> r[i] >> K[i];
    P[i] = vector<point>(K[i] + 1);
    for (int j = 0; j < K[i]; j++){
      cin >> P[i][j].x >> P[i][j].y;
    }
    P[i][K[i]] = P[i][0];
  }
  vector<vector<double>> s(N);
  for (int i = 0; i < N; i++){
    s[i] = vector<double>(K[i] + 1);
    s[i][0] = 0;
    for (int j = 0; j < K[i]; j++){
      s[i][j + 1] = s[i][j] + dist(P[i][j], P[i][j + 1]);
    }
  }
  vector<vector<int>> E(N + 2, vector<int>(N + 2, false));
  for (int i = 0; i < N; i++){
    for (int j = 0; j < N; j++){
      vector<tuple<double, point, int>> upd;
      for (int k = 0; k < K[i]; k++){
        upd.push_back(make_tuple(s[i][k] / s[i][K[i]], (P[i][k + 1] - P[i][k]) * s[i][K[i]] / dist(P[i][k], P[i][k + 1]), 0));
      }
      for (int k = 0; k < K[j]; k++){
        upd.push_back(make_tuple(s[j][k] / s[j][K[j]], (P[j][k + 1] - P[j][k]) * s[j][K[j]] / dist(P[j][k], P[j][k + 1]), 1));
      }
      sort(upd.begin(), upd.end());
      int cnt = upd.size();
      point v1(0, 0), v2(0, 0);
      vector<double> t(cnt + 1);
      vector<point> dv(cnt);
      for (int k = 0; k < cnt; k++){
        double t2 = get<0>(upd[k]);
        point v = get<1>(upd[k]);
        int id = get<2>(upd[k]);
        if (id == 0){
          v1 = v;
        }
        if (id == 1){
          v2 = v;
        }
        t[k] = t2;
        dv[k] = v2 - v1;
      }
      t[cnt] = 1;
      point D = P[j][0] - P[i][0];
      if (abs(D) < r[i] + r[j]){
        E[i][j] = true;
      }
      for (int k = 0; k < cnt; k++){
        if (abs(dv[k]) > EPS){
          point D2 = D + dv[k] * (t[k + 1] - t[k]);
          if (point_segment_distance(point(0, 0), line(D, D2)) < r[i] + r[j]){
            E[i][j] = true;
          }
          D = D2;
        }
      }
    }
  }
  for (int i = 0; i < N; i++){
    for (int j = 0; j < K[i]; j++){
      if (point_segment_distance(S, line(P[i][j], P[i][j + 1])) < r[i]){
        E[N][i] = true;
      }
      if (point_segment_distance(T, line(P[i][j], P[i][j + 1])) < r[i]){
        E[i][N + 1] = true;
      }
    }
  }
  vector<bool> used(N + 2, false);
  used[N] = 0;
  queue<int> Q;
  Q.push(N);
  while (!Q.empty()){
    int v = Q.front();
    Q.pop();
    for (int i = 0; i < N + 2; i++){
      if (E[v][i] && !used[i]){
        used[i] = true;
        Q.push(i);
      }
    }
  }
  if (used[N + 1]){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
accuracy: 1
time_ms: 10
memory_kb: 3376
final_rank: 1

code_snippet: #include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define NUM 105

struct Point{
	Point(double arg_x,double arg_y,double arg_arrive_time){
		x = arg_x;
		y = arg_y;
		arrive_time = arg_arrive_time;
	}

	Point(){
		x = y = 0.0;
		arrive_time = 0;
	}

	Point operator + (Point p){ return Point(x+p.x,y+p.y,arrive_time); }
	Point operator - (Point p){ return Point(x-p.x,y-p.y,arrive_time);}
	Point operator * (double a){ return Point(a*x,a*y,arrive_time); }
	Point operator / (double a){ return Point(x/a,y/a,arrive_time); }

	double abs(){ return sqrt(norm()); }
	double norm(){ return x*x + y*y; }

	bool operator<(const Point &p) const{
		return x != p.x? x < p.x: y < p.y;
	}

	bool operator == (const Point &p) const{
		return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
	}

	double x,y,arrive_time;
};
typedef Point Vector;

struct Line{
	Point p[2];
	Line(Point p1,Point p2){
		p[0] = p1;
		p[1] = p2;
	}
	Line(){

	}
};

typedef vector<Point> Polygon;

struct Info{

	double R;
	vector<Line> LINE;
	int num_point;
};

int N;
int boss[NUM],height[NUM];
int start_index,goal_index;
double UNIT_TIME = 10.0;
Point start,goal;
Info info[NUM];


//自分のボスのindexを取得しつつ、経路圧縮を行う関数
int get_boss(int id){
	if(boss[id] == id)return id; //自分が代表なら、自分の値を返す
	else{
		return boss[id] = get_boss(boss[id]); //代表でないなら、自分が所属する組織の代表を返しつつ、経路圧縮
	}
}

int is_Same(int x,int y){
	return get_boss(x) == get_boss(y);
}

void unite(int x,int y){
	int boss_x = get_boss(x);
	int boss_y = get_boss(y);

	//既に同じグループなら何もしない
	if(boss_x == boss_y)return;

	//高さが高い方に吸収する
	if(height[x] > height[y]){

		boss[boss_y] = boss_x;

	}else if(height[x] < height[y]){

		boss[boss_x] = boss_y;

	}else{ //height[x] == height[y]

		boss[boss_y] = boss_x;
		height[x]++;
	}
}

void init(){

	for(int i = 0; i < N; i++){

		boss[i] = i;
		height[i] = 0;
	}
}


double norm(Vector a){
	return a.x*a.x+a.y*a.y;
}

double abs(Vector a){
	return sqrt(norm(a));
}

double cross(Vector a,Vector b){
    return a.x*b.y-a.y*b.x;
}

double dot(Vector a,Vector b){
    return a.x*b.x + a.y*b.y;
}

Point calc_minus(Point a,Point b){
    Point ret;

    ret.x = a.x-b.x;
    ret.y = a.y-b.y;

    return ret;
}

int func(double x1,double y1,double x2, double y2, double xp, double yp){
	double naiseki,norm1,norm2,gaiseki;
	norm1 = sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
	norm2 = sqrt((xp-x1)*(xp-x1)+(yp-y1)*(yp-y1));
	naiseki = (xp-x1)*(x2-x1)+(yp-y1)*(y2-y1);
	gaiseki = (x2-x1)*(yp-y1)-(xp-x1)*(y2-y1);
	if(gaiseki > EPS){
		return 1;
	}else if(gaiseki < -EPS){
		return -1;
	}
	if(naiseki < -EPS){
		return 2;
	}

	if(norm1 < norm2){
		return -2;
	}
	return 0;
}


//★★直線ではなく、線分の交差判定★★
bool is_Cross(Line a,Line b){

	if(func(a.p[0].x,a.p[0].y,a.p[1].x,a.p[1].y,b.p[0].x,b.p[0].y)*
			func(a.p[0].x,a.p[0].y,a.p[1].x,a.p[1].y,b.p[1].x,b.p[1].y) <= 0 &&
			func(b.p[0].x,b.p[0].y,b.p[1].x,b.p[1].y,a.p[0].x,a.p[0].y)*
			func(b.p[0].x,b.p[0].y,b.p[1].x,b.p[1].y,a.p[1].x,a.p[1].y) <= 0){
		return true;
	}
	return false;
}

double calc_len(Vector a){
    return sqrt(a.x*a.x+a.y*a.y);
}

//★★線分ではなく直線と点の距離★★
double getDistanceLP(Line l,Point p){
    return fabs(cross(calc_minus(l.p[1],l.p[0]),calc_minus(p,l.p[0]))/calc_len(calc_minus(l.p[1],l.p[0])));
}

//★★点と線分の距離★★
double getDistanceSP(Line l,Point p){
	if(dot(calc_minus(l.p[1],l.p[0]),calc_minus(p,l.p[0])) < 0.0)return calc_len(calc_minus(p,l.p[0]));
	if(dot(calc_minus(l.p[0],l.p[1]),calc_minus(p,l.p[1])) < 0.0)return calc_len(calc_minus(p,l.p[1]));
	return getDistanceLP(l,p);
}

//★★線分と線分の距離★★
double getDistance(Line A,Line B){
	if(is_Cross(A,B))return 0.0;
	return min(min(getDistanceSP(A,B.p[0]),getDistanceSP(A,B.p[1])),
			min(getDistanceSP(B,A.p[0]),getDistanceSP(B,A.p[1])));
}

double calc_dist(Point A,Point B){

	return sqrt((A.x-B.x)*(A.x-B.x)+(A.y-B.y)*(A.y-B.y));
}


double calc_dist(Point A,Point B,Vector dir_A,Vector dir_B,double diff_time){

	Point calc_A = A+dir_A*diff_time;
	Point calc_B = B+dir_B*diff_time;

	return calc_dist(calc_A,calc_B);
}

double thirds_search(double left,double right,Point A,Point B,Vector dir_A,Vector dir_B){

	if(fabs(right-left) < EPS){
		return calc_dist(A,B,dir_A,dir_B,(left+right)/2);
	}

	double mid1 = (2.0*left+right)/3.0;
	double mid2 = (1.0*left+2.0*right)/3.0;

	if(calc_dist(A,B,dir_A,dir_B,mid1) > calc_dist(A,B,dir_A,dir_B,mid2)){ //大きい方の外側を捨てる
		return thirds_search(mid1,right,A,B,dir_A,dir_B);
	}else{
		return thirds_search(left,mid2,A,B,dir_A,dir_B);
	}
}

Vector calc_dir(Line A){

	Vector ret;

	double v = abs(A.p[1]-A.p[0])/(A.p[1].arrive_time-A.p[0].arrive_time); //距離/時間 = 速さ

	ret.x = v*((A.p[1].x-A.p[0].x)/abs(A.p[1]-A.p[0]));
	ret.y = v*((A.p[1].y-A.p[0].y)/abs(A.p[1]-A.p[0]));

	return ret;
}

int main(){

	scanf("%d %lf %lf %lf %lf",&N,&start.x,&start.y,&goal.x,&goal.y);

	for(int i = 0; i < N; i++){

		scanf("%lf %d",&info[i].R,&info[i].num_point);

		Polygon polygon;

		for(int k = 0; k < info[i].num_point; k++){

			Point tmp_point;

			scanf("%lf %lf",&tmp_point.x,&tmp_point.y);

			polygon.push_back(tmp_point);
		}

		double sum_dist = 0; //到着時刻を求めるため、まずは総距離を計算

		for(int k = 0; k < info[i].num_point; k++){

			Line tmp_line;

			tmp_line.p[0] = polygon[k];
			tmp_line.p[1] = polygon[(k+1)%info[i].num_point];

			info[i].LINE.push_back(tmp_line);

			sum_dist += calc_dist(tmp_line.p[0],tmp_line.p[1]);
		}

		double current_time = 0;

		for(int k = 0; k < info[i].num_point; k++){

			double tmp_dist = calc_dist(info[i].LINE[k].p[1],info[i].LINE[k].p[0]);

			info[i].LINE[k].p[0].arrive_time = current_time;
			info[i].LINE[k].p[1].arrive_time = current_time+UNIT_TIME*(tmp_dist/sum_dist);

			current_time = info[i].LINE[k].p[1].arrive_time;
		}
	}

	start_index = N;
	goal_index = N+1;

	N += 2;
	init();

	//スタートと、スポットライトの関係を調べる
	for(int i = 0; i <= N-3; i++){

		double min_dist = BIG_NUM;

		for(int k = 0; k < info[i].num_point; k++){

			double tmp_dist = getDistanceSP(info[i].LINE[k],start);

			min_dist = min(min_dist,tmp_dist);
		}

		if(min_dist+EPS < info[i].R){

			unite(i,start_index);
		}
	}

	//ゴールと、スポットライトの関係を調べる
	for(int i = 0; i <= N-3; i++){

		double min_dist = BIG_NUM;

		for(int k = 0; k < info[i].num_point; k++){

			double tmp_dist = getDistanceSP(info[i].LINE[k],goal);

			min_dist = min(min_dist,tmp_dist);
		}

		if(min_dist+EPS < info[i].R){

			unite(i,goal_index);
		}
	}

	//スポットライト同士の接続関係を調べる
	for(int i = 0; i <= N-4; i++){
		for(int k = i+1; k <= N-3; k++){

			double min_dist = BIG_NUM;

			for(int a = 0; a < info[i].num_point; a++){
				for(int b = 0; b < info[k].num_point; b++){

					if(getDistance(info[i].LINE[a],info[k].LINE[b]) >= info[i].R+info[k].R)continue; //交差不可能なのでSKIP

					double L = max(info[i].LINE[a].p[0].arrive_time,info[k].LINE[b].p[0].arrive_time);
					double	R = min(info[i].LINE[a].p[1].arrive_time,info[k].LINE[b].p[1].arrive_time);

					if(L >= R){
						continue; //時間が交差しないのでSKIP
					}

					Point A = info[i].LINE[a].p[0];
					Point B = info[k].LINE[b].p[0];

					Vector dir_A = calc_dir(info[i].LINE[a]);
					Vector dir_B = calc_dir(info[k].LINE[b]);

					double tmp_dist = thirds_search(0,R-L,A,B,dir_A,dir_B);

					min_dist = min(min_dist,tmp_dist);
				}
			}

			if(min_dist+EPS < info[i].R+info[k].R){

				unite(i,k);
			}
		}
	}


	if(is_Same(start_index,goal_index)){

		printf("Yes\n");

	}else{

		printf("No\n");
	}

	return 0;
}
accuracy: 1
time_ms: 130
memory_kb: 3332
final_rank: 3

code_snippet: #include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

struct UnionFind{
  vector<int> v;
  UnionFind(int n) : v(n, -1) {}
  void init(){ for(int i = 0;i < (int)v.size();i++)v[i]=-1; }
  int find(int x) { return v[x] < 0 ? x : v[x] = find(v[x]); }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (-v[x] < -v[y]) swap(x, y);
    v[x] += v[y]; v[y] = x;
    return true;
  }
  bool root(int x) { return v[x] < 0; }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -v[find(x)]; }
};

typedef long double D;
typedef complex<D> P;

#define X real()
#define Y imag()

D dot(P a,P b){ return (conj(a)*b).X; }

const D eps=1e-9;
const D inf=1e12;
const D PI=acos(-1);
struct L : public vector<P> { // line and segment
  L(const P& a,const P &b){
    push_back(a);
    push_back(b);
  }
};

int N;
int sx,sy,tx,ty;
D R[110];
int sz[110];
D tot[110];
D st[110][21];
vector<P> cents[110];

int main(){
  cin>>N>>sx>>sy>>tx>>ty;
  rep(i,N){
    cin>>R[i];
    cin>>sz[i];
    rep(j,sz[i]){
      int x,y;
      cin>>x>>y;
      cents[i].push_back(P(x,y));
    }
    rep(j,sz[i])tot[i]+=abs(cents[i][j]-cents[i][(j+1)%sz[i]]);

    st[i][0]=0;
    repl(j,1,sz[i]){
      D len=abs(cents[i][j]-cents[i][j-1]);
      st[i][j]=st[i][j-1]+(len/tot[i]);
    }
  }
  sz[N]=1; cents[N].push_back(P(sx,sy));
  sz[N+1]=1; cents[N+1].push_back(P(tx,ty));

  UnionFind uf(N+2);
  rep(i,N+2){
    rep(j,i){
      if(i==N+1&&j==N)continue;
      rep(crti,sz[i]){
        int nxti=(crti+1)%sz[i];
        D ist=st[i][crti],ied=(nxti==0?1.0:st[i][nxti]);
        rep(crtj,sz[j]){
          int nxtj=(crtj+1)%sz[j];
          D jst=st[j][crtj],jed=(nxtj==0?1.0:st[j][nxtj]);

          D l=max(ist,jst),r=min(ied,jed);
          D ub=pow(R[i]+R[j],2);
          if(l>r)continue;

          P inidelta=(cents[i][crti]-(ist/(ied-ist))*(cents[i][nxti]-cents[i][crti]))-(cents[j][crtj]-(jst/(jed-jst))*(cents[j][nxtj]-cents[j][crtj]));
          P vdelta=((cents[i][nxti]-cents[i][crti])/(ied-ist))-((cents[j][nxtj]-cents[j][crtj])/(jed-jst));

          D A=norm(vdelta), B=2.0*dot(inidelta,vdelta), C=norm(inidelta);
          if(abs(A)<eps){
            if(C<=ub)uf.unite(i,j);
            continue;
          }
          if(A*l*l+B*l+C<=ub||A*r*r+B*r+C<=ub)uf.unite(i,j);
          D x=-B/(2.0*A);
          if(l<=x&&x<=r&&A*x*x+B*x+C<=ub)uf.unite(i,j);
        }
      }
    }
  }

  if(uf.same(N,N+1))cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3376
final_rank: 1

code_snippet: #include <bits/stdc++.h>
#define MOD 1000000007LL
#define EPS 1e-10
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<long double,int> DP;

long double add(long double a,long double b){
	if(abs(a+b)<EPS*(abs(a)+abs(b)))return 0.0;
	return a+b;
}

class Point{
public:
	long double x,y;
	Point(){}
	Point(long double xx,long double yy){
		x=xx;
		y=yy;
	}
	Point operator +(Point p){
		return Point(x+p.x,y+p.y);
	}
	Point operator -(Point p){
		return Point(x-p.x,y-p.y);
	}
	Point operator *(long double a){
		return Point(a*x,a*y);
	}
	Point operator /(long double a){
		return Point(x/a,y/a);
	}
	long double abs(){
		return sqrt(norm());
	}

	long double norm(){
		return x*x+y*y;
	}
};

typedef Point Vector;
struct Segment{
	Point p1,p2;
	Segment(){}
	Segment(Point pp1,Point pp2){
		p1=pp1;
		p2=pp2;
	}
};

typedef Segment Line;

long double norm(Vector v){
	return v.x*v.x+v.y*v.y;
}

long double abs(Vector v){
	return sqrt(norm(v));
}

long double dot(Vector a,Vector b){
	return a.x*b.x+a.y*b.y;
}

long double cross(Vector a,Vector b){
	return a.x*b.y-a.y*b.x;
}

long double getDistance(Point a,Point b){
	return abs(a-b);
}

long double getDistanceLP(Line l,Point p){
	return abs(cross(l.p2-l.p1,p-l.p1))/abs(l.p2-l.p1);
}

long double getDistanceSP(Segment s,Point p){
	if(dot(s.p2-s.p1,p-s.p1)<0.0)return abs(p-s.p1);
	if(dot(s.p1-s.p2,p-s.p2)<0.0)return abs(p-s.p2);
	return getDistanceLP(s,p);
}

int n;
Point s,e;
vector<int> G[105];
long double r[105];
int siz[105];
vector<Point> vp[105];
bool used[105];

void dfs(int v){
	used[v]=true;
	for(int i=0;i<G[v].size();i++){
		int nv=G[v][i];
		if(!used[nv])dfs(nv);
	}
}

long double C(long double sec,Vector a,Vector d){
	a=a+d*sec;
	return abs(a);
}

bool check(int a,int b){
	long double lena=0;
	long double lenb=0;
	for(int i=0;i<siz[a];i++){
		lena+=abs(vp[a][i]-vp[a][(i+1)%siz[a]]);
	}
	for(int i=0;i<siz[b];i++){
		lenb+=abs(vp[b][i]-vp[b][(i+1)%siz[b]]);
	}
	vector<DP> ch;
	Point diff=vp[a][0]-vp[b][0];
	if(abs(diff)<=r[a]+r[b])return true;
	long double cur=0;
	for(int i=0;i<siz[a];i++){
		cur+=abs(vp[a][i]-vp[a][(i+1)%siz[a]]);
		ch.push_back(DP(cur/lena,0));
	}
	cur=0;
	for(int i=0;i<siz[b];i++){
		cur+=abs(vp[b][i]-vp[b][(i+1)%siz[b]]);
		ch.push_back(DP(cur/lenb,1));
	}
	sort(ch.begin(),ch.end());
	int pa=0,pb=0;
	long double prev=0.0;
	for(int i=0;i<ch.size();i++){
		Vector di=(vp[a][(pa+1)%siz[a]]-vp[a][pa])/abs(vp[a][pa]-vp[a][(pa+1)%siz[a]])*lena;
		di=di-(vp[b][(pb+1)%siz[b]]-vp[b][pb])/abs(vp[b][pb]-vp[b][(pb+1)%siz[b]])*lenb;
		long double vl=0.0;
		long double vr=ch[i].first-prev;
		for(int k=0;k<100;k++){
			long double midl=(vl*2.0+vr)/3;
			long double midr=(vl+vr*2.0)/3;
			if(C(midl,diff,di)<C(midr,diff,di)){
				vr=midr;
			}else{
				vl=midl;
			}
		}
		if(C(vl,diff,di)<=r[a]+r[b])return true;
		if(abs(di*(ch[i].first-prev))>EPS)diff=diff+di*(ch[i].first-prev);
		if(ch[i].second==0){
			pa=(pa+1)%siz[a];
		}else{
			pb=(pb+1)%siz[b];
		}
		prev=ch[i].first;
	}
	return false;
}

int main(void){
	double aa,bb,cc,dd;
	scanf("%d%lf%lf%lf%lf",&n,&aa,&bb,&cc,&dd);
	s.x=aa;
	s.y=bb;
	e.x=cc;
	e.y=dd;
	for(int i=0;i<n;i++){
		scanf("%lf%d",&aa,&siz[i]);
		r[i]=aa;
		for(int j=0;j<siz[i];j++){
			Point p;
			scanf("%lf%lf",&aa,&bb);
			p.x=aa;
			p.y=bb;
			vp[i].push_back(p);
		}
	}
	for(int i=0;i<n;i++){
		bool flag=false;
		for(int j=0;j<siz[i];j++){
			if(getDistanceSP(Segment(vp[i][j],vp[i][(j+1)%siz[i]]),s)<=r[i])flag=true;
		}
		if(flag)G[n].push_back(i);
	}
	for(int i=0;i<n;i++){
		bool flag=false;
		for(int j=0;j<siz[i];j++){
			if(getDistanceSP(Segment(vp[i][j],vp[i][(j+1)%siz[i]]),e)<=r[i])flag=true;
		}
		if(flag)G[i].push_back(n+1);
	}
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(check(i,j)){
				G[i].push_back(j);
				G[j].push_back(i);
			}
		}
	}
	dfs(n);
	printf("%s\n",used[n+1]?"Yes":"No");
	return 0;
}
accuracy: 1
time_ms: 260
memory_kb: 3404
final_rank: 4

code_snippet: #include <bits/stdc++.h>
#define MOD 1000000007LL
#define EPS 1e-10
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<long double,int> DP;

long double add(long double a,long double b){
	if(abs(a+b)<EPS*(abs(a)+abs(b)))return 0.0;
	return a+b;
}

class Point{
public:
	long double x,y;
	Point(){}
	Point(long double xx,long double yy){
		x=xx;
		y=yy;
	}
	Point operator +(Point p){
		return Point(x+p.x,y+p.y);
	}
	Point operator -(Point p){
		return Point(x-p.x,y-p.y);
	}
	Point operator *(long double a){
		return Point(a*x,a*y);
	}
	Point operator /(long double a){
		return Point(x/a,y/a);
	}
	long double abs(){
		return sqrt(norm());
	}

	long double norm(){
		return x*x+y*y;
	}
};

typedef Point Vector;
struct Segment{
	Point p1,p2;
	Segment(){}
	Segment(Point pp1,Point pp2){
		p1=pp1;
		p2=pp2;
	}
};

typedef Segment Line;

long double norm(Vector v){
	return v.x*v.x+v.y*v.y;
}

long double abs(Vector v){
	return sqrt(norm(v));
}

long double dot(Vector a,Vector b){
	return a.x*b.x+a.y*b.y;
}

long double cross(Vector a,Vector b){
	return a.x*b.y-a.y*b.x;
}

long double getDistance(Point a,Point b){
	return abs(a-b);
}

long double getDistanceLP(Line l,Point p){
	return abs(cross(l.p2-l.p1,p-l.p1))/abs(l.p2-l.p1);
}

long double getDistanceSP(Segment s,Point p){
	if(dot(s.p2-s.p1,p-s.p1)<0.0)return abs(p-s.p1);
	if(dot(s.p1-s.p2,p-s.p2)<0.0)return abs(p-s.p2);
	return getDistanceLP(s,p);
}

int n;
Point s,e;
vector<int> G[105];
long double r[105];
int siz[105];
vector<Point> vp[105];
bool used[105];

void dfs(int v){
	used[v]=true;
	for(int i=0;i<G[v].size();i++){
		int nv=G[v][i];
		if(!used[nv])dfs(nv);
	}
}

long double C(long double sec,Vector a,Vector d){
	a=a+d*sec;
	return abs(a);
}

bool check(int a,int b){
	long double lena=0;
	long double lenb=0;
	for(int i=0;i<siz[a];i++){
		lena+=abs(vp[a][i]-vp[a][(i+1)%siz[a]]);
	}
	for(int i=0;i<siz[b];i++){
		lenb+=abs(vp[b][i]-vp[b][(i+1)%siz[b]]);
	}
	vector<DP> ch;
	Point diff=vp[a][0]-vp[b][0];
	if(abs(diff)<=r[a]+r[b])return true;
	long double cur=0;
	for(int i=0;i<siz[a];i++){
		cur+=abs(vp[a][i]-vp[a][(i+1)%siz[a]]);
		ch.push_back(DP(cur,0));
	}
	cur=0;
	for(int i=0;i<siz[b];i++){
		cur+=abs(vp[b][i]-vp[b][(i+1)%siz[b]]);
		ch.push_back(DP(cur*lena/lenb,1));
	}
	sort(ch.begin(),ch.end());
	int pa=0,pb=0;
	long double prev=0.0;
	for(int i=0;i<ch.size();i++){
		Vector di=(vp[a][(pa+1)%siz[a]]-vp[a][pa])/(abs(vp[a][pa]-vp[a][(pa+1)%siz[a]]));
		di=di-(vp[b][(pb+1)%siz[b]]-vp[b][pb])*lena/(abs(vp[b][pb]-vp[b][(pb+1)%siz[b]])*lenb);
		long double vl=0.0;
		long double vr=ch[i].first-prev;
		for(int k=0;k<100;k++){
			long double midl=(vl*2.0+vr)/3;
			long double midr=(vl+vr*2.0)/3;
			if(C(midl,diff,di)<C(midr,diff,di)){
				vr=midr;
			}else{
				vl=midl;
			}
		}
		if(C(vl,diff,di)<=r[a]+r[b])return true;
		if(abs(di*(ch[i].first-prev))>EPS)diff=diff+di*(ch[i].first-prev);
		if(ch[i].second==0){
			pa=(pa+1)%siz[a];
		}else{
			pb=(pb+1)%siz[b];
		}
		prev=ch[i].first;
	}
	return false;
}

int main(void){
	double aa,bb,cc,dd;
	scanf("%d%lf%lf%lf%lf",&n,&aa,&bb,&cc,&dd);
	s.x=aa;
	s.y=bb;
	e.x=cc;
	e.y=dd;
	for(int i=0;i<n;i++){
		scanf("%lf%d",&aa,&siz[i]);
		r[i]=aa;
		for(int j=0;j<siz[i];j++){
			Point p;
			scanf("%lf%lf",&aa,&bb);
			p.x=aa;
			p.y=bb;
			vp[i].push_back(p);
		}
	}
	for(int i=0;i<n;i++){
		bool flag=false;
		for(int j=0;j<siz[i];j++){
			if(getDistanceSP(Segment(vp[i][j],vp[i][(j+1)%siz[i]]),s)<=r[i])flag=true;
		}
		if(flag)G[n].push_back(i);
	}
	for(int i=0;i<n;i++){
		bool flag=false;
		for(int j=0;j<siz[i];j++){
			if(getDistanceSP(Segment(vp[i][j],vp[i][(j+1)%siz[i]]),e)<=r[i])flag=true;
		}
		if(flag)G[i].push_back(n+1);
	}
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(check(i,j)){
				G[i].push_back(j);
				G[j].push_back(i);
			}
		}
	}
	dfs(n);
	printf("%s\n",used[n+1]?"Yes":"No");
	return 0;
}
accuracy: 0.7162162162162162
time_ms: 260
memory_kb: 3400
final_rank: 8

code_snippet: #include <bits/stdc++.h>
#define MOD 1000000007LL
#define EPS 1e-10
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<long double,int> DP;

long double add(long double a,long double b){
	if(abs(a+b)<EPS*(abs(a)+abs(b)))return 0.0;
	return a+b;
}

class Point{
public:
	long double x,y;
	Point(){}
	Point(long double xx,long double yy){
		x=xx;
		y=yy;
	}
	Point operator +(Point p){
		return Point(x+p.x,y+p.y);
	}
	Point operator -(Point p){
		return Point(x-p.x,y-p.y);
	}
	Point operator *(long double a){
		return Point(a*x,a*y);
	}
	Point operator /(long double a){
		return Point(x/a,y/a);
	}
	long double abs(){
		return sqrt(norm());
	}

	long double norm(){
		return x*x+y*y;
	}
};

typedef Point Vector;
struct Segment{
	Point p1,p2;
	Segment(){}
	Segment(Point pp1,Point pp2){
		p1=pp1;
		p2=pp2;
	}
};

typedef Segment Line;

long double norm(Vector v){
	return v.x*v.x+v.y*v.y;
}

long double abs(Vector v){
	return sqrt(norm(v));
}

long double dot(Vector a,Vector b){
	return a.x*b.x+a.y*b.y;
}

long double cross(Vector a,Vector b){
	return a.x*b.y-a.y*b.x;
}

long double getDistance(Point a,Point b){
	return abs(a-b);
}

long double getDistanceLP(Line l,Point p){
	return abs(cross(l.p2-l.p1,p-l.p1))/abs(l.p2-l.p1);
}

long double getDistanceSP(Segment s,Point p){
	if(dot(s.p2-s.p1,p-s.p1)<0.0)return abs(p-s.p1);
	if(dot(s.p1-s.p2,p-s.p2)<0.0)return abs(p-s.p2);
	return getDistanceLP(s,p);
}

int n;
Point s,e;
vector<int> G[105];
long double r[105];
int siz[105];
vector<Point> vp[105];
bool used[105];

long double abs(long double v){
	if(v<0.0)return -v;
	return v;
}

void dfs(int v){
	used[v]=true;
	for(int i=0;i<G[v].size();i++){
		int nv=G[v][i];
		if(!used[nv])dfs(nv);
	}
}

long double C(long double sec,Vector a,Vector d){
	a=a+d*sec;
	return abs(a);
}

bool check(int a,int b){
	long double lena=0;
	long double lenb=0;
	for(int i=0;i<siz[a];i++){
		lena+=abs(vp[a][i]-vp[a][(i+1)%siz[a]]);
	}
	for(int i=0;i<siz[b];i++){
		lenb+=abs(vp[b][i]-vp[b][(i+1)%siz[b]]);
	}
	vector<DP> ch;
	Point diff=vp[a][0]-vp[b][0];
	if(abs(diff)<r[a]+r[b])return true;
	long double cur=0;
	for(int i=0;i<siz[a];i++){
		cur+=abs(vp[a][i]-vp[a][(i+1)%siz[a]]);
		ch.push_back(DP(cur,0));
	}
	cur=0;
	for(int i=0;i<siz[b];i++){
		cur+=abs(vp[b][i]-vp[b][(i+1)%siz[b]]);
		ch.push_back(DP(cur*lena/lenb,1));
	}
	sort(ch.begin(),ch.end());
	int pa=0,pb=0;
	long double prev=0.0;
	long double pta=0.0;
	long double ptb=0.0;
	for(int i=0;i<ch.size();i++){
		Vector di=(vp[a][(pa+1)%siz[a]]-vp[a][pa])/(abs(vp[a][pa]-vp[a][(pa+1)%siz[a]]));
		di=di-(vp[b][(pb+1)%siz[b]]-vp[b][pb])*lena/(abs(vp[b][pb]-vp[b][(pb+1)%siz[b]])*lenb);
		long double vl=0.0;
		long double vr=ch[i].first-prev;
		for(int k=0;k<300;k++){
			long double midl=(vl*2.0+vr)/3;
			long double midr=(vl+vr*2.0)/3;
			if(C(midl,diff,di)<C(midr,diff,di)){
				vr=midr;
			}else{
				vl=midl;
			}
		}
		if(C(vl,diff,di)<r[a]+r[b])return true;
		if(ch[i].second==0){
			pa=(pa+1)%siz[a];
			pta=ch[i].first;
			diff=vp[a][pa]-vp[b][pb];
			diff=diff-(vp[b][(pb+1)%siz[b]]-vp[b][pb])*lena/(abs(vp[b][pb]-vp[b][(pb+1)%siz[b]])*lenb)*(ch[i].first-ptb);
		}else{
			pb=(pb+1)%siz[b];
			ptb=ch[i].first;
			diff=vp[a][pa]-vp[b][pb];
			diff=diff+(vp[a][(pa+1)%siz[a]]-vp[a][pa])/(abs(vp[a][pa]-vp[a][(pa+1)%siz[a]]))*(ch[i].first-pta);
		}
		prev=ch[i].first;
	}
	return false;
}

int main(void){
	double aa,bb,cc,dd;
	scanf("%d%lf%lf%lf%lf",&n,&aa,&bb,&cc,&dd);
	s.x=aa;
	s.y=bb;
	e.x=cc;
	e.y=dd;
	for(int i=0;i<n;i++){
		scanf("%lf%d",&aa,&siz[i]);
		r[i]=aa;
		for(int j=0;j<siz[i];j++){
			Point p;
			scanf("%lf%lf",&aa,&bb);
			p.x=aa;
			p.y=bb;
			vp[i].push_back(p);
		}
	}
	for(int i=0;i<n;i++){
		bool flag=false;
		for(int j=0;j<siz[i];j++){
			if(getDistanceSP(Segment(vp[i][j],vp[i][(j+1)%siz[i]]),s)<=r[i])flag=true;
		}
		if(flag)G[n].push_back(i);
	}
	for(int i=0;i<n;i++){
		bool flag=false;
		for(int j=0;j<siz[i];j++){
			if(getDistanceSP(Segment(vp[i][j],vp[i][(j+1)%siz[i]]),e)<=r[i])flag=true;
		}
		if(flag)G[i].push_back(n+1);
	}
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(check(i,j)){
				G[i].push_back(j);
				G[j].push_back(i);
			}
		}
	}
	dfs(n);
	printf("%s\n",used[n+1]?"Yes":"No");
	return 0;
}
accuracy: 0.7027027027027027
time_ms: 760
memory_kb: 3408
final_rank: 17

code_snippet: #include <bits/stdc++.h>
#define MOD 1000000007LL
#define EPS 1e-10
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<long double,int> DP;

long double add(long double a,long double b){
	if(abs(a+b)<EPS*(abs(a)+abs(b)))return 0.0;
	return a+b;
}

class Point{
public:
	long double x,y;
	Point(){}
	Point(long double xx,long double yy){
		x=xx;
		y=yy;
	}
	Point operator +(Point p){
		return Point(x+p.x,y+p.y);
	}
	Point operator -(Point p){
		return Point(x-p.x,y-p.y);
	}
	Point operator *(long double a){
		return Point(a*x,a*y);
	}
	Point operator /(long double a){
		return Point(x/a,y/a);
	}
	long double abs(){
		return sqrt(norm());
	}

	long double norm(){
		return x*x+y*y;
	}
};

typedef Point Vector;
struct Segment{
	Point p1,p2;
	Segment(){}
	Segment(Point pp1,Point pp2){
		p1=pp1;
		p2=pp2;
	}
};

typedef Segment Line;

long double norm(Vector v){
	return v.x*v.x+v.y*v.y;
}

long double abs(Vector v){
	return sqrt(norm(v));
}

long double dot(Vector a,Vector b){
	return a.x*b.x+a.y*b.y;
}

long double cross(Vector a,Vector b){
	return a.x*b.y-a.y*b.x;
}

long double getDistance(Point a,Point b){
	return abs(a-b);
}

long double getDistanceLP(Line l,Point p){
	return abs(cross(l.p2-l.p1,p-l.p1))/abs(l.p2-l.p1);
}

long double getDistanceSP(Segment s,Point p){
	if(dot(s.p2-s.p1,p-s.p1)<0.0)return abs(p-s.p1);
	if(dot(s.p1-s.p2,p-s.p2)<0.0)return abs(p-s.p2);
	return getDistanceLP(s,p);
}

int n;
Point s,e;
vector<int> G[105];
long double r[105];
int siz[105];
vector<Point> vp[105];
bool used[105];

long double abs(long double v){
	if(v<0.0)return -v;
	return v;
}

void dfs(int v){
	used[v]=true;
	for(int i=0;i<G[v].size();i++){
		int nv=G[v][i];
		if(!used[nv])dfs(nv);
	}
}

long double C(long double sec,Vector a,Vector d){
	a=a+d*sec;
	return abs(a);
}

bool check(int a,int b){
	long double lena=0;
	long double lenb=0;
	for(int i=0;i<siz[a];i++){
		lena+=abs(vp[a][i]-vp[a][(i+1)%siz[a]]);
	}
	for(int i=0;i<siz[b];i++){
		lenb+=abs(vp[b][i]-vp[b][(i+1)%siz[b]]);
	}
	vector<DP> ch;
	Point diff=vp[a][0]-vp[b][0];
	if(abs(diff)<=r[a]+r[b])return true;
	long double cur=0;
	for(int i=0;i<siz[a];i++){
		cur+=abs(vp[a][i]-vp[a][(i+1)%siz[a]]);
		ch.push_back(DP(cur,0));
	}
	cur=0;
	for(int i=0;i<siz[b];i++){
		cur+=abs(vp[b][i]-vp[b][(i+1)%siz[b]]);
		ch.push_back(DP(cur*lena/lenb,1));
	}
	sort(ch.begin(),ch.end());
	int pa=0,pb=0;
	long double prev=0.0;
	long double pta=0.0;
	long double ptb=0.0;
	for(int i=0;i<ch.size();i++){
		Vector di=(vp[a][(pa+1)%siz[a]]-vp[a][pa])/(abs(vp[a][pa]-vp[a][(pa+1)%siz[a]]));
		di=di-(vp[b][(pb+1)%siz[b]]-vp[b][pb])*lena/(abs(vp[b][pb]-vp[b][(pb+1)%siz[b]])*lenb);
		long double vl=0.0;
		long double vr=ch[i].first-prev;
		for(int k=0;k<300;k++){
			long double midl=(vl*2.0+vr)/3;
			long double midr=(vl+vr*2.0)/3;
			if(C(midl,diff,di)<C(midr,diff,di)){
				vr=midr;
			}else{
				vl=midl;
			}
		}
		if(C(vl,diff,di)<=r[a]+r[b])return true;
		if(ch[i].second==0){
			pa=(pa+1)%siz[a];
			pta=ch[i].first;
			diff=vp[a][pa]-vp[b][pb];
			diff=diff-(vp[b][(pb+1)%siz[b]]-vp[b][pb])*lena/(abs(vp[b][pb]-vp[b][(pb+1)%siz[b]])*lenb)*(ch[i].first-ptb);
		}else{
			pb=(pb+1)%siz[b];
			ptb=ch[i].first;
			diff=vp[a][pa]-vp[b][pb];
			diff=diff+(vp[a][(pa+1)%siz[a]]-vp[a][pa])/(abs(vp[a][pa]-vp[a][(pa+1)%siz[a]]))*(ch[i].first-pta);
		}
		prev=ch[i].first;
	}
	return false;
}

int main(void){
	double aa,bb,cc,dd;
	scanf("%d%lf%lf%lf%lf",&n,&aa,&bb,&cc,&dd);
	s.x=aa;
	s.y=bb;
	e.x=cc;
	e.y=dd;
	for(int i=0;i<n;i++){
		scanf("%lf%d",&aa,&siz[i]);
		r[i]=aa;
		for(int j=0;j<siz[i];j++){
			Point p;
			scanf("%lf%lf",&aa,&bb);
			p.x=aa;
			p.y=bb;
			vp[i].push_back(p);
		}
	}
	for(int i=0;i<n;i++){
		bool flag=false;
		for(int j=0;j<siz[i];j++){
			if(getDistanceSP(Segment(vp[i][j],vp[i][(j+1)%siz[i]]),s)<=r[i])flag=true;
		}
		if(flag)G[n].push_back(i);
	}
	for(int i=0;i<n;i++){
		bool flag=false;
		for(int j=0;j<siz[i];j++){
			if(getDistanceSP(Segment(vp[i][j],vp[i][(j+1)%siz[i]]),e)<=r[i])flag=true;
		}
		if(flag)G[i].push_back(n+1);
	}
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(check(i,j)){
				G[i].push_back(j);
				G[j].push_back(i);
			}
		}
	}
	dfs(n);
	printf("%s\n",used[n+1]?"Yes":"No");
	return 0;
}
accuracy: 0.7027027027027027
time_ms: 760
memory_kb: 3420
final_rank: 18

code_snippet: #include <bits/stdc++.h>
#define MOD 1000000007LL
#define EPS 1e-10
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<long double,int> DP;

long double add(long double a,long double b){
	if(abs(a+b)<EPS*(abs(a)+abs(b)))return 0.0;
	return a+b;
}

class Point{
public:
	long double x,y;
	Point(){}
	Point(long double xx,long double yy){
		x=xx;
		y=yy;
	}
	Point operator +(Point p){
		return Point(x+p.x,y+p.y);
	}
	Point operator -(Point p){
		return Point(x-p.x,y-p.y);
	}
	Point operator *(long double a){
		return Point(a*x,a*y);
	}
	Point operator /(long double a){
		return Point(x/a,y/a);
	}
	long double abs(){
		return sqrt(norm());
	}

	long double norm(){
		return x*x+y*y;
	}
};

typedef Point Vector;
struct Segment{
	Point p1,p2;
	Segment(){}
	Segment(Point pp1,Point pp2){
		p1=pp1;
		p2=pp2;
	}
};

typedef Segment Line;

long double norm(Vector v){
	return v.x*v.x+v.y*v.y;
}

long double abs(Vector v){
	return sqrt(norm(v));
}

long double dot(Vector a,Vector b){
	return a.x*b.x+a.y*b.y;
}

long double cross(Vector a,Vector b){
	return a.x*b.y-a.y*b.x;
}

long double getDistance(Point a,Point b){
	return abs(a-b);
}

long double getDistanceLP(Line l,Point p){
	return abs(cross(l.p2-l.p1,p-l.p1))/abs(l.p2-l.p1);
}

long double getDistanceSP(Segment s,Point p){
	if(dot(s.p2-s.p1,p-s.p1)<0.0)return abs(p-s.p1);
	if(dot(s.p1-s.p2,p-s.p2)<0.0)return abs(p-s.p2);
	return getDistanceLP(s,p);
}

int n;
Point s,e;
vector<int> G[105];
long double r[105];
int siz[105];
vector<Point> vp[105];
bool used[105];

long double abs(long double v){
	if(v<0.0)return -v;
	return v;
}

void dfs(int v){
	used[v]=true;
	for(int i=0;i<G[v].size();i++){
		int nv=G[v][i];
		if(!used[nv])dfs(nv);
	}
}

long double C(long double sec,Vector a,Vector d){
	a=a+d*sec;
	return abs(a);
}

bool check(int a,int b){
	long double lena=0;
	long double lenb=0;
	for(int i=0;i<siz[a];i++){
		lena+=abs(vp[a][i]-vp[a][(i+1)%siz[a]]);
	}
	for(int i=0;i<siz[b];i++){
		lenb+=abs(vp[b][i]-vp[b][(i+1)%siz[b]]);
	}
	vector<DP> ch;
	Point diff=vp[a][0]-vp[b][0];
	if(abs(diff)<=r[a]+r[b])return true;
	long double cur=0;
	for(int i=0;i<siz[a];i++){
		cur+=abs(vp[a][i]-vp[a][(i+1)%siz[a]]);
		ch.push_back(DP(cur,0));
	}
	cur=0;
	for(int i=0;i<siz[b];i++){
		cur+=abs(vp[b][i]-vp[b][(i+1)%siz[b]]);
		ch.push_back(DP(cur*lena/lenb,1));
	}
	sort(ch.begin(),ch.end());
	int pa=0,pb=0;
	long double prev=0.0;
	for(int i=0;i<ch.size();i++){
		Vector di=(vp[a][(pa+1)%siz[a]]-vp[a][pa])/(abs(vp[a][pa]-vp[a][(pa+1)%siz[a]]));
		di=di-(vp[b][(pb+1)%siz[b]]-vp[b][pb])*lena/(abs(vp[b][pb]-vp[b][(pb+1)%siz[b]])*lenb);
		long double vl=0.0;
		long double vr=ch[i].first-prev;
		for(int k=0;k<100;k++){
			long double midl=(vl*2.0+vr)/3;
			long double midr=(vl+vr*2.0)/3;
			if(C(midl,diff,di)<C(midr,diff,di)){
				vr=midr;
			}else{
				vl=midl;
			}
		}
		if(C(vl,diff,di)<=r[a]+r[b])return true;
		diff=diff+di*(ch[i].first-prev);
		if(ch[i].second==0){
			pa=(pa+1)%siz[a];
		}else{
			pb=(pb+1)%siz[b];
		}
		prev=ch[i].first;
	}
	return false;
}

int main(void){
	double aa,bb,cc,dd;
	scanf("%d%lf%lf%lf%lf",&n,&aa,&bb,&cc,&dd);
	s.x=aa;
	s.y=bb;
	e.x=cc;
	e.y=dd;
	for(int i=0;i<n;i++){
		scanf("%lf%d",&aa,&siz[i]);
		r[i]=aa;
		for(int j=0;j<siz[i];j++){
			Point p;
			scanf("%lf%lf",&aa,&bb);
			p.x=aa;
			p.y=bb;
			vp[i].push_back(p);
		}
	}
	for(int i=0;i<n;i++){
		bool flag=false;
		for(int j=0;j<siz[i];j++){
			if(getDistanceSP(Segment(vp[i][j],vp[i][(j+1)%siz[i]]),s)<=r[i])flag=true;
		}
		if(flag)G[n].push_back(i);
	}
	for(int i=0;i<n;i++){
		bool flag=false;
		for(int j=0;j<siz[i];j++){
			if(getDistanceSP(Segment(vp[i][j],vp[i][(j+1)%siz[i]]),e)<=r[i])flag=true;
		}
		if(flag)G[i].push_back(n+1);
	}
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(check(i,j)){
				G[i].push_back(j);
				G[j].push_back(i);
			}
		}
	}
	dfs(n);
	printf("%s\n",used[n+1]?"Yes":"No");
	return 0;
}
accuracy: 0.7162162162162162
time_ms: 260
memory_kb: 3428
final_rank: 9

code_snippet: #include <bits/stdc++.h>
#define MOD 1000000007LL
#define EPS 1e-10
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<long double,int> DP;

long double add(long double a,long double b){
	if(abs(a+b)<EPS*(abs(a)+abs(b)))return 0.0;
	return a+b;
}

class Point{
public:
	long double x,y;
	Point(){}
	Point(long double xx,long double yy){
		x=xx;
		y=yy;
	}
	Point operator +(Point p){
		return Point(add(x,p.x),add(y,p.y));
	}
	Point operator -(Point p){
		return Point(add(x,-p.x),add(y,-p.y));
	}
	Point operator *(long double a){
		return Point(a*x,a*y);
	}
	Point operator /(long double a){
		return Point(x/a,y/a);
	}
	long double abs(){
		return sqrt(norm());
	}

	long double norm(){
		return x*x+y*y;
	}
};

typedef Point Vector;
struct Segment{
	Point p1,p2;
	Segment(){}
	Segment(Point pp1,Point pp2){
		p1=pp1;
		p2=pp2;
	}
};

typedef Segment Line;

long double norm(Vector v){
	return v.x*v.x+v.y*v.y;
}

long double abs(Vector v){
	return sqrt(norm(v));
}

long double dot(Vector a,Vector b){
	return a.x*b.x+a.y*b.y;
}

long double cross(Vector a,Vector b){
	return a.x*b.y-a.y*b.x;
}

long double getDistance(Point a,Point b){
	return abs(a-b);
}

long double getDistanceLP(Line l,Point p){
	return abs(cross(l.p2-l.p1,p-l.p1))/abs(l.p2-l.p1);
}

long double getDistanceSP(Segment s,Point p){
	if(dot(s.p2-s.p1,p-s.p1)<0.0)return abs(p-s.p1);
	if(dot(s.p1-s.p2,p-s.p2)<0.0)return abs(p-s.p2);
	return getDistanceLP(s,p);
}

int n;
Point s,e;
vector<int> G[105];
long double r[105];
int siz[105];
vector<Point> vp[105];
bool used[105];

void dfs(int v){
	used[v]=true;
	for(int i=0;i<G[v].size();i++){
		int nv=G[v][i];
		if(!used[nv])dfs(nv);
	}
}

long double C(long double sec,Vector a,Vector d){
	a=a+d*sec;
	return abs(a);
}

bool check(int a,int b){
	long double lena=0;
	long double lenb=0;
	for(int i=0;i<siz[a];i++){
		lena+=abs(vp[a][i]-vp[a][(i+1)%siz[a]]);
	}
	for(int i=0;i<siz[b];i++){
		lenb+=abs(vp[b][i]-vp[b][(i+1)%siz[b]]);
	}
	vector<DP> ch;
	Point diff=vp[a][0]-vp[b][0];
	if(abs(diff)<=r[a]+r[b])return true;
	long double cur=0;
	for(int i=0;i<siz[a];i++){
		cur+=abs(vp[a][i]-vp[a][(i+1)%siz[a]]);
		ch.push_back(DP(cur,0));
	}
	cur=0;
	for(int i=0;i<siz[b];i++){
		cur+=abs(vp[b][i]-vp[b][(i+1)%siz[b]]);
		ch.push_back(DP(cur*lena/lenb,1));
	}
	sort(ch.begin(),ch.end());
	int pa=0,pb=0;
	long double prev=0.0;
	for(int i=0;i<ch.size();i++){
		Vector di=(vp[a][(pa+1)%siz[a]]-vp[a][pa])/(abs(vp[a][pa]-vp[a][(pa+1)%siz[a]]));
		di=di-(vp[b][(pb+1)%siz[b]]-vp[b][pb])*lena/(abs(vp[b][pb]-vp[b][(pb+1)%siz[b]])*lenb);
		long double vl=0.0;
		long double vr=ch[i].first-prev;
		for(int k=0;k<100;k++){
			long double midl=(vl*2.0+vr)/3;
			long double midr=(vl+vr*2.0)/3;
			if(C(midl,diff,di)<C(midr,diff,di)){
				vr=midr;
			}else{
				vl=midl;
			}
		}
		if(C(vl,diff,di)<=r[a]+r[b])return true;
		diff=diff+di*(ch[i].first-prev);
		if(ch[i].second==0){
			pa=(pa+1)%siz[a];
		}else{
			pb=(pb+1)%siz[b];
		}
		prev=ch[i].first;
	}
	return false;
}

int main(void){
	double aa,bb,cc,dd;
	scanf("%d%lf%lf%lf%lf",&n,&aa,&bb,&cc,&dd);
	s.x=aa;
	s.y=bb;
	e.x=cc;
	e.y=dd;
	for(int i=0;i<n;i++){
		scanf("%lf%d",&aa,&siz[i]);
		r[i]=aa;
		for(int j=0;j<siz[i];j++){
			Point p;
			scanf("%lf%lf",&aa,&bb);
			p.x=aa;
			p.y=bb;
			vp[i].push_back(p);
		}
	}
	for(int i=0;i<n;i++){
		bool flag=false;
		for(int j=0;j<siz[i];j++){
			if(getDistanceSP(Segment(vp[i][j],vp[i][(j+1)%siz[i]]),s)<=r[i])flag=true;
		}
		if(flag)G[n].push_back(i);
	}
	for(int i=0;i<n;i++){
		bool flag=false;
		for(int j=0;j<siz[i];j++){
			if(getDistanceSP(Segment(vp[i][j],vp[i][(j+1)%siz[i]]),e)<=r[i])flag=true;
		}
		if(flag)G[i].push_back(n+1);
	}
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(check(i,j)){
				G[i].push_back(j);
				G[j].push_back(i);
			}
		}
	}
	dfs(n);
	printf("%s\n",used[n+1]?"Yes":"No");
	return 0;
}
accuracy: 0.7162162162162162
time_ms: 420
memory_kb: 3412
final_rank: 11

code_snippet: #include <bits/stdc++.h>
#define MOD 1000000007LL
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<long double,int> DP;

long double add(long double a,long double b){
	if(abs(a+b)<EPS*(abs(a)+abs(b)))return 0.0;
	return a+b;
}

class Point{
public:
	long double x,y;
	Point(){}
	Point(long double xx,long double yy){
		x=xx;
		y=yy;
	}
	Point operator +(Point p){
		return Point(add(x,p.x),add(y,p.y));
	}
	Point operator -(Point p){
		return Point(add(x,-p.x),add(y,-p.y));
	}
	Point operator *(long double a){
		return Point(a*x,a*y);
	}
	Point operator /(long double a){
		return Point(x/a,y/a);
	}
	long double abs(){
		return sqrt(norm());
	}

	long double norm(){
		return x*x+y*y;
	}
};

typedef Point Vector;
struct Segment{
	Point p1,p2;
	Segment(){}
	Segment(Point pp1,Point pp2){
		p1=pp1;
		p2=pp2;
	}
};

typedef Segment Line;

long double norm(Vector v){
	return v.x*v.x+v.y*v.y;
}

long double abs(Vector v){
	return sqrt(norm(v));
}

long double dot(Vector a,Vector b){
	return a.x*b.x+a.y*b.y;
}

long double cross(Vector a,Vector b){
	return a.x*b.y-a.y*b.x;
}

long double getDistance(Point a,Point b){
	return abs(a-b);
}

long double getDistanceLP(Line l,Point p){
	return abs(cross(l.p2-l.p1,p-l.p1))/abs(l.p2-l.p1);
}

long double getDistanceSP(Segment s,Point p){
	if(dot(s.p2-s.p1,p-s.p1)<0.0)return abs(p-s.p1);
	if(dot(s.p1-s.p2,p-s.p2)<0.0)return abs(p-s.p2);
	return getDistanceLP(s,p);
}

int n;
Point s,e;
vector<int> G[105];
long double r[105];
int siz[105];
vector<Point> vp[105];
bool used[105];

void dfs(int v){
	used[v]=true;
	for(int i=0;i<G[v].size();i++){
		int nv=G[v][i];
		if(!used[nv])dfs(nv);
	}
}

long double C(long double sec,Vector a,Vector d){
	a=a+d*sec;
	return abs(a);
}

bool check(int a,int b){
	long double lena=0;
	long double lenb=0;
	for(int i=0;i<siz[a];i++){
		lena+=abs(vp[a][i]-vp[a][(i+1)%siz[a]]);
	}
	for(int i=0;i<siz[b];i++){
		lenb+=abs(vp[b][i]-vp[b][(i+1)%siz[b]]);
	}
	vector<DP> ch;
	Point diff=vp[a][0]-vp[b][0];
	if(abs(diff)<=r[a]+r[b])return true;
	long double cur=0;
	for(int i=0;i<siz[a];i++){
		cur+=abs(vp[a][i]-vp[a][(i+1)%siz[a]]);
		ch.push_back(DP(cur,0));
	}
	cur=0;
	for(int i=0;i<siz[b];i++){
		cur+=abs(vp[b][i]-vp[b][(i+1)%siz[b]]);
		ch.push_back(DP(cur*lena/lenb,1));
	}
	sort(ch.begin(),ch.end());
	int pa=0,pb=0;
	long double prev=0.0;
	for(int i=0;i<ch.size();i++){
		Vector di=(vp[a][(pa+1)%siz[a]]-vp[a][pa])/(abs(vp[a][pa]-vp[a][(pa+1)%siz[a]]));
		di=di-(vp[b][(pb+1)%siz[b]]-vp[b][pb])*lena/(abs(vp[b][pb]-vp[b][(pb+1)%siz[b]])*lenb);
		long double vl=0.0;
		long double vr=ch[i].first-prev;
		for(int k=0;k<100;k++){
			long double midl=(vl*2.0+vr)/3;
			long double midr=(vl+vr*2.0)/3;
			if(C(midl,diff,di)<C(midr,diff,di)){
				vr=midr;
			}else{
				vl=midl;
			}
		}
		if(C(vl,diff,di)<=r[a]+r[b])return true;
		diff=diff+di*(ch[i].first-prev);
		if(ch[i].second==0){
			pa=(pa+1)%siz[a];
		}else{
			pb=(pb+1)%siz[b];
		}
		prev=ch[i].first;
	}
	return false;
}

int main(void){
	double aa,bb,cc,dd;
	scanf("%d%lf%lf%lf%lf",&n,&aa,&bb,&cc,&dd);
	s.x=aa;
	s.y=bb;
	e.x=cc;
	e.y=dd;
	for(int i=0;i<n;i++){
		scanf("%lf%d",&aa,&siz[i]);
		r[i]=aa;
		for(int j=0;j<siz[i];j++){
			Point p;
			scanf("%lf%lf",&aa,&bb);
			p.x=aa;
			p.y=bb;
			vp[i].push_back(p);
		}
	}
	for(int i=0;i<n;i++){
		bool flag=false;
		for(int j=0;j<siz[i];j++){
			if(getDistanceSP(Segment(vp[i][j],vp[i][(j+1)%siz[i]]),s)<=r[i])flag=true;
		}
		if(flag)G[n].push_back(i);
	}
	for(int i=0;i<n;i++){
		bool flag=false;
		for(int j=0;j<siz[i];j++){
			if(getDistanceSP(Segment(vp[i][j],vp[i][(j+1)%siz[i]]),e)<=r[i])flag=true;
		}
		if(flag)G[i].push_back(n+1);
	}
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(check(i,j)){
				G[i].push_back(j);
				G[j].push_back(i);
			}
		}
	}
	dfs(n);
	printf("%s\n",used[n+1]?"Yes":"No");
	return 0;
}
accuracy: 0.7162162162162162
time_ms: 420
memory_kb: 3392
final_rank: 10

code_snippet: #include <bits/stdc++.h>
#define MOD 1000000007LL
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<long double,int> DP;

long double add(long double a,long double b){
	if(abs(a+b)<EPS*(abs(a)+abs(b)))return 0.0;
	return a+b;
}

class Point{
public:
	long double x,y;
	Point(){}
	Point(long double xx,long double yy){
		x=xx;
		y=yy;
	}
	Point operator +(Point p){
		return Point(x+p.x,y+p.y);
	}
	Point operator -(Point p){
		return Point(x-p.x,y-p.y);
	}
	Point operator *(long double a){
		return Point(a*x,a*y);
	}
	Point operator /(long double a){
		return Point(x/a,y/a);
	}
	long double abs(){
		return sqrt(norm());
	}

	long double norm(){
		return x*x+y*y;
	}
};

typedef Point Vector;
struct Segment{
	Point p1,p2;
	Segment(){}
	Segment(Point pp1,Point pp2){
		p1=pp1;
		p2=pp2;
	}
};

typedef Segment Line;

long double norm(Vector v){
	return v.x*v.x+v.y*v.y;
}

long double abs(Vector v){
	return sqrt(norm(v));
}

long double dot(Vector a,Vector b){
	return a.x*b.x+a.y*b.y;
}

long double cross(Vector a,Vector b){
	return a.x*b.y-a.y*b.x;
}

long double getDistance(Point a,Point b){
	return abs(a-b);
}

long double getDistanceLP(Line l,Point p){
	return abs(cross(l.p2-l.p1,p-l.p1))/abs(l.p2-l.p1);
}

long double getDistanceSP(Segment s,Point p){
	if(dot(s.p2-s.p1,p-s.p1)<0.0)return abs(p-s.p1);
	if(dot(s.p1-s.p2,p-s.p2)<0.0)return abs(p-s.p2);
	return getDistanceLP(s,p);
}

int n;
Point s,e;
vector<int> G[105];
long double r[105];
int siz[105];
vector<Point> vp[105];
bool used[105];

void dfs(int v){
	used[v]=true;
	for(int i=0;i<G[v].size();i++){
		int nv=G[v][i];
		if(!used[nv])dfs(nv);
	}
}

long double C(long double sec,Vector a,Vector d){
	a=a+d*sec;
	return abs(a);
}

bool check(int a,int b){
	long double lena=0;
	long double lenb=0;
	for(int i=0;i<siz[a];i++){
		lena+=abs(vp[a][i]-vp[a][(i+1)%siz[a]]);
	}
	for(int i=0;i<siz[b];i++){
		lenb+=abs(vp[b][i]-vp[b][(i+1)%siz[b]]);
	}
	vector<DP> ch;
	Point diff=vp[a][0]-vp[b][0];
	if(abs(diff)<=r[a]+r[b])return true;
	long double cur=0;
	for(int i=0;i<siz[a];i++){
		cur+=abs(vp[a][i]-vp[a][(i+1)%siz[a]]);
		ch.push_back(DP(cur,0));
	}
	cur=0;
	for(int i=0;i<siz[b];i++){
		cur+=abs(vp[b][i]-vp[b][(i+1)%siz[b]]);
		ch.push_back(DP(cur*lena/lenb,1));
	}
	sort(ch.begin(),ch.end());
	int pa=0,pb=0;
	long double prev=0.0;
	for(int i=0;i<ch.size();i++){
		Vector di=(vp[a][(pa+1)%siz[a]]-vp[a][pa])/(abs(vp[a][pa]-vp[a][(pa+1)%siz[a]]));
		di=di-(vp[b][(pb+1)%siz[b]]-vp[b][pb])*lena/(abs(vp[b][pb]-vp[b][(pb+1)%siz[b]])*lenb);
		long double vl=0.0;
		long double vr=ch[i].first-prev;
		for(int k=0;k<500;k++){
			long double midl=(vl*2.0+vr)/3;
			long double midr=(vl+vr*2.0)/3;
			if(C(midl,diff,di)<C(midr,diff,di)){
				vr=midr;
			}else{
				vl=midl;
			}
		}
		if(C(vl,diff,di)<=r[a]+r[b])return true;
		diff=diff+di*(ch[i].first-prev);
		if(ch[i].second==0){
			pa=(pa+1)%siz[a];
		}else{
			pb=(pb+1)%siz[b];
		}
		prev=ch[i].first;
	}
	return false;
}

int main(void){
	double aa,bb,cc,dd;
	scanf("%d%lf%lf%lf%lf",&n,&aa,&bb,&cc,&dd);
	s.x=aa;
	s.y=bb;
	e.x=cc;
	e.y=dd;
	for(int i=0;i<n;i++){
		scanf("%lf%d",&aa,&siz[i]);
		r[i]=aa;
		for(int j=0;j<siz[i];j++){
			Point p;
			scanf("%lf%lf",&aa,&bb);
			p.x=aa;
			p.y=bb;
			vp[i].push_back(p);
		}
	}
	for(int i=0;i<n;i++){
		bool flag=false;
		for(int j=0;j<siz[i];j++){
			if(getDistanceSP(Segment(vp[i][j],vp[i][(j+1)%siz[i]]),s)<=r[i])flag=true;
		}
		if(flag)G[n].push_back(i);
	}
	for(int i=0;i<n;i++){
		bool flag=false;
		for(int j=0;j<siz[i];j++){
			if(getDistanceSP(Segment(vp[i][j],vp[i][(j+1)%siz[i]]),e)<=r[i])flag=true;
		}
		if(flag)G[i].push_back(n+1);
	}
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(check(i,j)){
				G[i].push_back(j);
				G[j].push_back(i);
			}
		}
	}
	dfs(n);
	printf("%s\n",used[n+1]?"Yes":"No");
	return 0;
}
accuracy: 0.7162162162162162
time_ms: 1250
memory_kb: 3404
final_rank: 14

code_snippet: #include <bits/stdc++.h>
#define MOD 1000000007LL
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<long double,int> DP;

long double add(long double a,long double b){
	if(abs(a+b)<EPS*(abs(a)+abs(b)))return 0.0;
	return a+b;
}

class Point{
public:
	long double x,y;
	Point(){}
	Point(long double xx,long double yy){
		x=xx;
		y=yy;
	}
	Point operator +(Point p){
		return Point(x+p.x,y+p.y);
	}
	Point operator -(Point p){
		return Point(x-p.x,y-p.y);
	}
	Point operator *(long double a){
		return Point(a*x,a*y);
	}
	Point operator /(long double a){
		return Point(x/a,y/a);
	}
	long double abs(){
		return sqrt(norm());
	}

	long double norm(){
		return x*x+y*y;
	}
};

typedef Point Vector;
struct Segment{
	Point p1,p2;
	Segment(){}
	Segment(Point pp1,Point pp2){
		p1=pp1;
		p2=pp2;
	}
};

typedef Segment Line;

long double norm(Vector v){
	return v.x*v.x+v.y*v.y;
}

long double abs(Vector v){
	return sqrt(norm(v));
}

long double dot(Vector a,Vector b){
	return add(a.x*b.x,a.y*b.y);
}

long double cross(Vector a,Vector b){
	return add(a.x*b.y,-a.y*b.x);
}

long double getDistance(Point a,Point b){
	return abs(a-b);
}

long double getDistanceLP(Line l,Point p){
	return abs(cross(l.p2-l.p1,p-l.p1))/abs(l.p2-l.p1);
}

long double getDistanceSP(Segment s,Point p){
	if(dot(s.p2-s.p1,p-s.p1)<0.0)return abs(p-s.p1);
	if(dot(s.p1-s.p2,p-s.p2)<0.0)return abs(p-s.p2);
	return getDistanceLP(s,p);
}

int n;
Point s,e;
vector<int> G[105];
long double r[105];
int siz[105];
vector<Point> vp[105];
bool used[105];

void dfs(int v){
	used[v]=true;
	for(int i=0;i<G[v].size();i++){
		int nv=G[v][i];
		if(!used[nv])dfs(nv);
	}
}

long double C(long double sec,Vector a,Vector d){
	a=a+d*sec;
	return abs(a);
}

bool check(int a,int b){
	long double lena=0;
	long double lenb=0;
	for(int i=0;i<siz[a];i++){
		lena+=abs(vp[a][i]-vp[a][(i+1)%siz[a]]);
	}
	for(int i=0;i<siz[b];i++){
		lenb+=abs(vp[b][i]-vp[b][(i+1)%siz[b]]);
	}
	vector<DP> ch;
	Point diff=vp[a][0]-vp[b][0];
	if(abs(diff)<=r[a]+r[b])return true;
	long double cur=0;
	for(int i=0;i<siz[a];i++){
		cur+=abs(vp[a][i]-vp[a][(i+1)%siz[a]]);
		ch.push_back(DP(cur,0));
	}
	cur=0;
	for(int i=0;i<siz[b];i++){
		cur+=abs(vp[b][i]-vp[b][(i+1)%siz[b]]);
		ch.push_back(DP(cur*lena/lenb,1));
	}
	sort(ch.begin(),ch.end());
	int pa=0,pb=0;
	long double prev=0.0;
	for(int i=0;i<ch.size();i++){
		Vector di=(vp[a][(pa+1)%siz[a]]-vp[a][pa])/(abs(vp[a][pa]-vp[a][(pa+1)%siz[a]]));
		di=di-(vp[b][(pb+1)%siz[b]]-vp[b][pb])*lena/(abs(vp[b][pb]-vp[b][(pb+1)%siz[b]])*lenb);
		long double vl=0.0;
		long double vr=ch[i].first-prev;
		for(int k=0;k<500;k++){
			long double midl=(vl*2.0+vr)/3;
			long double midr=(vl+vr*2.0)/3;
			if(C(midl,diff,di)<C(midr,diff,di)){
				vr=midr;
			}else{
				vl=midl;
			}
		}
		if(C(vl,diff,di)<=r[a]+r[b])return true;
		diff=diff+di*(ch[i].first-prev);
		if(ch[i].second==0){
			pa=(pa+1)%siz[a];
		}else{
			pb=(pb+1)%siz[b];
		}
		prev=ch[i].first;
	}
	return false;
}

int main(void){
	double aa,bb,cc,dd;
	scanf("%d%lf%lf%lf%lf",&n,&aa,&bb,&cc,&dd);
	s.x=aa;
	s.y=bb;
	e.x=cc;
	e.y=dd;
	for(int i=0;i<n;i++){
		scanf("%lf%d",&aa,&siz[i]);
		r[i]=aa;
		for(int j=0;j<siz[i];j++){
			Point p;
			scanf("%lf%lf",&aa,&bb);
			p.x=aa;
			p.y=bb;
			vp[i].push_back(p);
		}
	}
	for(int i=0;i<n;i++){
		bool flag=false;
		for(int j=0;j<siz[i];j++){
			if(getDistanceSP(Segment(vp[i][j],vp[i][(j+1)%siz[i]]),s)<=r[i])flag=true;
		}
		if(flag)G[n].push_back(i);
	}
	for(int i=0;i<n;i++){
		bool flag=false;
		for(int j=0;j<siz[i];j++){
			if(getDistanceSP(Segment(vp[i][j],vp[i][(j+1)%siz[i]]),e)<=r[i])flag=true;
		}
		if(flag)G[i].push_back(n+1);
	}
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(check(i,j)){
				G[i].push_back(j);
				G[j].push_back(i);
			}
		}
	}
	dfs(n);
	printf("%s\n",used[n+1]?"Yes":"No");
	return 0;
}
accuracy: 0.7162162162162162
time_ms: 1250
memory_kb: 3396
final_rank: 13

code_snippet: #include <bits/stdc++.h>
#define MOD 1000000007LL
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<long double,int> DP;

long double add(long double a,long double b){
	if(abs(a+b)<EPS*(abs(a)+abs(b)))return 0.0;
	return a+b;
}

class Point{
public:
	long double x,y;
	Point(){}
	Point(long double xx,long double yy){
		x=xx;
		y=yy;
	}
	Point operator +(Point p){
		return Point(x+p.x,y+p.y);
	}
	Point operator -(Point p){
		return Point(x-p.x,y-p.y);
	}
	Point operator *(long double a){
		return Point(a*x,a*y);
	}
	Point operator /(long double a){
		return Point(x/a,y/a);
	}
	long double abs(){
		return sqrt(norm());
	}

	long double norm(){
		return x*x+y*y;
	}
};

typedef Point Vector;
struct Segment{
	Point p1,p2;
	Segment(){}
	Segment(Point pp1,Point pp2){
		p1=pp1;
		p2=pp2;
	}
};

typedef Segment Line;

long double norm(Vector v){
	return v.x*v.x+v.y*v.y;
}

long double abs(Vector v){
	return sqrt(norm(v));
}

long double dot(Vector a,Vector b){
	return add(a.x*b.x,a.y*b.y);
}

long double cross(Vector a,Vector b){
	return add(a.x*b.y,-a.y*b.x);
}

long double getDistance(Point a,Point b){
	return abs(a-b);
}

long double getDistanceLP(Line l,Point p){
	return abs(cross(l.p2-l.p1,p-l.p1))/abs(l.p2-l.p1);
}

long double getDistanceSP(Segment s,Point p){
	if(dot(s.p2-s.p1,p-s.p1)<0.0)return abs(p-s.p1);
	if(dot(s.p1-s.p2,p-s.p2)<0.0)return abs(p-s.p2);
	return getDistanceLP(s,p);
}

int n;
Point s,e;
vector<int> G[105];
long double r[105];
int siz[105];
vector<Point> vp[105];
bool used[105];

void dfs(int v){
	used[v]=true;
	for(int i=0;i<G[v].size();i++){
		int nv=G[v][i];
		if(!used[nv])dfs(nv);
	}
}

long double C(long double sec,Vector a,Vector d){
	a=a+d*sec;
	return abs(a);
}

bool check(int a,int b){
	long double lena=0;
	long double lenb=0;
	for(int i=0;i<siz[a];i++){
		lena+=abs(vp[a][i]-vp[a][(i+1)%siz[a]]);
	}
	for(int i=0;i<siz[b];i++){
		lenb+=abs(vp[b][i]-vp[b][(i+1)%siz[b]]);
	}
	vector<DP> ch;
	Point diff=vp[a][0]-vp[b][0];
	if(abs(diff)<=r[a]+r[b])return true;
	long double cur=0;
	for(int i=0;i<siz[a];i++){
		cur+=abs(vp[a][i]-vp[a][(i+1)%siz[a]]);
		ch.push_back(DP(cur,0));
	}
	cur=0;
	for(int i=0;i<siz[b];i++){
		cur+=abs(vp[b][i]-vp[b][(i+1)%siz[b]]);
		ch.push_back(DP(cur*lena/lenb,1));
	}
	sort(ch.begin(),ch.end());
	int pa=0,pb=0;
	long double prev=0.0;
	for(int i=0;i<ch.size();i++){
		Vector di=(vp[a][(pa+1)%siz[a]]-vp[a][pa])/(abs(vp[a][pa]-vp[a][(pa+1)%siz[a]]));
		di=di-(vp[b][(pb+1)%siz[b]]-vp[b][pb])*lena/(abs(vp[b][pb]-vp[b][(pb+1)%siz[b]])*lenb);
		long double vl=0.0;
		long double vr=ch[i].first-prev;
		for(int k=0;k<200;k++){
			long double midl=(vl*2.0+vr)/3;
			long double midr=(vl+vr*2.0)/3;
			if(C(midl,diff,di)<C(midr,diff,di)){
				vr=midr;
			}else{
				vl=midl;
			}
		}
		if(C(vl,diff,di)<=r[a]+r[b])return true;
		diff=diff+di*(ch[i].first-prev);
		if(ch[i].second==0){
			pa=(pa+1)%siz[a];
		}else{
			pb=(pb+1)%siz[b];
		}
		prev=ch[i].first;
	}
	return false;
}

int main(void){
	double aa,bb,cc,dd;
	scanf("%d%lf%lf%lf%lf",&n,&aa,&bb,&cc,&dd);
	s.x=aa;
	s.y=bb;
	e.x=cc;
	e.y=dd;
	for(int i=0;i<n;i++){
		scanf("%lf%d",&aa,&siz[i]);
		r[i]=aa;
		for(int j=0;j<siz[i];j++){
			Point p;
			scanf("%lf%lf",&aa,&bb);
			p.x=aa;
			p.y=bb;
			vp[i].push_back(p);
		}
	}
	for(int i=0;i<n;i++){
		bool flag=false;
		for(int j=0;j<siz[i];j++){
			if(getDistanceSP(Segment(vp[i][j],vp[i][(j+1)%siz[i]]),s)<=r[i])flag=true;
		}
		if(flag)G[n].push_back(i);
	}
	for(int i=0;i<n;i++){
		bool flag=false;
		for(int j=0;j<siz[i];j++){
			if(getDistanceSP(Segment(vp[i][j],vp[i][(j+1)%siz[i]]),e)<=r[i])flag=true;
		}
		if(flag)G[i].push_back(n+1);
	}
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(check(i,j)){
				G[i].push_back(j);
				G[j].push_back(i);
			}
		}
	}
	dfs(n);
	printf("%s\n",used[n+1]?"Yes":"No");
	return 0;
}
accuracy: 0.7162162162162162
time_ms: 510
memory_kb: 3424
final_rank: 12

code_snippet: #include <bits/stdc++.h>
#define MOD 1000000007LL
#define EPS 1e-10
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<long double,int> DP;

long double add(long double a,long double b){
	if(abs(a+b)<EPS*(abs(a)+abs(b)))return 0.0;
	return a+b;
}

class Point{
public:
	long double x,y;
	Point(){}
	Point(long double xx,long double yy){
		x=xx;
		y=yy;
	}
	Point operator +(Point p){
		return Point(x+p.x,y+p.y);
	}
	Point operator -(Point p){
		return Point(x-p.x,y-p.y);
	}
	Point operator *(long double a){
		return Point(a*x,a*y);
	}
	Point operator /(long double a){
		return Point(x/a,y/a);
	}
	long double abs(){
		return sqrt(norm());
	}

	long double norm(){
		return x*x+y*y;
	}
};

typedef Point Vector;
struct Segment{
	Point p1,p2;
	Segment(){}
	Segment(Point pp1,Point pp2){
		p1=pp1;
		p2=pp2;
	}
};

typedef Segment Line;

long double norm(Vector v){
	return v.x*v.x+v.y*v.y;
}

long double abs(Vector v){
	return sqrt(norm(v));
}

long double dot(Vector a,Vector b){
	return add(a.x*b.x,a.y*b.y);
}

long double cross(Vector a,Vector b){
	return add(a.x*b.y,-a.y*b.x);
}

long double getDistance(Point a,Point b){
	return abs(a-b);
}

long double getDistanceLP(Line l,Point p){
	return abs(cross(l.p2-l.p1,p-l.p1))/abs(l.p2-l.p1);
}

long double getDistanceSP(Segment s,Point p){
	if(dot(s.p2-s.p1,p-s.p1)<0.0)return abs(p-s.p1);
	if(dot(s.p1-s.p2,p-s.p2)<0.0)return abs(p-s.p2);
	return getDistanceLP(s,p);
}

int n;
Point s,e;
vector<int> G[105];
long double r[105];
int siz[105];
vector<Point> vp[105];
bool used[105];

void dfs(int v){
	used[v]=true;
	for(int i=0;i<G[v].size();i++){
		int nv=G[v][i];
		if(!used[nv])dfs(nv);
	}
}

long double C(long double sec,Vector a,Vector d){
	a=a+d*sec;
	return abs(a);
}

bool check(int a,int b){
	long double lena=0;
	long double lenb=0;
	for(int i=0;i<siz[a];i++){
		lena+=abs(vp[a][i]-vp[a][(i+1)%siz[a]]);
	}
	for(int i=0;i<siz[b];i++){
		lenb+=abs(vp[b][i]-vp[b][(i+1)%siz[b]]);
	}
	vector<DP> ch;
	Point diff=vp[a][0]-vp[b][0];
	if(abs(diff)<=r[a]+r[b])return true;
	long double cur=0;
	for(int i=0;i<siz[a];i++){
		cur+=abs(vp[a][i]-vp[a][(i+1)%siz[a]]);
		ch.push_back(DP(cur,0));
	}
	cur=0;
	for(int i=0;i<siz[b];i++){
		cur+=abs(vp[b][i]-vp[b][(i+1)%siz[b]]);
		ch.push_back(DP(cur*lena/lenb,1));
	}
	sort(ch.begin(),ch.end());
	int pa=0,pb=0;
	long double prev=0.0;
	long double pta=0.0;
	long double ptb=0.0;
	for(int i=0;i<ch.size();i++){
		Vector di=(vp[a][(pa+1)%siz[a]]-vp[a][pa])/(abs(vp[a][pa]-vp[a][(pa+1)%siz[a]]));
		di=di-(vp[b][(pb+1)%siz[b]]-vp[b][pb])*lena/(abs(vp[b][pb]-vp[b][(pb+1)%siz[b]])*lenb);
		long double vl=0.0;
		long double vr=ch[i].first-prev;
		for(int k=0;k<300;k++){
			long double midl=(vl*2.0+vr)/3;
			long double midr=(vl+vr*2.0)/3;
			if(C(midl,diff,di)<C(midr,diff,di)){
				vr=midr;
			}else{
				vl=midl;
			}
		}
		if(C(vl,diff,di)<=r[a]+r[b] || C(vr,diff,di)<=r[a]+r[b])return true;
		if(ch[i].second==0){
			pa=(pa+1)%siz[a];
			pta=ch[i].first;
			diff=vp[a][pa]-vp[b][pb];
			if(abs((vp[b][(pb+1)%siz[b]]-vp[b][pb])*lena/(abs(vp[b][pb]-vp[b][(pb+1)%siz[b]])*lenb)*(ch[i].first-ptb))>EPS)diff=diff-(vp[b][(pb+1)%siz[b]]-vp[b][pb])*lena/(abs(vp[b][pb]-vp[b][(pb+1)%siz[b]])*lenb)*(ch[i].first-ptb);
		}else{
			pb=(pb+1)%siz[b];
			ptb=ch[i].first;
			diff=vp[a][pa]-vp[b][pb];
			if(abs((vp[a][(pa+1)%siz[a]]-vp[a][pa])/(abs(vp[a][pa]-vp[a][(pa+1)%siz[a]]))*(ch[i].first-pta))>EPS)diff=diff+(vp[a][(pa+1)%siz[a]]-vp[a][pa])/(abs(vp[a][pa]-vp[a][(pa+1)%siz[a]]))*(ch[i].first-pta);
		}
		prev=ch[i].first;
	}
	return false;
}

int main(void){
	double aa,bb,cc,dd;
	scanf("%d%lf%lf%lf%lf",&n,&aa,&bb,&cc,&dd);
	s.x=aa;
	s.y=bb;
	e.x=cc;
	e.y=dd;
	for(int i=0;i<n;i++){
		scanf("%lf%d",&aa,&siz[i]);
		r[i]=aa;
		for(int j=0;j<siz[i];j++){
			Point p;
			scanf("%lf%lf",&aa,&bb);
			p.x=aa;
			p.y=bb;
			vp[i].push_back(p);
		}
	}
	for(int i=0;i<n;i++){
		bool flag=false;
		for(int j=0;j<siz[i];j++){
			if(getDistanceSP(Segment(vp[i][j],vp[i][(j+1)%siz[i]]),s)<=r[i])flag=true;
		}
		if(flag)G[n].push_back(i);
	}
	for(int i=0;i<n;i++){
		bool flag=false;
		for(int j=0;j<siz[i];j++){
			if(getDistanceSP(Segment(vp[i][j],vp[i][(j+1)%siz[i]]),e)<=r[i])flag=true;
		}
		if(flag)G[i].push_back(n+1);
	}
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(check(i,j)){
				G[i].push_back(j);
				G[j].push_back(i);
			}
		}
	}
	dfs(n);
	printf("%s\n",used[n+1]?"Yes":"No");
	return 0;
}
accuracy: 0.7027027027027027
time_ms: 760
memory_kb: 3428
final_rank: 19