QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#890166 | #9049. Machine Learning with Penguins | thinking (Fedor Romashov, Alexey Mikhnenko, Gimran Abdullin)# | WA | 501ms | 14404kb | C++20 | 57.3kb | 2025-02-08 20:31:46 | 2025-02-10 01:16:01 |
Judging History
This is the latest submission verdict.
- [2025-02-15 21:09:22]
- hack成功,自动添加数据
- (/hack/1559)
- [2025-02-10 01:12:50]
- hack成功,自动添加数据
- (/hack/1555)
- [2025-02-10 00:54:56]
- hack成功,自动添加数据
- (/hack/1553)
- [2025-02-08 20:31:46]
- Submitted
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define all(a) begin(a), end(a)
#define len(a) int((a).size())
#include<bits/stdc++.h>
using namespace std;
// https://victorlecomte.com/cp-geo.pdf
const int N = 3e5 + 9;
#define double ld
const double inf = 1e100;
const double eps = 1e-9;
const double PI = acos((double)-1.0);
int sign(double x) { return (x > eps) - (x < -eps); }
struct PT {
double x, y;
PT() { x = 0, y = 0; }
PT(double x, double y) : x(x), y(y) {}
PT(const PT &p) : x(p.x), y(p.y) {}
PT operator + (const PT &a) const { return PT(x + a.x, y + a.y); }
PT operator - (const PT &a) const { return PT(x - a.x, y - a.y); }
PT operator * (const double a) const { return PT(x * a, y * a); }
friend PT operator * (const double &a, const PT &b) { return PT(a * b.x, a * b.y); }
PT operator / (const double a) const { return PT(x / a, y / a); }
bool operator == (PT a) const { return sign(a.x - x) == 0 && sign(a.y - y) == 0; }
bool operator != (PT a) const { return !(*this == a); }
bool operator < (PT a) const { return sign(a.x - x) == 0 ? y < a.y : x < a.x; }
bool operator > (PT a) const { return sign(a.x - x) == 0 ? y > a.y : x > a.x; }
double norm() { return sqrtl(x * x + y * y); }
double norm2() { return x * x + y * y; }
PT perp() { return PT(-y, x); }
double arg() { return atan2(y, x); }
PT truncate(double r) { // returns a vector with norm r and having same direction
double k = norm();
if (!sign(k)) return *this;
r /= k;
return PT(x * r, y * r);
}
};
istream &operator >> (istream &in, PT &p) { return in >> p.x >> p.y; }
ostream &operator << (ostream &out, PT &p) { return out << "(" << p.x << "," << p.y << ")"; }
inline double dot(PT a, PT b) { return a.x * b.x + a.y * b.y; }
inline double dist2(PT a, PT b) { return dot(a - b, a - b); }
inline double dist(PT a, PT b) { return sqrt(dot(a - b, a - b)); }
inline double cross(PT a, PT b) { return a.x * b.y - a.y * b.x; }
inline double cross2(PT a, PT b, PT c) { return cross(b - a, c - a); }
inline int orientation(PT a, PT b, PT c) { return sign(cross(b - a, c - a)); }
PT perp(PT a) { return PT(-a.y, a.x); }
PT rotateccw90(PT a) { return PT(-a.y, a.x); }
PT rotatecw90(PT a) { return PT(a.y, -a.x); }
PT rotateccw(PT a, double t) { return PT(a.x * cos(t) - a.y * sin(t), a.x * sin(t) + a.y * cos(t)); }
PT rotatecw(PT a, double t) { return PT(a.x * cos(t) + a.y * sin(t), -a.x * sin(t) + a.y * cos(t)); }
double SQ(double x) { return x * x; }
double rad_to_deg(double r) { return (r * 180.0 / PI); }
double deg_to_rad(double d) { return (d * PI / 180.0); }
double get_angle(PT a, PT b) {
double costheta = dot(a, b) / a.norm() / b.norm();
return acos(max((double)-1.0, min((double)1.0, costheta)));
}
bool is_point_in_angle(PT b, PT a, PT c, PT p) { // does point p lie in angle <bac
assert(orientation(a, b, c) != 0);
if (orientation(a, c, b) < 0) swap(b, c);
return orientation(a, c, p) >= 0 && orientation(a, b, p) <= 0;
}
bool half(PT p) {
return p.y > 0.0 || (p.y == 0.0 && p.x < 0.0);
}
void polar_sort(vector<PT> &v) { // sort points in counterclockwise
sort(v.begin(), v.end(), [](PT a,PT b) {
return make_tuple(half(a), 0.0, a.norm2()) < make_tuple(half(b), cross(a, b), b.norm2());
});
}
void polar_sort(vector<PT> &v, PT o) { // sort points in counterclockwise with respect to point o
sort(v.begin(), v.end(), [&](PT a,PT b) {
return make_tuple(half(a - o), 0.0, (a - o).norm2()) < make_tuple(half(b - o), cross(a - o, b - o), (b - o).norm2());
});
}
struct line {
PT a, b; // goes through points a and b
PT v; double c; //line form: direction vec [cross] (x, y) = c
line() {}
//direction vector v and offset c
line(PT v, double c) : v(v), c(c) {
auto p = get_points();
a = p.first; b = p.second;
}
// equation ax + by + c = 0
line(double _a, double _b, double _c) : v({_b, -_a}), c(-_c) {
auto p = get_points();
a = p.first; b = p.second;
}
// goes through points p and q
line(PT p, PT q) : v(q - p), c(cross(v, p)), a(p), b(q) {}
pair<PT, PT> get_points() { //extract any two points from this line
PT p, q; double a = -v.y, b = v.x; // ax + by = c
if (sign(a) == 0) {
p = PT(0, c / b);
q = PT(1, c / b);
}
else if (sign(b) == 0) {
p = PT(c / a, 0);
q = PT(c / a, 1);
}
else {
p = PT(0, c / b);
q = PT(1, (c - a) / b);
}
return {p, q};
}
// ax + by + c = 0
array<double, 3> get_abc() {
double a = -v.y, b = v.x;
return {a, b, -c};
}
// 1 if on the left, -1 if on the right, 0 if on the line
int side(PT p) { return sign(cross(v, p) - c); }
// line that is perpendicular to this and goes through point p
line perpendicular_through(PT p) { return {p, p + perp(v)}; }
// translate the line by vector t i.e. shifting it by vector t
line translate(PT t) { return {v, c + cross(v, t)}; }
// compare two points by their orthogonal projection on this line
// a projection point comes before another if it comes first according to vector v
bool cmp_by_projection(PT p, PT q) { return dot(v, p) < dot(v, q); }
line shift_left(double d) {
PT z = v.perp().truncate(d);
return line(a + z, b + z);
}
};
// find a point from a through b with distance d
PT point_along_line(PT a, PT b, double d) {
assert(a != b);
return a + (((b - a) / (b - a).norm()) * d);
}
// projection point c onto line through a and b assuming a != b
PT project_from_point_to_line(PT a, PT b, PT c) {
return a + (b - a) * dot(c - a, b - a) / (b - a).norm2();
}
// reflection point c onto line through a and b assuming a != b
PT reflection_from_point_to_line(PT a, PT b, PT c) {
PT p = project_from_point_to_line(a,b,c);
return p + p - c;
}
// minimum distance from point c to line through a and b
double dist_from_point_to_line(PT a, PT b, PT c) {
return fabs(cross(b - a, c - a) / (b - a).norm());
}
// returns true if point p is on line segment ab
bool is_point_on_seg(PT a, PT b, PT p) {
if (fabs(cross(p - b, a - b)) < eps) {
if (p.x < min(a.x, b.x) - eps || p.x > max(a.x, b.x) + eps) return false;
if (p.y < min(a.y, b.y) - eps || p.y > max(a.y, b.y) + eps) return false;
return true;
}
return false;
}
// minimum distance point from point c to segment ab that lies on segment ab
PT project_from_point_to_seg(PT a, PT b, PT c) {
double r = dist2(a, b);
if (sign(r) == 0) return a;
r = dot(c - a, b - a) / r;
if (r < 0) return a;
if (r > 1) return b;
return a + (b - a) * r;
}
// minimum distance from point c to segment ab
double dist_from_point_to_seg(PT a, PT b, PT c) {
return dist(c, project_from_point_to_seg(a, b, c));
}
// 0 if not parallel, 1 if parallel, 2 if collinear
int is_parallel(PT a, PT b, PT c, PT d) {
double k = fabs(cross(b - a, d - c));
if (k < eps){
if (fabs(cross(a - b, a - c)) < eps && fabs(cross(c - d, c - a)) < eps) return 2;
else return 1;
}
else return 0;
}
// check if two lines are same
bool are_lines_same(PT a, PT b, PT c, PT d) {
if (fabs(cross(a - c, c - d)) < eps && fabs(cross(b - c, c - d)) < eps) return true;
return false;
}
// bisector vector of <abc
PT angle_bisector(PT &a, PT &b, PT &c){
PT p = a - b, q = c - b;
return p + q * sqrt(dot(p, p) / dot(q, q));
}
// 1 if point is ccw to the line, 2 if point is cw to the line, 3 if point is on the line
int point_line_relation(PT a, PT b, PT p) {
int c = sign(cross(p - a, b - a));
if (c < 0) return 1;
if (c > 0) return 2;
return 3;
}
// intersection point between ab and cd assuming unique intersection exists
bool line_line_intersection(PT a, PT b, PT c, PT d, PT &ans) {
double a1 = a.y - b.y, b1 = b.x - a.x, c1 = cross(a, b);
double a2 = c.y - d.y, b2 = d.x - c.x, c2 = cross(c, d);
double det = a1 * b2 - a2 * b1;
if (det == 0) return 0;
ans = PT((b1 * c2 - b2 * c1) / det, (c1 * a2 - a1 * c2) / det);
return 1;
}
// intersection point between segment ab and segment cd assuming unique intersection exists
bool seg_seg_intersection(PT a, PT b, PT c, PT d, PT &ans) {
double oa = cross2(c, d, a), ob = cross2(c, d, b);
double oc = cross2(a, b, c), od = cross2(a, b, d);
if (oa * ob < 0 && oc * od < 0){
ans = (a * ob - b * oa) / (ob - oa);
return 1;
}
else return 0;
}
// intersection point between segment ab and segment cd assuming unique intersection may not exists
// se.size()==0 means no intersection
// se.size()==1 means one intersection
// se.size()==2 means range intersection
set<PT> seg_seg_intersection_inside(PT a, PT b, PT c, PT d) {
PT ans;
if (seg_seg_intersection(a, b, c, d, ans)) return {ans};
set<PT> se;
if (is_point_on_seg(c, d, a)) se.insert(a);
if (is_point_on_seg(c, d, b)) se.insert(b);
if (is_point_on_seg(a, b, c)) se.insert(c);
if (is_point_on_seg(a, b, d)) se.insert(d);
return se;
}
// intersection between segment ab and line cd
// 0 if do not intersect, 1 if proper intersect, 2 if segment intersect
int seg_line_relation(PT a, PT b, PT c, PT d) {
double p = cross2(c, d, a);
double q = cross2(c, d, b);
if (sign(p) == 0 && sign(q) == 0) return 2;
else if (p * q < 0) return 1;
else return 0;
}
// intersection between segament ab and line cd assuming unique intersection exists
bool seg_line_intersection(PT a, PT b, PT c, PT d, PT &ans) {
bool k = seg_line_relation(a, b, c, d);
assert(k != 2);
if (k) line_line_intersection(a, b, c, d, ans);
return k;
}
// minimum distance from segment ab to segment cd
double dist_from_seg_to_seg(PT a, PT b, PT c, PT d) {
PT dummy;
if (seg_seg_intersection(a, b, c, d, dummy)) return 0.0;
else return min({dist_from_point_to_seg(a, b, c), dist_from_point_to_seg(a, b, d),
dist_from_point_to_seg(c, d, a), dist_from_point_to_seg(c, d, b)});
}
// minimum distance from point c to ray (starting point a and direction vector b)
double dist_from_point_to_ray(PT a, PT b, PT c) {
b = a + b;
double r = dot(c - a, b - a);
if (r < 0.0) return dist(c, a);
return dist_from_point_to_line(a, b, c);
}
// starting point as and direction vector ad
bool ray_ray_intersection(PT as, PT ad, PT bs, PT bd) {
double dx = bs.x - as.x, dy = bs.y - as.y;
double det = bd.x * ad.y - bd.y * ad.x;
if (fabs(det) < eps) return 0;
double u = (dy * bd.x - dx * bd.y) / det;
double v = (dy * ad.x - dx * ad.y) / det;
if (sign(u) >= 0 && sign(v) >= 0) return 1;
else return 0;
}
double ray_ray_distance(PT as, PT ad, PT bs, PT bd) {
if (ray_ray_intersection(as, ad, bs, bd)) return 0.0;
double ans = dist_from_point_to_ray(as, ad, bs);
ans = min(ans, dist_from_point_to_ray(bs, bd, as));
return ans;
}
struct circle {
PT p; double r;
circle() {}
circle(PT _p, double _r): p(_p), r(_r) {};
// center (x, y) and radius r
circle(double x, double y, double _r): p(PT(x, y)), r(_r) {};
// circumcircle of a triangle
// the three points must be unique
circle(PT a, PT b, PT c) {
b = (a + b) * 0.5;
c = (a + c) * 0.5;
line_line_intersection(b, b + rotatecw90(a - b), c, c + rotatecw90(a - c), p);
r = dist(a, p);
}
// inscribed circle of a triangle
// pass a bool just to differentiate from circumcircle
circle(PT a, PT b, PT c, bool t) {
line u, v;
double m = atan2(b.y - a.y, b.x - a.x), n = atan2(c.y - a.y, c.x - a.x);
u.a = a;
u.b = u.a + (PT(cos((n + m)/2.0), sin((n + m)/2.0)));
v.a = b;
m = atan2(a.y - b.y, a.x - b.x), n = atan2(c.y - b.y, c.x - b.x);
v.b = v.a + (PT(cos((n + m)/2.0), sin((n + m)/2.0)));
line_line_intersection(u.a, u.b, v.a, v.b, p);
r = dist_from_point_to_seg(a, b, p);
}
bool operator == (circle v) { return p == v.p && sign(r - v.r) == 0; }
double area() { return PI * r * r; }
double circumference() { return 2.0 * PI * r; }
};
//0 if outside, 1 if on circumference, 2 if inside circle
int circle_point_relation(PT p, double r, PT b) {
double d = dist(p, b);
if (sign(d - r) < 0) return 2;
if (sign(d - r) == 0) return 1;
return 0;
}
// 0 if outside, 1 if on circumference, 2 if inside circle
int circle_line_relation(PT p, double r, PT a, PT b) {
double d = dist_from_point_to_line(a, b, p);
if (sign(d - r) < 0) return 2;
if (sign(d - r) == 0) return 1;
return 0;
}
//compute intersection of line through points a and b with
//circle centered at c with radius r > 0
vector<PT> circle_line_intersection(PT c, double r, PT a, PT b) {
vector<PT> ret;
b = b - a; a = a - c;
double A = dot(b, b), B = dot(a, b);
double C = dot(a, a) - r * r, D = B * B - A * C;
if (D < -eps) return ret;
ret.push_back(c + a + b * (-B + sqrt(D + eps)) / A);
if (D > eps) ret.push_back(c + a + b * (-B - sqrt(D)) / A);
return ret;
}
//5 - outside and do not intersect
//4 - intersect outside in one point
//3 - intersect in 2 points
//2 - intersect inside in one point
//1 - inside and do not intersect
int circle_circle_relation(PT a, double r, PT b, double R) {
double d = dist(a, b);
if (sign(d - r - R) > 0) return 5;
if (sign(d - r - R) == 0) return 4;
double l = fabs(r - R);
if (sign(d - r - R) < 0 && sign(d - l) > 0) return 3;
if (sign(d - l) == 0) return 2;
if (sign(d - l) < 0) return 1;
assert(0); return -1;
}
vector<PT> circle_circle_intersection(PT a, double r, PT b, double R) {
if (a == b && sign(r - R) == 0) return {PT(1e18, 1e18)};
vector<PT> ret;
double d = sqrt(dist2(a, b));
if (d > r + R || d + min(r, R) < max(r, R)) return ret;
double x = (d * d - R * R + r * r) / (2 * d);
double y = sqrt(r * r - x * x);
PT v = (b - a) / d;
ret.push_back(a + v * x + rotateccw90(v) * y);
if (y > 0) ret.push_back(a + v * x - rotateccw90(v) * y);
return ret;
}
// returns two circle c1, c2 through points a, b and of radius r
// 0 if there is no such circle, 1 if one circle, 2 if two circle
int get_circle(PT a, PT b, double r, circle &c1, circle &c2) {
vector<PT> v = circle_circle_intersection(a, r, b, r);
int t = v.size();
if (!t) return 0;
c1.p = v[0], c1.r = r;
if (t == 2) c2.p = v[1], c2.r = r;
return t;
}
// returns two circle c1, c2 which is tangent to line u, goes through
// point q and has radius r1; 0 for no circle, 1 if c1 = c2 , 2 if c1 != c2
int get_circle(line u, PT q, double r1, circle &c1, circle &c2) {
double d = dist_from_point_to_line(u.a, u.b, q);
if (sign(d - r1 * 2.0) > 0) return 0;
if (sign(d) == 0) {
cout << u.v.x << ' ' << u.v.y << '\n';
c1.p = q + rotateccw90(u.v).truncate(r1);
c2.p = q + rotatecw90(u.v).truncate(r1);
c1.r = c2.r = r1;
return 2;
}
line u1 = line(u.a + rotateccw90(u.v).truncate(r1), u.b + rotateccw90(u.v).truncate(r1));
line u2 = line(u.a + rotatecw90(u.v).truncate(r1), u.b + rotatecw90(u.v).truncate(r1));
circle cc = circle(q, r1);
PT p1, p2; vector<PT> v;
v = circle_line_intersection(q, r1, u1.a, u1.b);
if (!v.size()) v = circle_line_intersection(q, r1, u2.a, u2.b);
v.push_back(v[0]);
p1 = v[0], p2 = v[1];
c1 = circle(p1, r1);
if (p1 == p2) {
c2 = c1;
return 1;
}
c2 = circle(p2, r1);
return 2;
}
// returns the circle such that for all points w on the circumference of the circle
// dist(w, a) : dist(w, b) = rp : rq
// rp != rq
// https://en.wikipedia.org/wiki/Circles_of_Apollonius
circle get_apollonius_circle(PT p, PT q, double rp, double rq ){
rq *= rq ;
rp *= rp ;
double a = rq - rp ;
assert(sign(a));
double g = rq * p.x - rp * q.x ; g /= a ;
double h = rq * p.y - rp * q.y ; h /= a ;
double c = rq * p.x * p.x - rp * q.x * q.x + rq * p.y * p.y - rp * q.y * q.y ;
c /= a ;
PT o(g, h);
double r = g * g + h * h - c ;
r = sqrt(r);
return circle(o,r);
}
// returns area of intersection between two circles
double circle_circle_area(PT a, double r1, PT b, double r2) {
double d = (a - b).norm();
if(r1 + r2 < d + eps) return 0;
if(r1 + d < r2 + eps) return PI * r1 * r1;
if(r2 + d < r1 + eps) return PI * r2 * r2;
double theta_1 = acos((r1 * r1 + d * d - r2 * r2) / (2 * r1 * d)),
theta_2 = acos((r2 * r2 + d * d - r1 * r1)/(2 * r2 * d));
return r1 * r1 * (theta_1 - sin(2 * theta_1)/2.) + r2 * r2 * (theta_2 - sin(2 * theta_2)/2.);
}
// tangent lines from point q to the circle
int tangent_lines_from_point(PT p, double r, PT q, line &u, line &v) {
int x = sign(dist2(p, q) - r * r);
if (x < 0) return 0; // point in cricle
if (x == 0) { // point on circle
u = line(q, q + rotateccw90(q - p));
v = u;
return 1;
}
double d = dist(p, q);
double l = r * r / d;
double h = sqrt(r * r - l * l);
u = line(q, p + ((q - p).truncate(l) + (rotateccw90(q - p).truncate(h))));
v = line(q, p + ((q - p).truncate(l) + (rotatecw90(q - p).truncate(h))));
return 2;
}
// returns outer tangents line of two circles
// if inner == 1 it returns inner tangent lines
int tangents_lines_from_circle(PT c1, double r1, PT c2, double r2, bool inner, line &u, line &v) {
if (inner) r2 = -r2;
PT d = c2 - c1;
double dr = r1 - r2, d2 = d.norm2(), h2 = d2 - dr * dr;
if (d2 == 0 || h2 < 0) {
assert(h2 != 0);
return 0;
}
vector<pair<PT, PT>>out;
for (int tmp: {- 1, 1}) {
PT v = (d * dr + rotateccw90(d) * sqrt(h2) * tmp) / d2;
out.push_back({c1 + v * r1, c2 + v * r2});
}
u = line(out[0].first, out[0].second);
if (out.size() == 2) v = line(out[1].first, out[1].second);
return 1 + (h2 > 0);
}
// O(n^2 log n)
// https://vjudge.net/problem/UVA-12056
struct CircleUnion {
int n;
double x[2020], y[2020], r[2020];
int covered[2020];
vector<pair<double, double> > seg, cover;
double arc, pol;
inline int sign(double x) {return x < -eps ? -1 : x > eps;}
inline int sign(double x, double y) {return sign(x - y);}
inline double SQ(const double x) {return x * x;}
inline double dist(double x1, double y1, double x2, double y2) {return sqrt(SQ(x1 - x2) + SQ(y1 - y2));}
inline double angle(double A, double B, double C) {
double val = (SQ(A) + SQ(B) - SQ(C)) / (2 * A * B);
if (val < -1) val = -1;
if (val > +1) val = +1;
return acos(val);
}
CircleUnion() {
n = 0;
seg.clear(), cover.clear();
arc = pol = 0;
}
void init() {
n = 0;
seg.clear(), cover.clear();
arc = pol = 0;
}
void add(double xx, double yy, double rr) {
x[n] = xx, y[n] = yy, r[n] = rr, covered[n] = 0, n++;
}
void getarea(int i, double lef, double rig) {
arc += 0.5 * r[i] * r[i] * (rig - lef - sin(rig - lef));
double x1 = x[i] + r[i] * cos(lef), y1 = y[i] + r[i] * sin(lef);
double x2 = x[i] + r[i] * cos(rig), y2 = y[i] + r[i] * sin(rig);
pol += x1 * y2 - x2 * y1;
}
double solve() {
for (int i = 0; i < n; i++) {
for (int j = 0; j < i; j++) {
if (!sign(x[i] - x[j]) && !sign(y[i] - y[j]) && !sign(r[i] - r[j])) {
r[i] = 0.0;
break;
}
}
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (i != j && sign(r[j] - r[i]) >= 0 && sign(dist(x[i], y[i], x[j], y[j]) - (r[j] - r[i])) <= 0) {
covered[i] = 1;
break;
}
}
}
for (int i = 0; i < n; i++) {
if (sign(r[i]) && !covered[i]) {
seg.clear();
for (int j = 0; j < n; j++) {
if (i != j) {
double d = dist(x[i], y[i], x[j], y[j]);
if (sign(d - (r[j] + r[i])) >= 0 || sign(d - abs(r[j] - r[i])) <= 0) {
continue;
}
double alpha = atan2(y[j] - y[i], x[j] - x[i]);
double beta = angle(r[i], d, r[j]);
pair<double, double> tmp(alpha - beta, alpha + beta);
if (sign(tmp.first) <= 0 && sign(tmp.second) <= 0) {
seg.push_back(pair<double, double>(2 * PI + tmp.first, 2 * PI + tmp.second));
}
else if (sign(tmp.first) < 0) {
seg.push_back(pair<double, double>(2 * PI + tmp.first, 2 * PI));
seg.push_back(pair<double, double>(0, tmp.second));
}
else {
seg.push_back(tmp);
}
}
}
sort(seg.begin(), seg.end());
double rig = 0;
for (vector<pair<double, double> >::iterator iter = seg.begin(); iter != seg.end(); iter++) {
if (sign(rig - iter->first) >= 0) {
rig = max(rig, iter->second);
}
else {
getarea(i, rig, iter->first);
rig = iter->second;
}
}
if (!sign(rig)) {
arc += r[i] * r[i] * PI;
}
else {
getarea(i, rig, 2 * PI);
}
}
}
return pol / 2.0 + arc;
}
} CU;
double area_of_triangle(PT a, PT b, PT c) {
return fabs(cross(b - a, c - a) * 0.5);
}
// -1 if strictly inside, 0 if on the polygon, 1 if strictly outside
int is_point_in_triangle(PT a, PT b, PT c, PT p) {
if (sign(cross(b - a,c - a)) < 0) swap(b, c);
int c1 = sign(cross(b - a,p - a));
int c2 = sign(cross(c - b,p - b));
int c3 = sign(cross(a - c,p - c));
if (c1<0 || c2<0 || c3 < 0) return 1;
if (c1 + c2 + c3 != 3) return 0;
return -1;
}
double perimeter(vector<PT> &p) {
double ans=0; int n = p.size();
for (int i = 0; i < n; i++) ans += dist(p[i], p[(i + 1) % n]);
return ans;
}
double area(vector<PT> &p) {
double ans = 0; int n = p.size();
for (int i = 0; i < n; i++) ans += cross(p[i], p[(i + 1) % n]);
return fabs(ans) * 0.5;
}
// centroid of a (possibly non-convex) polygon,
// assuming that the coordinates are listed in a clockwise or
// counterclockwise fashion. Note that the centroid is often known as
// the "center of gravity" or "center of mass".
PT centroid(vector<PT> &p) {
int n = p.size(); PT c(0, 0);
double sum = 0;
for (int i = 0; i < n; i++) sum += cross(p[i], p[(i + 1) % n]);
double scale = 3.0 * sum;
for (int i = 0; i < n; i++) {
int j = (i + 1) % n;
c = c + (p[i] + p[j]) * cross(p[i], p[j]);
}
return c / scale;
}
// 0 if cw, 1 if ccw
bool get_direction(vector<PT> &p) {
double ans = 0; int n = p.size();
for (int i = 0; i < n; i++) ans += cross(p[i], p[(i + 1) % n]);
if (sign(ans) > 0) return 1;
return 0;
}
// it returns a point such that the sum of distances
// from that point to all points in p is minimum
// O(n log^2 MX)
PT geometric_median(vector<PT> p) {
auto tot_dist = [&](PT z) {
double res = 0;
for (int i = 0; i < p.size(); i++) res += dist(p[i], z);
return res;
};
auto findY = [&](double x) {
double yl = -1e5, yr = 1e5;
for (int i = 0; i < 60; i++) {
double ym1 = yl + (yr - yl) / 3;
double ym2 = yr - (yr - yl) / 3;
double d1 = tot_dist(PT(x, ym1));
double d2 = tot_dist(PT(x, ym2));
if (d1 < d2) yr = ym2;
else yl = ym1;
}
return pair<double, double> (yl, tot_dist(PT(x, yl)));
};
double xl = -1e5, xr = 1e5;
for (int i = 0; i < 60; i++) {
double xm1 = xl + (xr - xl) / 3;
double xm2 = xr - (xr - xl) / 3;
double y1, d1, y2, d2;
auto z = findY(xm1); y1 = z.first; d1 = z.second;
z = findY(xm2); y2 = z.first; d2 = z.second;
if (d1 < d2) xr = xm2;
else xl = xm1;
}
return {xl, findY(xl).first };
}
vector<PT> convex_hull(vector<PT> &p) {
if (p.size() <= 1) return p;
vector<PT> v = p;
sort(v.begin(), v.end());
vector<PT> up, dn;
for (auto& p : v) {
while (up.size() > 1 && orientation(up[up.size() - 2], up.back(), p) >= 0) {
up.pop_back();
}
while (dn.size() > 1 && orientation(dn[dn.size() - 2], dn.back(), p) <= 0) {
dn.pop_back();
}
up.push_back(p);
dn.push_back(p);
}
v = dn;
if (v.size() > 1) v.pop_back();
reverse(up.begin(), up.end());
up.pop_back();
for (auto& p : up) {
v.push_back(p);
}
if (v.size() == 2 && v[0] == v[1]) v.pop_back();
return v;
}
//checks if convex or not
bool is_convex(vector<PT> &p) {
bool s[3]; s[0] = s[1] = s[2] = 0;
int n = p.size();
for (int i = 0; i < n; i++) {
int j = (i + 1) % n;
int k = (j + 1) % n;
s[sign(cross(p[j] - p[i], p[k] - p[i])) + 1] = 1;
if (s[0] && s[2]) return 0;
}
return 1;
}
// -1 if strictly inside, 0 if on the polygon, 1 if strictly outside
// it must be strictly convex, otherwise make it strictly convex first
int is_point_in_convex(vector<PT> &p, const PT& x) { // O(log n)
int n = p.size(); assert(n >= 3);
int a = orientation(p[0], p[1], x), b = orientation(p[0], p[n - 1], x);
if (a < 0 || b > 0) return 1;
int l = 1, r = n - 1;
while (l + 1 < r) {
int mid = l + r >> 1;
if (orientation(p[0], p[mid], x) >= 0) l = mid;
else r = mid;
}
int k = orientation(p[l], p[r], x);
if (k <= 0) return -k;
if (l == 1 && a == 0) return 0;
if (r == n - 1 && b == 0) return 0;
return -1;
}
bool is_point_on_polygon(vector<PT> &p, const PT& z) {
int n = p.size();
for (int i = 0; i < n; i++) {
if (is_point_on_seg(p[i], p[(i + 1) % n], z)) return 1;
}
return 0;
}
// returns 1e9 if the point is on the polygon
int winding_number(vector<PT> &p, const PT& z) { // O(n)
if (is_point_on_polygon(p, z)) return 1e9;
int n = p.size(), ans = 0;
for (int i = 0; i < n; ++i) {
int j = (i + 1) % n;
bool below = p[i].y < z.y;
if (below != (p[j].y < z.y)) {
auto orient = orientation(z, p[j], p[i]);
if (orient == 0) return 0;
if (below == (orient > 0)) ans += below ? 1 : -1;
}
}
return ans;
}
// -1 if strictly inside, 0 if on the polygon, 1 if strictly outside
int is_point_in_polygon(vector<PT> &p, const PT& z) { // O(n)
int k = winding_number(p, z);
return k == 1e9 ? 0 : k == 0 ? 1 : -1;
}
// id of the vertex having maximum dot product with z
// polygon must need to be convex
// top - upper right vertex
// for minimum dot product negate z and return -dot(z, p[id])
int extreme_vertex(vector<PT> &p, const PT &z, const int top) { // O(log n)
int n = p.size();
if (n == 1) return 0;
double ans = dot(p[0], z); int id = 0;
if (dot(p[top], z) > ans) ans = dot(p[top], z), id = top;
int l = 1, r = top - 1;
while (l < r) {
int mid = l + r >> 1;
if (dot(p[mid + 1], z) >= dot(p[mid], z)) l = mid + 1;
else r = mid;
}
if (dot(p[l], z) > ans) ans = dot(p[l], z), id = l;
l = top + 1, r = n - 1;
while (l < r) {
int mid = l + r >> 1;
if (dot(p[(mid + 1) % n], z) >= dot(p[mid], z)) l = mid + 1;
else r = mid;
}
l %= n;
if (dot(p[l], z) > ans) ans = dot(p[l], z), id = l;
return id;
}
// maximum distance from any point on the perimeter to another point on the perimeter
double diameter(vector<PT> &p) {
int n = (int)p.size();
if (n == 1) return 0;
if (n == 2) return dist(p[0], p[1]);
double ans = 0;
int i = 0, j = 1;
while (i < n) {
while (cross(p[(i + 1) % n] - p[i], p[(j + 1) % n] - p[j]) >= 0) {
ans = max(ans, dist2(p[i], p[j]));
j = (j + 1) % n;
}
ans = max(ans, dist2(p[i], p[j]));
i++;
}
return sqrt(ans);
}
// minimum distance between two parallel lines (non necessarily axis parallel)
// such that the polygon can be put between the lines
double width(vector<PT> &p) {
int n = (int)p.size();
if (n <= 2) return 0;
double ans = inf;
int i = 0, j = 1;
while (i < n) {
while (cross(p[(i + 1) % n] - p[i], p[(j + 1) % n] - p[j]) >= 0) j = (j + 1) % n;
ans = min(ans, dist_from_point_to_line(p[i], p[(i + 1) % n], p[j]));
i++;
}
return ans;
}
// minimum perimeter
double minimum_enclosing_rectangle(vector<PT> &p) {
int n = p.size();
if (n <= 2) return perimeter(p);
int mndot = 0; double tmp = dot(p[1] - p[0], p[0]);
for (int i = 1; i < n; i++) {
if (dot(p[1] - p[0], p[i]) <= tmp) {
tmp = dot(p[1] - p[0], p[i]);
mndot = i;
}
}
double ans = inf;
int i = 0, j = 1, mxdot = 1;
while (i < n) {
PT cur = p[(i + 1) % n] - p[i];
while (cross(cur, p[(j + 1) % n] - p[j]) >= 0) j = (j + 1) % n;
while (dot(p[(mxdot + 1) % n], cur) >= dot(p[mxdot], cur)) mxdot = (mxdot + 1) % n;
while (dot(p[(mndot + 1) % n], cur) <= dot(p[mndot], cur)) mndot = (mndot + 1) % n;
ans = min(ans, 2.0 * ((dot(p[mxdot], cur) / cur.norm() - dot(p[mndot], cur) / cur.norm()) + dist_from_point_to_line(p[i], p[(i + 1) % n], p[j])));
i++;
}
return ans;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// given n points, find the minimum enclosing circle of the points
// call convex_hull() before this for faster solution
// expected O(n)
circle minimum_enclosing_circle(vector<PT> &p) {
shuffle(p.begin(), p.end(), rng);
int n = p.size();
circle c(p[0], 0);
for (int i = 1; i < n; i++) {
if (sign(dist(c.p, p[i]) - c.r) > 0) {
c = circle(p[i], 0);
for (int j = 0; j < i; j++) {
if (sign(dist(c.p, p[j]) - c.r) > 0) {
c = circle((p[i] + p[j]) / 2, dist(p[i], p[j]) / 2);
for (int k = 0; k < j; k++) {
if (sign(dist(c.p, p[k]) - c.r) > 0) {
c = circle(p[i], p[j], p[k]);
}
}
}
}
}
}
return c;
}
// returns a vector with the vertices of a polygon with everything
// to the left of the line going from a to b cut away.
vector<PT> cut(vector<PT> &p, PT a, PT b) {
vector<PT> ans;
int n = (int)p.size();
for (int i = 0; i < n; i++) {
double c1 = cross(b - a, p[i] - a);
double c2 = cross(b - a, p[(i + 1) % n] - a);
if (sign(c1) >= 0) ans.push_back(p[i]);
if (sign(c1 * c2) < 0) {
if (!is_parallel(p[i], p[(i + 1) % n], a, b)) {
PT tmp; line_line_intersection(p[i], p[(i + 1) % n], a, b, tmp);
ans.push_back(tmp);
}
}
}
return ans;
}
// not necessarily convex, boundary is included in the intersection
// returns total intersected length
// it returns the sum of the lengths of the portions of the line that are inside the polygon
double polygon_line_intersection(vector<PT> p, PT a, PT b) {
int n = p.size();
p.push_back(p[0]);
line l = line(a, b);
double ans = 0.0;
vector< pair<double, int> > vec;
for (int i = 0; i < n; i++) {
int s1 = orientation(a, b, p[i]);
int s2 = orientation(a, b, p[i + 1]);
if (s1 == s2) continue;
line t = line(p[i], p[i + 1]);
PT inter = (t.v * l.c - l.v * t.c) / cross(l.v, t.v);
double tmp = dot(inter, l.v);
int f;
if (s1 > s2) f = s1 && s2 ? 2 : 1;
else f = s1 && s2 ? -2 : -1;
vec.push_back(make_pair((f > 0 ? tmp - eps : tmp + eps), f)); // keep eps very small like 1e-12
}
sort(vec.begin(), vec.end());
for (int i = 0, j = 0; i + 1 < (int)vec.size(); i++){
j += vec[i].second;
if (j) ans += vec[i + 1].first - vec[i].first; // if this portion is inside the polygon
// else ans = 0; // if we want the maximum intersected length which is totally inside the polygon, uncomment this and take the maximum of ans
}
ans = ans / sqrt(dot(l.v, l.v));
p.pop_back();
return ans;
}
// given a convex polygon p, and a line ab and the top vertex of the polygon
// returns the intersection of the line with the polygon
// it returns the indices of the edges of the polygon that are intersected by the line
// so if it returns i, then the line intersects the edge (p[i], p[(i + 1) % n])
array<int, 2> convex_line_intersection(vector<PT> &p, PT a, PT b, int top) {
int end_a = extreme_vertex(p, (a - b).perp(), top);
int end_b = extreme_vertex(p, (b - a).perp(), top);
auto cmp_l = [&](int i) { return orientation(a, p[i], b); };
if (cmp_l(end_a) < 0 || cmp_l(end_b) > 0)
return {-1, -1}; // no intersection
array<int, 2> res;
for (int i = 0; i < 2; i++) {
int lo = end_b, hi = end_a, n = p.size();
while ((lo + 1) % n != hi) {
int m = ((lo + hi + (lo < hi ? 0 : n)) / 2) % n;
(cmp_l(m) == cmp_l(end_b) ? lo : hi) = m;
}
res[i] = (lo + !cmp_l(hi)) % n;
swap(end_a, end_b);
}
if (res[0] == res[1]) return {res[0], -1}; // touches the vertex res[0]
if (!cmp_l(res[0]) && !cmp_l(res[1]))
switch ((res[0] - res[1] + (int)p.size() + 1) % p.size()) {
case 0: return {res[0], res[0]}; // touches the edge (res[0], res[0] + 1)
case 2: return {res[1], res[1]}; // touches the edge (res[1], res[1] + 1)
}
return res; // intersects the edges (res[0], res[0] + 1) and (res[1], res[1] + 1)
}
pair<PT, int> point_poly_tangent(vector<PT> &p, PT Q, int dir, int l, int r) {
while (r - l > 1) {
int mid = (l + r) >> 1;
bool pvs = orientation(Q, p[mid], p[mid - 1]) != -dir;
bool nxt = orientation(Q, p[mid], p[mid + 1]) != -dir;
if (pvs && nxt) return {p[mid], mid};
if (!(pvs || nxt)) {
auto p1 = point_poly_tangent(p, Q, dir, mid + 1, r);
auto p2 = point_poly_tangent(p, Q, dir, l, mid - 1);
return orientation(Q, p1.first, p2.first) == dir ? p1 : p2;
}
if (!pvs) {
if (orientation(Q, p[mid], p[l]) == dir) r = mid - 1;
else if (orientation(Q, p[l], p[r]) == dir) r = mid - 1;
else l = mid + 1;
}
if (!nxt) {
if (orientation(Q, p[mid], p[l]) == dir) l = mid + 1;
else if (orientation(Q, p[l], p[r]) == dir) r = mid - 1;
else l = mid + 1;
}
}
pair<PT, int> ret = {p[l], l};
for (int i = l + 1; i <= r; i++) ret = orientation(Q, ret.first, p[i]) != dir ? make_pair(p[i], i) : ret;
return ret;
}
// (ccw, cw) tangents from a point that is outside this convex polygon
// returns indexes of the points
// ccw means the tangent from Q to that point is in the same direction as the polygon ccw direction
pair<int, int> tangents_from_point_to_polygon(vector<PT> &p, PT Q){
int ccw = point_poly_tangent(p, Q, 1, 0, (int)p.size() - 1).second;
int cw = point_poly_tangent(p, Q, -1, 0, (int)p.size() - 1).second;
return make_pair(ccw, cw);
}
// minimum distance from a point to a convex polygon
// it assumes point lie strictly outside the polygon
double dist_from_point_to_polygon(vector<PT> &p, PT z) {
double ans = inf;
int n = p.size();
if (n <= 3) {
for(int i = 0; i < n; i++) ans = min(ans, dist_from_point_to_seg(p[i], p[(i + 1) % n], z));
return ans;
}
auto [r, l] = tangents_from_point_to_polygon(p, z);
if(l > r) r += n;
while (l < r) {
int mid = (l + r) >> 1;
double left = dist2(p[mid % n], z), right= dist2(p[(mid + 1) % n], z);
ans = min({ans, left, right});
if(left < right) r = mid;
else l = mid + 1;
}
ans = sqrt(ans);
ans = min(ans, dist_from_point_to_seg(p[l % n], p[(l + 1) % n], z));
ans = min(ans, dist_from_point_to_seg(p[l % n], p[(l - 1 + n) % n], z));
return ans;
}
// minimum distance from convex polygon p to line ab
// returns 0 is it intersects with the polygon
// top - upper right vertex
double dist_from_polygon_to_line(vector<PT> &p, PT a, PT b, int top) { //O(log n)
PT orth = (b - a).perp();
if (orientation(a, b, p[0]) > 0) orth = (a - b).perp();
int id = extreme_vertex(p, orth, top);
if (dot(p[id] - a, orth) > 0) return 0.0; //if orth and a are in the same half of the line, then poly and line intersects
return dist_from_point_to_line(a, b, p[id]); //does not intersect
}
// minimum distance from a convex polygon to another convex polygon
// the polygon doesnot overlap or touch
// tested in https://toph.co/p/the-wall
double dist_from_polygon_to_polygon(vector<PT> &p1, vector<PT> &p2) { // O(n log n)
double ans = inf;
for (int i = 0; i < p1.size(); i++) {
ans = min(ans, dist_from_point_to_polygon(p2, p1[i]));
}
for (int i = 0; i < p2.size(); i++) {
ans = min(ans, dist_from_point_to_polygon(p1, p2[i]));
}
return ans;
}
// maximum distance from a convex polygon to another convex polygon
double maximum_dist_from_polygon_to_polygon(vector<PT> &u, vector<PT> &v){ //O(n)
int n = (int)u.size(), m = (int)v.size();
double ans = 0;
if (n < 3 || m < 3) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) ans = max(ans, dist2(u[i], v[j]));
}
return sqrt(ans);
}
if (u[0].x > v[0].x) swap(n, m), swap(u, v);
int i = 0, j = 0, step = n + m + 10;
while (j + 1 < m && v[j].x < v[j + 1].x) j++ ;
while (step--) {
if (cross(u[(i + 1)%n] - u[i], v[(j + 1)%m] - v[j]) >= 0) j = (j + 1) % m;
else i = (i + 1) % n;
ans = max(ans, dist2(u[i], v[j]));
}
return sqrt(ans);
}
// calculates the area of the union of n polygons (not necessarily convex).
// the points within each polygon must be given in CCW order.
// complexity: O(N^2), where N is the total number of points
double rat(PT a, PT b, PT p) {
return !sign(a.x - b.x) ? (p.y - a.y) / (b.y - a.y) : (p.x - a.x) / (b.x - a.x);
};
double polygon_union(vector<vector<PT>> &p) {
int n = p.size();
double ans=0;
for(int i = 0; i < n; ++i) {
for (int v = 0; v < (int)p[i].size(); ++v) {
PT a = p[i][v], b = p[i][(v + 1) % p[i].size()];
vector<pair<double, int>> segs;
segs.emplace_back(0, 0), segs.emplace_back(1, 0);
for(int j = 0; j < n; ++j) {
if(i != j) {
for(size_t u = 0; u < p[j].size(); ++u) {
PT c = p[j][u], d = p[j][(u + 1) % p[j].size()];
int sc = sign(cross(b - a, c - a)), sd = sign(cross(b - a, d - a));
if(!sc && !sd) {
if(sign(dot(b - a, d - c)) > 0 && i > j) {
segs.emplace_back(rat(a, b, c), 1), segs.emplace_back(rat(a, b, d), -1);
}
}
else {
double sa = cross(d - c, a - c), sb = cross(d - c, b - c);
if(sc >= 0 && sd < 0) segs.emplace_back(sa / (sa - sb), 1);
else if(sc < 0 && sd >= 0) segs.emplace_back(sa / (sa - sb), -1);
}
}
}
}
sort(segs.begin(), segs.end());
double pre = min<ld>(max<ld>(segs[0].first, 0.0), 1.0), now, sum = 0;
int cnt = segs[0].second;
for(int j = 1; j < segs.size(); ++j) {
now = min<ld>(max<ld>(segs[j].first, 0.0), 1.0);
if (!cnt) sum += now - pre;
cnt += segs[j].second;
pre = now;
}
ans += cross(a, b) * sum;
}
}
return ans * 0.5;
}
// contains all points p such that: cross(b - a, p - a) >= 0
struct HP {
PT a, b;
HP() {}
HP(PT a, PT b) : a(a), b(b) {}
HP(const HP& rhs) : a(rhs.a), b(rhs.b) {}
int operator < (const HP& rhs) const {
PT p = b - a;
PT q = rhs.b - rhs.a;
int fp = (p.y < 0 || (p.y == 0 && p.x < 0));
int fq = (q.y < 0 || (q.y == 0 && q.x < 0));
if (fp != fq) return fp == 0;
if (cross(p, q)) return cross(p, q) > 0;
return cross(p, rhs.b - a) < 0;
}
PT line_line_intersection(PT a, PT b, PT c, PT d) {
b = b - a; d = c - d; c = c - a;
return a + b * cross(c, d) / cross(b, d);
}
PT intersection(const HP &v) {
return line_line_intersection(a, b, v.a, v.b);
}
};
int check(HP a, HP b, HP c) {
return cross(a.b - a.a, b.intersection(c) - a.a) > -eps; //-eps to include polygons of zero area (straight lines, points)
}
// consider half-plane of counter-clockwise side of each line
// if lines are not bounded add infinity rectangle
// returns a convex polygon, a point can occur multiple times though
// complexity: O(n log(n))
vector<PT> half_plane_intersection(vector<HP> h) {
sort(h.begin(), h.end());
vector<HP> tmp;
for (int i = 0; i < h.size(); i++) {
if (!i || cross(h[i].b - h[i].a, h[i - 1].b - h[i - 1].a)) {
tmp.push_back(h[i]);
}
}
h = tmp;
vector<HP> q(h.size() + 10);
int qh = 0, qe = 0;
for (int i = 0; i < h.size(); i++) {
while (qe - qh > 1 && !check(h[i], q[qe - 2], q[qe - 1])) qe--;
while (qe - qh > 1 && !check(h[i], q[qh], q[qh + 1])) qh++;
q[qe++] = h[i];
}
while (qe - qh > 2 && !check(q[qh], q[qe - 2], q[qe - 1])) qe--;
while (qe - qh > 2 && !check(q[qe - 1], q[qh], q[qh + 1])) qh++;
vector<HP> res;
for (int i = qh; i < qe; i++) res.push_back(q[i]);
vector<PT> hull;
if (res.size() > 2) {
for (int i = 0; i < res.size(); i++) {
hull.push_back(res[i].intersection(res[(i + 1) % ((int)res.size())]));
}
}
return hull;
}
// rotate the polygon such that the (bottom, left)-most point is at the first position
void reorder_polygon(vector<PT> &p) {
int pos = 0;
for (int i = 1; i < p.size(); i++) {
if (p[i].y < p[pos].y || (sign(p[i].y - p[pos].y) == 0 && p[i].x < p[pos].x)) pos = i;
}
rotate(p.begin(), p.begin() + pos, p.end());
}
// a and b are convex polygons
// returns a convex hull of their minkowski sum
// min(a.size(), b.size()) >= 2
// https://cp-algorithms.com/geometry/minkowski.html
vector<PT> minkowski_sum(vector<PT> a, vector<PT> b) {
reorder_polygon(a); reorder_polygon(b);
int n = a.size(), m = b.size();
int i = 0, j = 0;
a.push_back(a[0]); a.push_back(a[1]);
b.push_back(b[0]); b.push_back(b[1]);
vector<PT> c;
while (i < n || j < m) {
c.push_back(a[i] + b[j]);
double p = cross(a[i + 1] - a[i], b[j + 1] - b[j]);
if (sign(p) >= 0) ++i;
if (sign(p) <= 0) ++j;
}
return c;
}
// returns the area of the intersection of the circle with center c and radius r
// and the triangle formed by the points c, a, b
double _triangle_circle_intersection(PT c, double r, PT a, PT b) {
double sd1 = dist2(c, a), sd2 = dist2(c, b);
if(sd1 > sd2) swap(a, b), swap(sd1, sd2);
double sd = dist2(a, b);
double d1 = sqrtl(sd1), d2 = sqrtl(sd2), d = sqrt(sd);
double x = abs(sd2 - sd - sd1) / (2 * d);
double h = sqrtl(sd1 - x * x);
if(r >= d2) return h * d / 2;
double area = 0;
if(sd + sd1 < sd2) {
if(r < d1) area = r * r * (acos(h / d2) - acos(h / d1)) / 2;
else {
area = r * r * ( acos(h / d2) - acos(h / r)) / 2;
double y = sqrtl(r * r - h * h);
area += h * (y - x) / 2;
}
}
else {
if(r < h) area = r * r * (acos(h / d2) + acos(h / d1)) / 2;
else {
area += r * r * (acos(h / d2) - acos(h / r)) / 2;
double y = sqrtl(r * r - h * h);
area += h * y / 2;
if(r < d1) {
area += r * r * (acos(h / d1) - acos(h / r)) / 2;
area += h * y / 2;
}
else area += h * x / 2;
}
}
return area;
}
// intersection between a simple polygon and a circle
double polygon_circle_intersection(vector<PT> &v, PT p, double r) {
int n = v.size();
double ans = 0.00;
PT org = {0, 0};
for(int i = 0; i < n; i++) {
int x = orientation(p, v[i], v[(i + 1) % n]);
if(x == 0) continue;
double area = _triangle_circle_intersection(org, r, v[i] - p, v[(i + 1) % n] - p);
if (x < 0) ans -= area;
else ans += area;
}
return abs(ans);
}
// find a circle of radius r that contains as many points as possible
// O(n^2 log n);
double maximum_circle_cover(vector<PT> p, double r, circle &c) {
int n = p.size();
int ans = 0;
int id = 0; double th = 0;
for (int i = 0; i < n; ++i) {
// maximum circle cover when the circle goes through this point
vector<pair<double, int>> events = {{-PI, +1}, {PI, -1}};
for (int j = 0; j < n; ++j) {
if (j == i) continue;
double d = dist(p[i], p[j]);
if (d > r * 2) continue;
double dir = (p[j] - p[i]).arg();
double ang = acos(d / 2 / r);
double st = dir - ang, ed = dir + ang;
if (st > PI) st -= PI * 2;
if (st <= -PI) st += PI * 2;
if (ed > PI) ed -= PI * 2;
if (ed <= -PI) ed += PI * 2;
events.push_back({st - eps, +1}); // take care of precisions!
events.push_back({ed, -1});
if (st > ed) {
events.push_back({-PI, +1});
events.push_back({+PI, -1});
}
}
sort(events.begin(), events.end());
int cnt = 0;
for (auto &&e: events) {
cnt += e.second;
if (cnt > ans) {
ans = cnt;
id = i; th = e.first;
}
}
}
PT w = PT(p[id].x + r * cos(th), p[id].y + r * sin(th));
c = circle(w, r); //best_circle
return ans;
}
// radius of the maximum inscribed circle in a convex polygon
double maximum_inscribed_circle(vector<PT> p) {
int n = p.size();
if (n <= 2) return 0;
double l = 0, r = 20000;
while (r - l > eps) {
double mid = (l + r) * 0.5;
vector<HP> h;
const int L = 1e9;
h.push_back(HP(PT(-L, -L), PT(L, -L)));
h.push_back(HP(PT(L, -L), PT(L, L)));
h.push_back(HP(PT(L, L), PT(-L, L)));
h.push_back(HP(PT(-L, L), PT(-L, -L)));
for (int i = 0; i < n; i++) {
PT z = (p[(i + 1) % n] - p[i]).perp();
z = z.truncate(mid);
PT y = p[i] + z, q = p[(i + 1) % n] + z;
h.push_back(HP(p[i] + z, p[(i + 1) % n] + z));
}
vector<PT> nw = half_plane_intersection(h);
if (!nw.empty()) l = mid;
else r = mid;
}
return l;
}
// ear decomposition, O(n^3) but faster
vector<vector<PT>> triangulate(vector<PT> p) {
vector<vector<PT>> v;
while (p.size() >= 3) {
for (int i = 0, n = p.size(); i < n; i++) {
int pre = i == 0 ? n - 1 : i - 1;;
int nxt = i == n - 1 ? 0 : i + 1;;
int ori = orientation(p[i], p[pre], p[nxt]);
if (ori < 0) {
int ok = 1;
for (int j = 0; j < n; j++) {
if (j == i || j == pre || j == nxt)continue;
if (is_point_in_triangle(p[i], p[pre], p[nxt] , p[j]) < 1) {
ok = 0;
break;
}
}
if (ok) {
v.push_back({p[pre], p[i], p[nxt]});
p.erase(p.begin() + i);
break;
}
}
}
}
return v;
}
struct star {
int n; // number of sides of the star
double r; // radius of the circumcircle
star(int _n, double _r) {
n = _n;
r = _r;
}
double area() {
double theta = PI / n;
double s = 2 * r * sin(theta);
double R = 0.5 * s / tan(theta);
double a = 0.5 * n * s * R;
double a2 = 0.25 * s * s / tan(1.5 * theta);
return a - n * a2;
}
};
// given a list of lengths of the sides of a polygon in counterclockwise order
// returns the maximum area of a non-degenerate polygon that can be formed using those lengths
double get_maximum_polygon_area_for_given_lengths(vector<double> v) {
if (v.size() < 3) {
return 0;
}
int m = 0;
double sum = 0;
for (int i = 0; i < v.size(); i++) {
if (v[i] > v[m]) {
m = i;
}
sum += v[i];
}
if (sign(v[m] - (sum - v[m])) >= 0) {
return 0; // no non-degenerate polygon is possible
}
// the polygon should be a circular polygon
// that is all points are on the circumference of a circle
double l = v[m] / 2, r = 1e6; // fix it correctly
int it = 60;
auto ang = [](double x, double r) { // x = length of the chord, r = radius of the circle
return 2 * asin((x / 2) / r);
};
auto calc = [=](double r) {
double sum = 0;
for (auto x: v) {
sum += ang(x, r);
}
return sum;
};
// compute the radius of the circle
while (it--) {
double mid = (l + r) / 2;
if (calc(mid) <= 2 * PI) {
r = mid;
}
else {
l = mid;
}
}
if (calc(r) <= 2 * PI - eps) { // the center of the circle is outside the polygon
auto calc2 = [&](double r) {
double sum = 0;
for (int i = 0; i < v.size(); i++) {
double x = v[i];
double th = ang(x, r);
if (i != m) {
sum += th;
}
else {
sum += 2 * PI - th;
}
}
return sum;
};
l = v[m] / 2; r = 1e6;
it = 60;
while (it--) {
double mid = (l + r) / 2;
if (calc2(mid) > 2 * PI) {
r = mid;
}
else {
l = mid;
}
}
auto get_area = [=](double r) {
double ans = 0;
for (int i = 0; i < v.size(); i++) {
double x = v[i];
double area = r * r * sin(ang(x, r)) / 2;
if (i != m) {
ans += area;
}
else {
ans -= area;
}
}
return ans;
};
return get_area(r);
}
else { // the center of the circle is inside the polygon
auto get_area = [=](double r) {
double ans = 0;
for (auto x: v) {
ans += r * r * sin(ang(x, r)) / 2;
}
return ans;
};
return get_area(r);
}
}
struct point {
ll x, y;
point(ll xx = 0, ll yy = 0) : x(xx), y(yy) {}
point operator-(const point &other) const {
return {x - other.x, y - other.y};
}
ll operator%(const point &other) const {
return x * other.y - y * other.x;
}
ll length() {
return x * x + y * y;
}
ll operator*(const point &other) const {
return x * other.x + y * other.y;
}
};
struct line2 {
ll A, B, C;
line2(point a, point b) {
A = a.y - b.y;
B = b.x - a.x;
C = 0;
C = eval(a);
}
ll eval(point p) {
return A * p.x + B * p.y - C;
}
};
namespace solve1 {
ll area2(point a, point b, point c) {
return abs((b - a) % (c - a));
}
bool inside_triangle(point a, point b, point c, point o) {
return area2(a, b, c) == area2(a, b, o) + area2(a, c, o) + area2(b, c, o);
}
struct polygon {
vector<point> hull;
polygon(vector<point> a) {
for (int i = 1; i < len(a); i++) {
if (make_pair(a[i].x, a[i].y) < make_pair(a[0].x, a[0].y)) {
swap(a[0], a[i]);
}
}
sort(1 + all(a), [&](point l, point r) {
l = l - a[0];
r = r - a[0];
ll val = l % r;
if (val == 0) {
return l.length() < r.length();
}
return val > 0;
});
for (auto p : a) {
while (len(hull) > 1 && (hull.back() - hull.rbegin()[1]) % (p - hull.back()) <= 0) {
hull.pop_back();
}
hull.push_back(p);
}
}
bool contains(point p) {
int lb = 1, rb = len(hull) - 1;
while (rb - lb > 1) {
int mid = (lb + rb) / 2;
if ((hull[mid] - hull[0]) % (p - hull[0]) >= 0) {
lb = mid;
} else {
rb = mid;
}
}
return inside_triangle(hull[0], hull[lb], hull[lb + 1], p);
}
};
bool solve1(point o, vector<point> p) {
if (len(p) <= 1) {
return true;
}
polygon poly(p);
auto hull = poly.hull;
if (len(hull) == 2) {
point A(hull[0]);
point B(hull[1]);
if ((A - o) * (B - o) < 0) {
return false;
}
return true;
}
for (auto p : hull) {
if (p.x == o.x && p.y == o.y) {
return true;
}
}
return !poly.contains(o);
}
}
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
auto start = chrono::high_resolution_clock::now();
int n;
cin >> n;
vector<int> x(n), y(n), z(n);
for (int i = 0; i < n; i++) {
cin >> x[i] >> y[i] >> z[i];
}
int max_z = *max_element(all(z));
vector<point> mid, other;
for (int i = 0; i < n; i++) {
if (z[i] == 0 || z[i] == max_z) {
other.emplace_back(x[i], y[i]);
} else {
mid.emplace_back(x[i], y[i]);
}
}
auto unique = [&](vector<point> &p) {
vector<point> q;
set<pair<int, int>> used;
for (auto p : p) {
if (used.insert({p.x, p.y}).second) {
q.push_back(p);
}
}
p = q;
};
auto inside_circle = [&](point p, circle c) {
return (c.p - PT(p.x, p.y)).norm() < c.r + eps;
};
auto check_circle = [&](circle c) {
for (auto [x, y] : mid) {
if (abs((c.p - PT(x, y)).norm() - c.r) > eps) {
return false;
}
}
for (auto p : other) {
if (!inside_circle(p, c)) {
return false;
}
}
return true;
};
unique(mid);
unique(other);
bool ans = false;
if (mid.empty()) {
ans = true;
} else if (len(mid) == 1) {
ans = solve1::solve1(mid[0], other);
while (chrono::high_resolution_clock::now() - start < 0.1s);
} else if (len(mid) == 2) {
vector<point> S, T;
line2 ln(mid[0], mid[1]);
for (auto p : other) {
if (ln.eval(p) == 0) {
if (mid[0].x == p.x && mid[0].y == p.y) {
continue;
}
if (mid[1].x == p.x && mid[1].y == p.y) {
continue;
}
if ((mid[0] - p) * (mid[1] - p) > eps) {
cout << "not a penguin\n";
return 0;
}
continue;
}
if (ln.eval(p) > 0) {
S.push_back(p);
} else {
T.push_back(p);
}
}
PT A(mid[0].x, mid[0].y);
PT B(mid[1].x, mid[1].y);
if (S.empty() || T.empty()) {
cout << "probably\n";
return 0;
}
const ld PI = atan2l(0, -1);
auto get_ang = [&](PT O) {
PT v1 = (A - O);
PT v2 = (B - O);
ld ang = atan2l(cross(v1, v2), dot(v1, v2));
return abs(ang);
};
ld ang1 = 1e18, ang2 = 1e18;
for (auto p : S) {
ang1 = min(ang1, get_ang(PT(p.x, p.y)));
}
for (auto p : T) {
ang2 = min(ang2, get_ang(PT(p.x, p.y)));
}
ans = ang1 + ang2 > PI - eps;
if (ans) {
cout << "probably\n";
while (chrono::high_resolution_clock::now() - start < 0.3s);
} else {
cout << "not a penguin\n";
while (chrono::high_resolution_clock::now() - start < 0.4s);
}
return 0;
} else {
if (line2(mid[0], mid[1]).eval(mid[2]) == 0) {
ans = false;
} else {
auto c = circle(PT(mid[0].x, mid[0].y), PT(mid[1].x, mid[1].y), PT(mid[2].x, mid[2].y));
ans = check_circle(c);
}
while (chrono::high_resolution_clock::now() - start < 0.5s);
}
if (ans) {
cout << "probably\n";
} else {
cout << "not a penguin\n";
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 501ms
memory: 3584kb
input:
5 0 0 0 3 4 1 -3 -4 2 -3 4 3 3 -4 4
output:
probably
result:
ok single line: 'probably'
Test #2:
score: 0
Accepted
time: 500ms
memory: 3712kb
input:
4 0 6 2 3 4 1 -3 -4 1 -3 4 1
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
2 0 0 0 1 1 0
output:
probably
result:
ok single line: 'probably'
Test #4:
score: 0
Accepted
time: 1ms
memory: 3712kb
input:
1 -707581848 729479863 0
output:
probably
result:
ok single line: 'probably'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
1 -645543323 -727037898 1000000000
output:
probably
result:
ok single line: 'probably'
Test #6:
score: 0
Accepted
time: 1ms
memory: 3712kb
input:
2 -144026193 -291805020 351535199 21583118 -794798695 351535199
output:
probably
result:
ok single line: 'probably'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
10 216139827 -699008032 210723435 -551462533 -568510194 210723435 279408745 78104755 210723435 -785457697 8180408 210723435 -402465570 651374568 210723435 -52859838 -914027103 210723435 42315332 41446900 210723435 304245166 -809754512 210723435 523743176 -944699162 210723435 -143145462 653487488 210...
output:
probably
result:
ok single line: 'probably'
Test #8:
score: 0
Accepted
time: 3ms
memory: 4608kb
input:
12837 -258471657 994194759 586603540 -537576135 -233571029 586603540 -465375394 506870976 586603540 -317032929 -517838213 586603540 10492460 -361011473 586603540 860612059 -831353929 586603540 -688074405 118458720 586603540 -705093302 -590826822 586603540 -671411924 144040556 586603540 -885405216 25...
output:
probably
result:
ok single line: 'probably'
Test #9:
score: 0
Accepted
time: 41ms
memory: 13316kb
input:
100000 -97006954 -37182521 633988833 -725457820 -329689716 633988833 747802869 -643601418 633988833 605644955 127768598 633988833 -495675635 -652668200 633988833 186575645 242702285 633988833 -694803524 -364850217 633988833 -792680470 29181377 633988833 578576113 -333667995 633988833 -805509390 7697...
output:
probably
result:
ok single line: 'probably'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
10 -979458639 883639183 660854572 151005794 637688912 660854572 -864679233 -572589246 660854572 -679129432 125352855 0 -504190727 -999033057 0 921071211 -745244241 0 109593464 368477593 660854572 -981479719 -827844525 0 -983601943 -78988738 0 837959682 889541598 660854572
output:
probably
result:
ok single line: 'probably'
Test #11:
score: 0
Accepted
time: 4ms
memory: 4608kb
input:
12837 -834245721 -183467634 0 -308307809 -180166551 741767378 767045571 134130709 0 490500926 -629281946 741767378 304164999 930493417 0 563177862 -601480066 0 768351036 205783930 741767378 364430828 490512148 0 425675963 -351032842 0 22511639 -799068154 0 798416022 382338113 0 -422637360 860070601 ...
output:
probably
result:
ok single line: 'probably'
Test #12:
score: 0
Accepted
time: 40ms
memory: 13316kb
input:
100000 -204419073 616651507 84119972 -275082100 866561360 84119972 -278978223 960506527 84119972 963474441 -531395628 84119972 -896450773 869050123 84119972 -203715034 -6252419 84119972 -565734459 872192953 0 145122453 678719320 84119972 135204531 142343624 84119972 53952704 -459314452 84119972 -901...
output:
probably
result:
ok single line: 'probably'
Test #13:
score: 0
Accepted
time: 100ms
memory: 3712kb
input:
10 917553613 163452026 303876702 247337867 -214697945 303876702 -269412946 301683947 0 862926845 731201507 303876702 732327945 -257608977 0 538988294 -376586456 303876702 -431527972 -304638582 303876702 -95861959 65682626 303876702 747247411 -321856195 0 659868388 773329785 287533139
output:
probably
result:
ok single line: 'probably'
Test #14:
score: 0
Accepted
time: 96ms
memory: 12572kb
input:
77512 454723971 922575736 0 686043534 -603094788 0 -204536198 -56984402 996653075 -774009699 219097279 0 -754958752 -580658969 996653075 -590380405 582608261 996653075 727605644 590331164 0 187598638 767142725 996653075 -531103525 -117991328 996653075 -344251189 -586688546 996653075 -598750222 52822...
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #15:
score: 0
Accepted
time: 94ms
memory: 13860kb
input:
100000 -193986194 701128931 190881300 -598024017 -928871353 0 19462831 -171836756 190881300 -926424602 -703017645 0 -772117075 -145804688 0 562742818 -26480056 0 70163556 -16279150 190881300 -214724360 436101136 190881300 602444020 -387771 190881300 214096285 883487603 0 938230992 769340143 19088130...
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #16:
score: 0
Accepted
time: 98ms
memory: 14284kb
input:
100000 -293097310 802904381 0 989007504 403703949 0 537411730 767165635 0 -877715602 254859027 0 950993991 -873780921 0 660769401 -526476292 369790967 -195862519 975476554 369790967 678630393 -403280040 0 -57321885 -68709385 369790967 166678387 -175644211 369790967 190507535 781104647 0 931978697 61...
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #17:
score: 0
Accepted
time: 94ms
memory: 14024kb
input:
100000 -762366769 -965168048 0 -337761858 -144114863 253733334 416370615 -810840722 0 -82280223 292636116 0 -926904564 -454699915 253733334 -413248633 -338887279 0 478550474 753244560 0 -250472520 395568409 253733334 -905302963 -22175383 253733334 -295142960 219022011 0 -842475120 702153900 0 964328...
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #18:
score: 0
Accepted
time: 95ms
memory: 13332kb
input:
100000 -911019359 419672960 0 -644260264 277438519 432643001 235875347 865654842 432643001 -787352212 -700168383 432643001 135263516 996827145 0 -583841971 -584711020 0 -803262005 -201504919 432643001 -61167342 -480267838 0 578620929 -128971548 0 -956623581 -482306231 0 -127822348 -54204288 0 -94967...
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #19:
score: 0
Accepted
time: 101ms
memory: 3712kb
input:
10 -266833289 276035476 0 373459649 -467612305 933997911 -371189489 352437584 182800695 -150099280 -321861957 0 -121996835 98084742 0 338715747 -289373538 0 340335980 -483824387 933997911 -37865990 -58015221 933997911 438614010 -437963778 0 -241701394 193295759 0
output:
probably
result:
ok single line: 'probably'
Test #20:
score: 0
Accepted
time: 99ms
memory: 4472kb
input:
12992 -482427818 379116094 0 193783383 403694148 642614679 -265916229 254827124 642614679 212446080 409490980 0 -240734439 32585028 0 435806883 231200712 642614679 -267494747 271919473 0 340668635 -46131559 642614679 -40089947 -77147783 0 -14707988 177198287 0 -279709820 -97304374 354462630 -1817373...
output:
probably
result:
ok single line: 'probably'
Test #21:
score: 0
Accepted
time: 96ms
memory: 13332kb
input:
100000 486619536 -280157151 0 364107721 -431642578 120822914 456666157 -396140921 0 361540476 -390444524 120822914 283198018 -329641436 0 445190103 -356096752 120822914 19144860 -407607159 120822914 357448825 -328887287 0 126688640 -421525423 0 293187644 -452887073 120822914 127829437 -426378486 120...
output:
probably
result:
ok single line: 'probably'
Test #22:
score: 0
Accepted
time: 97ms
memory: 14016kb
input:
100000 384791586 -206128778 0 464542102 -244267138 0 372152754 -260418149 4765281 219377617 -265165939 4765281 391492059 -300136967 4765281 188373991 -425424825 4765281 319793506 -214990893 0 -67848534 -415947347 4765281 305420597 -499661289 0 387411509 -306532826 0 -58428173 -406523362 4765281 4765...
output:
probably
result:
ok single line: 'probably'
Test #23:
score: 0
Accepted
time: 94ms
memory: 13360kb
input:
100000 -311404589 -233249269 0 -321367178 395257602 0 -430067907 -40638765 478642248 -157246203 177445077 478642248 433888519 -86234298 478642248 390693781 -73578452 0 -143371832 -155559437 478642248 207583658 -467907341 478642248 -280479044 -124586133 478642248 -382252032 265709627 0 217270132 -792...
output:
probably
result:
ok single line: 'probably'
Test #24:
score: 0
Accepted
time: 92ms
memory: 13256kb
input:
100000 -100822455 -25632313 0 481639169 -345633230 0 -159607623 312393104 362584616 -294240781 21523498 362584616 -360661758 455976921 0 405936373 16148482 0 231888592 -288630536 362584616 -437899009 96621309 0 -191271850 -328579038 4292200 -145217963 -140344016 0 -216719816 -132021597 362584616 214...
output:
probably
result:
ok single line: 'probably'
Test #25:
score: 0
Accepted
time: 99ms
memory: 3712kb
input:
10 455846259 -224888203 64829807 332535043 -479768760 0 142251459 -404965628 0 -38001857 -324335831 64829807 190112387 -423742447 0 -197047477 -352464866 64829807 -451825461 -188820484 0 24813369 -142031628 3476005 -28052648 -319119598 64829807 -40622138 -260304584 64829807
output:
probably
result:
ok single line: 'probably'
Test #26:
score: 0
Accepted
time: 100ms
memory: 3712kb
input:
126 377265333 309935082 633106955 -80622237 300823207 633106955 281228801 -218021738 0 312351577 477340265 0 -251323121 -292925746 0 85356411 94832497 0 -140902731 98909679 0 146927027 499409093 0 120523233 -371756829 0 16488122 215951557 633106955 44377457 -32612567 633106955 411446073 216705748 41...
output:
probably
result:
ok single line: 'probably'
Test #27:
score: 0
Accepted
time: 100ms
memory: 8332kb
input:
55412 -189453212 313373083 995031698 -433718573 104442567 995031698 -345219477 123847623 995031698 -465644108 -293601403 0 -479177201 465153343 0 -434371388 433411283 0 -196403288 487949905 995031698 -263244169 67655631 0 -191705482 465320013 0 -287174311 96339569 0 -214487690 99096188 0 -322022469 ...
output:
probably
result:
ok single line: 'probably'
Test #28:
score: 0
Accepted
time: 94ms
memory: 13296kb
input:
100000 405399933 -461059261 0 -337802624 -113080686 344919416 -109336926 -465625363 344919416 -249049989 -169703465 0 -471999979 -363098666 0 189448737 -430645807 344919416 180955506 14764427 344919416 239432881 -117986953 0 11454880 -29287947 344919416 -291195544 -368292588 0 212513069 -218028683 0...
output:
probably
result:
ok single line: 'probably'
Test #29:
score: 0
Accepted
time: 92ms
memory: 13776kb
input:
100000 154340192 -464526344 0 84552615 417912151 0 176335675 -102597355 0 340079523 -219135850 818796383 -253692229 -481561227 0 65030024 128343435 818796383 179902215 332282765 818796383 40994891 -320923787 818796383 -161896610 -458161633 0 435750761 -245284465 818796383 -242748813 -305566601 0 468...
output:
probably
result:
ok single line: 'probably'
Test #30:
score: 0
Accepted
time: 96ms
memory: 13320kb
input:
100000 -5359326 -6243958 702738750 42746494 9608197 0 400175261 185225537 0 83242432 253324081 702738750 -18335774 267253001 702738750 357094934 34307149 0 -53645196 -259814417 702738750 103526161 -454532250 0 -81502683 -154642825 0 -110188476 -243868030 702738750 80119610 -137952665 702738750 -1189...
output:
probably
result:
ok single line: 'probably'
Test #31:
score: 0
Accepted
time: 98ms
memory: 14404kb
input:
100000 88351933 -198517161 0 -388687076 272469378 0 139713374 309226227 881648417 -97806159 -350274461 0 -348079249 304844192 881648417 292612007 -386584300 881648417 -243317034 -368190293 881648417 446283856 477129176 881648417 -172289661 493711843 881648417 -418931391 440658428 881648417 420371653...
output:
probably
result:
ok single line: 'probably'
Test #32:
score: 0
Accepted
time: 100ms
memory: 3712kb
input:
6 76912216 -997552502 809812098 -198184220 -55199053 0 -260106296 156917406 809812098 -365678360 518558582 809812098 -132201680 -281224788 809812098 -141337724 -249928917 809018022
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #33:
score: 0
Accepted
time: 100ms
memory: 3840kb
input:
445 -196289588 -229287709 0 839221532 -145265197 897317033 71515012 -207557749 0 169710032 -199590097 0 -446240548 -249569005 897317033 -874727908 -284336941 897317033 142929572 -201763093 0 919562912 -138746209 897317033 508929192 -172065481 0 446441452 -177135805 897317033 80441832 -206833417 8973...
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #34:
score: 0
Accepted
time: 100ms
memory: 3840kb
input:
575 76664255 -646213617 0 281744767 38145331 0 148780479 -405559921 0 342592831 241196887 0 155541375 -382998637 786485753 155541375 -382998637 87975318 216389439 -179947081 0 144273215 -420600777 0 254701183 -52099805 794451606 387665471 391605447 0 29337983 -804142605 0 446259903 587136575 7944516...
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #35:
score: 0
Accepted
time: 100ms
memory: 3712kb
input:
1479 121266902 259577912 956555420 121266902 259577912 257730889 141951236 550062755 992480451 121266902 259577912 295305535 121266902 259577912 727177954 121266902 259577912 161213673 172037540 972586163 992480451 121266902 259577912 56695060 41036758 -867151176 0 136936852 479642187 0 121266902 25...
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #36:
score: 0
Accepted
time: 100ms
memory: 3712kb
input:
2577 -784935267 893091381 0 -156183117 -109948279 721942830 -383080632 252018207 876422818 -156183117 -109948279 658278768 -156183117 -109948279 712331904 -156183117 -109948279 399747531 -421352502 313072795 0 -407683977 291267585 876422818 -156183117 -109948279 610037945 -552570342 522402811 0 -156...
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #37:
score: 0
Accepted
time: 101ms
memory: 4352kb
input:
11260 -138665843 -405845542 31653882 144793522 -930978262 0 -311141118 -86320342 0 -334237807 -43531750 0 -863361955 936715994 0 -138665843 -405845542 35589294 -2785322 -657575830 350299786 -138665843 -405845542 101129526 98900101 -845956774 350299786 -138665843 -405845542 237604354 -165062059 -3569...
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #38:
score: 0
Accepted
time: 99ms
memory: 3840kb
input:
782 -416115861 224628267 195041195 -98156866 932516995 234242153 -923683431 -905395941 234242153 -351940651 367504891 0 -363608871 341527323 0 -416115861 224628267 87272416 -640729096 -275439917 0 -150663856 815617939 234242153 -416115861 224628267 52787462 -599890326 -184518429 234242153 -868259386...
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #39:
score: 0
Accepted
time: 101ms
memory: 3712kb
input:
4 221097898 -457007279 538681211 -354201092 393966931 0 464001916 -816307501 0 -405338780 469609083 61372751
output:
probably
result:
ok single line: 'probably'
Test #40:
score: 0
Accepted
time: 101ms
memory: 3712kb
input:
125 848653610 -258670439 428531324 986355122 -261630669 0 583843010 -252977689 428531324 223700594 -245235549 0 382586954 -248651199 428531324 605027858 -253433109 0 901615730 -259808989 428531324 403771802 -249106619 428531324 647397554 -254343949 0 340217258 -247740359 0 975762698 -261402959 42853...
output:
probably
result:
ok single line: 'probably'
Test #41:
score: 0
Accepted
time: 100ms
memory: 3712kb
input:
254 467329692 229862833 164145293 938918788 574242297 0 515560395 265083460 661599133 917482920 558588685 0 638816636 355091729 661599133 478047626 237689639 0 719201141 413792774 661599133 799585646 472493819 661599133 762072877 445099998 0 987149491 609462924 0 649534570 362918535 661599133 879970...
output:
probably
result:
ok single line: 'probably'
Test #42:
score: 0
Accepted
time: 101ms
memory: 3840kb
input:
761 -292087663 314140882 27653732 -292087663 314140882 30915174 -272209309 317220283 0 211497305 392152374 30993853 -292087663 314140882 19661827 562681559 446555125 30993853 98853299 374702435 0 -146313067 336723156 30993853 -292087663 314140882 8834347 874109105 494799074 0 -292087663 314140882 20...
output:
probably
result:
ok single line: 'probably'
Test #43:
score: 0
Accepted
time: 100ms
memory: 3840kb
input:
1294 273339453 -748961023 0 430462319 -350352602 29151236 174439781 -999861755 209903520 199164699 -937136572 0 430462319 -350352602 103073006 430462319 -350352602 161052677 377822171 -483896540 209903520 430462319 -350352602 205179576 216711415 -892621926 0 353894831 -544598330 0 339538427 -5810194...
output:
probably
result:
ok single line: 'probably'
Test #44:
score: 0
Accepted
time: 99ms
memory: 3840kb
input:
1759 447979593 280121208 88725328 447979593 280121208 283925412 -616005351 342780816 388813187 447979593 280121208 172703699 447979593 280121208 208397200 -281494933 323081015 388813187 121529667 299346315 0 -583763383 340882040 0 447979593 280121208 225019441 -221041243 319520810 0 447979593 280121...
output:
probably
result:
ok single line: 'probably'
Test #45:
score: 0
Accepted
time: 101ms
memory: 3840kb
input:
2125 170529574 279191237 63097348 170529574 279191237 75304608 170529574 279191237 263301275 170529574 279191237 411377258 170529574 279191237 165359863 676612162 -351477703 0 170529574 279191237 33315902 170529574 279191237 185428287 316220016 97635027 567722854 170529574 279191237 170065938 170529...
output:
probably
result:
ok single line: 'probably'
Test #46:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
4 -23362375 -6792784 547064938 23778296 61082152 104302760 -42024459 88573038 0 -31663927 99805405 446289904
output:
probably
result:
ok single line: 'probably'
Test #47:
score: 0
Accepted
time: 301ms
memory: 3712kb
input:
125 3455191 -50114032 0 -28453691 36924628 0 79902719 44830046 861292284 3941284 -8775681 0 -43360011 65854051 861292284 -24081798 -27465649 861292284 47463441 26086302 861292284 96288762 -9992369 861292284 28800001 -56589474 861292284 50095958 -57960670 0 -40194677 60022468 861292284 9746416 -50778...
output:
probably
result:
ok single line: 'probably'
Test #48:
score: 0
Accepted
time: 300ms
memory: 4416kb
input:
12233 -5647740 62164908 0 -29500981 37388655 284831198 14742167 -3340258 284831198 11448719 37128440 284831198 -27221799 33815501 284831198 -34137958 27319978 0 27644163 -3351001 284831198 -14697767 49215880 0 -22884737 25057221 284831198 -33815555 55073596 284831198 -27437501 -6931906 0 -3060758 43...
output:
probably
result:
ok single line: 'probably'
Test #49:
score: 0
Accepted
time: 300ms
memory: 13316kb
input:
100000 -8415004 33371661 962303556 -4000838 6238020 962303556 -80299844 55860651 962303556 -163941696 55392142 0 -117967260 30429588 962303556 -71839392 1018239 0 -26419789 79154902 0 -70823718 50017486 0 -163322064 12250757 962303556 -84819821 -3241578 0 -39808011 -36197506 0 -78292788 -10896306 96...
output:
probably
result:
ok single line: 'probably'
Test #50:
score: 0
Accepted
time: 297ms
memory: 13312kb
input:
100000 -80829956 82399267 0 -42302074 22331454 0 -37752257 29309915 141213224 -100576690 19036145 141213224 18171681 89472281 0 -13923840 25604733 0 -12032486 43650754 0 -94474050 15283912 141213224 -24349055 35689925 0 15145440 63253549 0 -12191322 120319803 0 -94772832 42944640 0 39711070 75639433...
output:
probably
result:
ok single line: 'probably'
Test #51:
score: 0
Accepted
time: 295ms
memory: 13320kb
input:
100000 28392177 106312309 0 51959880 131298635 320122892 40094599 52487391 320122892 35328354 73654633 0 -16729884 67899060 0 82534683 69777898 0 80790415 -4686458 0 -48822180 8785043 0 70318052 44938277 0 111817812 19713774 320122892 -23201814 87682594 0 5978885 -21694465 320122892 104305804 240094...
output:
probably
result:
ok single line: 'probably'
Test #52:
score: 0
Accepted
time: 295ms
memory: 13316kb
input:
100000 70199611 -12147140 0 -15670038 36243532 204065259 110474484 -9553202 0 63243735 60979210 0 18973178 68084656 0 72460850 -31374045 204065259 44027051 41232621 204065259 52022921 13768326 0 40190899 87178159 204065259 -884879 77831430 0 58853039 71449315 204065259 76662655 -37939949 204065259 7...
output:
probably
result:
ok single line: 'probably'
Test #53:
score: 0
Accepted
time: 1ms
memory: 3712kb
input:
40 -558841073 45356782 0 -948650243 -439296602 0 -115959293 595995838 0 -745510253 -186730754 0 -754660703 -198107594 0 -75697313 646053934 0 -507598553 109067086 734030171 -163541633 536836270 0 110971867 878141470 0 -227594783 457198390 0 -875446643 -348281882 734030171 -685117283 -111643610 0 -53...
output:
probably
result:
ok single line: 'probably'
Test #54:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
480 -69850213 -430849423 321889773 -875513977 -627051614 321889773 785648423 -222511014 0 337134575 -331736976 0 -676174489 -578506742 0 868706543 -202283984 0 -742620985 -594688366 321889773 760730987 -228579123 0 -510058249 -538052682 321889773 270688079 -347918600 0 -593116369 -558279712 0 420192...
output:
probably
result:
ok single line: 'probably'
Test #55:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
294 725213479 -181129461 183271860 290241511 -98606837 0 -593295299 69017243 183271860 969885211 -227548437 0 195091393 -80555013 0 -470959433 45807755 183271860 534913243 -145025813 183271860 -538923803 58701915 183271860 31976905 -49609029 0 -443773685 40650091 183271860 847549345 -204338949 18327...
output:
probably
result:
ok single line: 'probably'
Test #56:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
844 -343451638 -404374034 0 638572715 -652458566 272597964 709733900 -670435706 0 -803627301 -288121862 272597964 -760930590 -298908146 0 -153688478 -452313074 272597964 -139456241 -455908502 0 -77783214 -471488690 272597964 -746698353 -302503574 0 168908894 -533809442 272597964 249558237 -554183534...
output:
probably
result:
ok single line: 'probably'
Test #57:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
132 85344089 312755777 156540331 473982665 -206432731 0 -130566231 601193837 156540331 992167433 -898684075 4942627 -108975199 572350031 156540331 -411249647 976163315 21874592 538755761 -292964149 156540331 150117185 226224359 156540331 711484017 -523714597 156540331 992167433 -898684075 156540331 ...
output:
probably
result:
ok single line: 'probably'
Test #58:
score: 0
Accepted
time: 1ms
memory: 3840kb
input:
538 416602356 -232440821 335449998 109453136 808521059 0 423184125 -254747147 335449998 306906206 139331279 0 508747122 -544729385 335449998 83126060 897746363 0 541655967 -656261015 0 282773053 221121141 335449998 223537132 421878075 335449998 537268121 -641390131 0 473644354 -425762313 335449998 2...
output:
probably
result:
ok single line: 'probably'
Test #59:
score: 0
Accepted
time: 1ms
memory: 3840kb
input:
624 861871796 707941945 0 20974674 174627452 0 650042750 573595546 219392365 -421940604 -106278655 0 855452734 703870842 0 -929046502 -427895792 0 451051828 447391353 219392365 714233370 614306576 219392365 -730055580 -301691599 0 -473293100 -138847479 0 816938362 679444224 0 380442146 402609220 0 -...
output:
probably
result:
ok single line: 'probably'
Test #60:
score: 0
Accepted
time: 100ms
memory: 3712kb
input:
6 -108857721 -212156569 0 195164185 86760306 277221751 -608163771 -703078444 0 -712463257 -805626569 0 -781256535 -873264694 212196853 352722983 241673431 0
output:
probably
result:
ok single line: 'probably'
Test #61:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
776 725808628 731097639 501871744 705326754 690340713 501871744 101111471 -511988604 0 -128578116 -969048417 501871744 -72984458 -858422475 0 396635653 76075614 501871744 1628083 -709950816 0 832606971 943615896 0 654122069 588448398 0 65999687 -581857620 501871744 25035939 -663371472 0 629251222 53...
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #62:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
442 226323771 213022371 0 -415594684 -108056740 0 -270937004 -35700884 644539031 669337916 434612180 644539031 108789406 154233238 644539031 380022556 289900468 0 -623540099 -212068283 0 -551211259 -175890355 644539031 470433606 335122878 0 479474711 339645119 0 976735486 588368374 644539031 8863244...
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #63:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
404 -21149265 478787121 333462952 -604401165 45252551 333462952 112165455 577880737 0 -854366265 -140547979 333462952 12179415 503560525 0 -721051545 -41454363 0 153826305 608847492 333462952 -854366265 -140547979 0 -687722865 -16680959 333462952 403791405 794648022 333462952 -46145775 460207068 0 -...
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #64:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
1174 -599431710 343743991 0 -746887998 833781175 0 -476551470 -64620329 0 -218502966 -922185401 0 -388487298 -357281425 0 -699783906 677241519 217405319 -472455462 -78232473 217405319 -420231360 -251787309 217405319 -526727568 102128435 0 -635271780 462850251 217405319 -724359954 758914383 0 -600455...
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #65:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
996 98776583 -435695114 0 -41821287 -378728134 0 -672503161 -123190538 0 817834261 -727040526 396314986 -347119519 -255028406 0 596894751 -637520986 396314986 416126061 -564277726 396314986 -511819881 -188295658 0 516553111 -604968426 0 -656434833 -129701050 396314986 -230624141 -302229618 0 5860576...
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #66:
score: 0
Accepted
time: 1ms
memory: 3840kb
input:
312 -906730190 -81531225 575224653 900939160 -126837768 0 362484460 -113342202 575224653 -419556890 -93741499 575224653 747094960 -122981892 0 -804167390 -84101809 0 734274610 -122660569 575224653 -945191240 -80567256 575224653 298382710 -111735587 575224653 -240071990 -98240021 575224653 -829808090...
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #67:
score: 0
Accepted
time: 400ms
memory: 3584kb
input:
8 171582597 52719320 130718979 183402422 -213849186 130718979 181402615 183187192 0 174180999 -242949305 130718979 -477564760 -186620984 96802117 8931586 348459979 0 484146186 -154485408 0 116017210 299794887 107608089
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #68:
score: 0
Accepted
time: 400ms
memory: 3712kb
input:
123 -395068085 130600610 394949921 456007846 -293166947 0 -256642449 -116373061 394949921 285806035 -125503593 394949921 456899792 450145016 0 294336137 -121949969 0 -387694944 325366333 0 483735521 -436899311 394949921 313051700 -439616400 394949921 -254337671 -330854038 394949921 -270663901 -26945...
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #69:
score: 0
Accepted
time: 401ms
memory: 4604kb
input:
9923 284640557 261766669 320661107 388905962 -136834985 320661107 139020182 151022021 320661107 -135985019 -269396387 0 -315982519 -324975657 0 -394096403 -154242912 320661107 261250547 202013548 0 373016179 167558970 0 -399293104 41450859 0 363095418 353133940 0 -388082712 -58786927 0 -256074363 20...
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #70:
score: 0
Accepted
time: 399ms
memory: 13152kb
input:
100000 99432747 -475527415 511767701 237643427 -66821752 0 216896510 -405122025 0 106223646 -260995190 511767701 -320041260 479277782 511767701 -839341 -354243787 0 429213358 48144685 0 -445438418 -366427378 0 105458517 54213625 511767701 -389345058 -257514928 511767701 -453116296 294347073 0 242840...
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #71:
score: 0
Accepted
time: 395ms
memory: 13320kb
input:
100000 -145374343 315401751 690677368 -188104756 -30866722 690677368 -497241773 -389990718 0 -497503746 133654925 690677368 115419310 59001937 0 -269935067 -160445337 0 471732811 -484373398 0 -72315680 -282512931 0 -81483075 387551074 690677368 -10297034 -214271035 0 -334996245 151655920 690677368 -...
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #72:
score: 0
Accepted
time: 396ms
memory: 13316kb
input:
100000 -489326632 -89282176 574619735 -278601230 -396826633 574619735 -455219603 -168478314 574619735 -491560655 180108341 0 191635179 -62320546 0 17130897 -157146851 0 -298198007 -495489929 0 -67024440 -181173438 0 434657619 469664978 574619735 248895645 -463175247 574619735 -278581877 -9458978 574...
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #73:
score: 0
Accepted
time: 395ms
memory: 13312kb
input:
100000 430908517 391416546 0 136855048 346742183 0 -359173480 387093798 753529402 26998959 -108338949 0 -106695634 403092845 753529402 139517954 -461361368 0 81678589 -409624955 0 -398107870 -454115884 0 -436677373 403194412 753529402 234395998 -334214521 0 -53472542 -341933081 753529402 -445682120 ...
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #74:
score: 0
Accepted
time: 500ms
memory: 3712kb
input:
5 -424417427 21129016 24574907 -624096987 448255670 9627334 -50214787 -779313060 0 -742017987 700495820 13540440 -136690187 -594336950 51330898
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #75:
score: 0
Accepted
time: 498ms
memory: 3712kb
input:
123 -602012198 -926219994 302822866 296060263 -179514474 302822866 -426631044 -780398714 302822866 423060409 -73919754 302822866 -532464499 -868394314 0 604489189 76929846 0 265822133 -204656074 0 946180058 361029926 0 135798174 -312764954 0 -511297808 -850795194 0 849418042 280576806 302822866 5016...
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #76:
score: 0
Accepted
time: 500ms
memory: 3584kb
input:
1554 -344038803 450300125 430073056 -315128335 69482953 430073056 -318058450 108079288 430073056 -273520702 -478585004 430073056 -375488704 864567454 0 -319816519 131237089 430073056 -261018878 -643262700 0 -296766281 -172387413 430073056 -308486741 -18002073 430073056 -369823815 789947873 0 -237187...
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #77:
score: 0
Accepted
time: 501ms
memory: 3712kb
input:
414 467199404 844803913 0 156167859 312192548 576281472 178788335 350927920 576281472 -539411778 -878920141 576281472 -392378684 -627140223 0 31755241 99148002 0 -98312496 -123580387 576281472 444578928 806068541 0 320166310 593023995 0 127892264 263773333 576281472 -465895231 -753030182 576281472 4...
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #78:
score: 0
Accepted
time: 500ms
memory: 3840kb
input:
788 -312513413 -384732191 460223839 -349314469 306276057 0 -356349965 438380575 460223839 -332266921 -13823352 0 -281124277 -974121579 460223839 -344714337 219900026 0 -326313809 -125604098 460223839 -283289045 -933474035 460223839 -375832877 804208471 460223839 -312513413 -384732191 0 -293571693 -7...
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #79:
score: 0
Accepted
time: 499ms
memory: 3840kb
input:
1146 310899796 124988389 344166206 930720532 -499565855 344166206 -363291180 804328093 344166206 998683332 -568047680 344166206 -480187196 922116832 344166206 -235521116 675582262 0 -461157612 902941921 0 -409505884 850895734 0 245655508 190730941 344166206 425077300 9938923 344166206 672461892 -239...
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #80:
score: 0
Accepted
time: 500ms
memory: 3712kb
input:
516 -429150459 -515127323 523075873 942874245 -310892687 0 175470597 -425125619 523075873 377010949 -395125051 523075873 -10566651 -452818451 0 -576429947 -537050815 0 245234565 -414740807 0 485532677 -378970899 0 51445765 -443587507 523075873 -390392699 -509357983 0 -196603899 -480511283 523075873 ...
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #81:
score: 0
Accepted
time: 500ms
memory: 3712kb
input:
5 302739376 -16766967 159216287 257193015 -402383485 68046359 313604685 -199622920 543782931 80257839 -346936212 543782931 45440081 -402075063 132344479
output:
probably
result:
ok single line: 'probably'
Test #82:
score: 0
Accepted
time: 501ms
memory: 3712kb
input:
123 -212956321 206352395 0 -147016602 164919048 61953451 -173166678 192445180 507571801 -375910513 311234566 0 -160760826 109511213 507571801 -451727949 256701608 507571801 -309581030 -16592497 507571801 -225738470 190042183 507571801 -319249132 270096287 0 -212899041 123256308 507571801 -224820045 ...
output:
probably
result:
ok single line: 'probably'
Test #83:
score: 0
Accepted
time: 499ms
memory: 4224kb
input:
6651 -74160955 366698613 241206985 -308467841 75599629 241206985 55362539 -29875114 241206985 385140845 172305042 0 27640690 388188188 241206985 -142701231 142367900 0 73080551 -39114365 0 202675013 346782704 0 174495058 255381321 241206985 -150755133 -197609396 0 121658658 283242198 0 148153672 126...
output:
probably
result:
ok single line: 'probably'
Test #84:
score: 0
Accepted
time: 496ms
memory: 13312kb
input:
100000 69741142 -252324164 386397230 -57486209 -396571901 386397230 -262787330 -158004890 0 108201594 -471730744 386397230 -123263315 81680541 386397230 -322759490 -108592899 386397230 -279797859 -296681228 386397230 -66810644 135096524 386397230 150255656 -438222756 0 138970289 -73996438 386397230 ...
output:
probably
result:
ok single line: 'probably'
Test #85:
score: 0
Accepted
time: 499ms
memory: 13316kb
input:
100000 182380991 -266074143 0 273324841 -157174622 860274197 379593093 -372147840 0 626936910 -136785998 0 474306903 -55640804 0 526696639 -339688321 0 228565941 -327815155 860274197 381743348 114217783 0 218503348 -205715496 0 647154804 -196691548 860274197 587775458 44555112 860274197 617462693 -1...
output:
probably
result:
ok single line: 'probably'
Test #86:
score: 0
Accepted
time: 496ms
memory: 13312kb
input:
100000 -436617113 82021370 744216564 -155195306 -281200493 744216564 -421032660 -178376836 744216564 265242960 -384923425 0 50082507 -53356280 744216564 -374953833 -244093673 744216564 42176767 -131272045 744216564 -24616379 105445 744216564 157629861 121079363 744216564 -410317470 -132174720 744216...
output:
probably
result:
ok single line: 'probably'
Test #87:
score: 0
Accepted
time: 498ms
memory: 13320kb
input:
100000 8244577 395040094 923126232 75378243 276264850 0 14751248 216332815 0 49218942 262738349 0 -20973502 264644653 923126232 -12668228 271817987 0 65269649 335188389 923126232 -16362504 321820916 0 -137313035 318551722 923126232 2172988 229825457 923126232 -34250061 424873009 0 63702140 242644614...
output:
probably
result:
ok single line: 'probably'
Test #88:
score: 0
Accepted
time: 496ms
memory: 13316kb
input:
100000 85308917 299968771 0 122121620 273696971 807068599 36198149 350159497 0 53115230 361861497 807068599 -50016928 71652836 0 213587599 273979964 0 134221324 -13221180 0 203677383 233358063 807068599 134040700 134807487 0 229526770 154787359 807068599 245896152 97961364 807068599 110776827 269772...
output:
probably
result:
ok single line: 'probably'
Test #89:
score: 0
Accepted
time: 496ms
memory: 13320kb
input:
100000 95363228 -37983298 985978266 218822224 146151943 985978266 -89919338 433718285 0 216184098 136808073 985978266 38100683 -27874775 985978266 -110636012 405778341 0 69198238 57969673 985978266 31886549 -52932944 0 -134791892 33919783 985978266 315171131 319779159 0 -106271723 369068462 98597826...
output:
probably
result:
ok single line: 'probably'
Test #90:
score: 0
Accepted
time: 494ms
memory: 13316kb
input:
100000 495090797 345311111 164887934 824293550 680948331 164887934 341340428 354950684 164887934 232716141 506526313 0 461960129 255806227 0 541430759 439033101 164887934 462406562 708343046 0 523664493 672333978 164887934 173539534 682964497 0 470681497 910040697 0 139893451 565847253 164887934 474...
output:
probably
result:
ok single line: 'probably'
Test #91:
score: 0
Accepted
time: 495ms
memory: 13320kb
input:
100000 305115826 -137436442 48830301 153938349 126273482 0 -69641484 -281894723 0 67243343 -227974364 0 162943917 -48272227 48830301 70808030 11291077 48830301 219713277 -133619952 48830301 -110453857 243791647 0 -109729037 187977735 48830301 -45040454 -179499342 0 54655789 195941536 0 431335166 -29...
output:
probably
result:
ok single line: 'probably'
Test #92:
score: 0
Accepted
time: 500ms
memory: 3712kb
input:
5 -442341932 199502624 38032293 -135455597 -364587295 407649886 335867107 -379451018 108674395 -445037144 253719370 407649886 19766594 -425812101 91347238
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #93:
score: 0
Accepted
time: 499ms
memory: 3712kb
input:
123 459893670 320172100 315836954 -339108849 -329265309 955103549 7985344 -240172469 955103549 -234338631 142208016 955103549 443018280 370625493 0 -442227352 -127961702 955103549 40505952 473709214 955103549 347736289 -73330083 0 298030829 -431535512 0 -29054969 -92929766 0 143595622 -455751068 0 -...
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #94:
score: 0
Accepted
time: 498ms
memory: 4212kb
input:
6651 278545501 29152043 0 460010313 272553531 0 -484611211 -410800985 0 -490221615 -478005842 0 88846651 302950773 0 382755535 65790691 0 25464072 -493643418 0 -124998350 494023558 0 -360378086 -47609948 509404277 -249625195 246722644 0 197719200 348278667 0 -12521733 -387896675 509404277 395729932 ...
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #95:
score: 0
Accepted
time: 497ms
memory: 13312kb
input:
100000 447265076 -395719496 445986182 -444760481 -35302899 0 385682942 -418294131 0 -448083342 458054159 445986182 -58052452 380193153 445986182 109315127 -219079462 445986182 -142018258 216100940 0 446014235 -229055765 445986182 351001571 346416334 445986182 364416771 -383813827 0 -248495145 -48153...
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #96:
score: 0
Accepted
time: 496ms
memory: 13312kb
input:
100000 -464283071 383202895 0 329534720 258916868 0 174721417 158646785 329928549 9436983 289144291 329928549 -471694511 -463673637 329928549 45672772 46264965 0 392920733 -53701006 329928549 494812190 497441631 0 -392824498 185645091 0 40781315 -38073387 329928549 63791614 403351987 0 -455864277 -3...
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #97:
score: 0
Accepted
time: 496ms
memory: 13316kb
input:
100000 339422210 453677538 0 437149926 408882154 803805516 476320490 248891155 803805516 35241311 155813687 0 -422682121 -333022946 803805516 314422585 -397846045 803805516 -218920737 -188175760 803805516 474196858 -46554974 0 -237192754 -336173721 0 148473920 -304051224 0 287540115 322468798 803805...
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #98:
score: 0
Accepted
time: 495ms
memory: 13316kb
input:
100000 60645406 -356923095 687747883 103675636 -409564453 687747883 476021208 52473839 687747883 -335651101 302291934 687747883 -416620400 -475382123 0 127379316 -483316845 687747883 246102132 -84923675 687747883 -249845324 431020477 687747883 -212119640 -343167580 0 317725651 195784283 0 380148930 ...
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #99:
score: 0
Accepted
time: 498ms
memory: 13120kb
input:
100000 -394790518 -360411716 0 374667696 163248281 866657550 -372271021 -337436995 866657550 103369730 -81145599 866657550 33597226 -443631600 866657550 229042682 -119858366 0 -488564494 -275076219 0 259524094 -53593918 866657550 -270225829 425930210 0 478301348 473982426 0 249034012 118690883 0 -28...
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #100:
score: 0
Accepted
time: 496ms
memory: 13312kb
input:
100000 -407950507 -461218654 0 436650858 424073367 0 -307491286 -12293914 750599917 189033159 -335912969 750599917 195544265 -289423466 0 454422156 -382502738 0 74252513 -418431928 750599917 -95083855 174674014 0 97625238 80542553 750599917 196668276 375503087 0 -475418389 -294829562 0 108671738 -19...
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #101:
score: 0
Accepted
time: 498ms
memory: 13164kb
input:
100000 466516749 -303090508 224476885 10056462 143665821 0 322547109 -392091326 0 -364097820 -377754105 0 -423265552 109700230 224476885 -119269304 -459590088 224476885 250284462 -343799015 0 -88433273 -330448846 224476885 -211128112 -122723537 224476885 -162153295 -19617268 224476885 257071123 4395...
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #102:
score: 0
Accepted
time: 497ms
memory: 13316kb
input:
100000 273749107 -377651819 0 -267729448 -94095620 0 -366845304 -170612035 0 107463648 -447012890 108419252 -164079308 -50295989 108419252 -491451064 -391375090 0 -323119105 38319083 0 -69139923 283338404 0 12885397 -211383306 0 -230073755 3174062 0 -44839548 -19756720 108419252 -207869707 -25962671...
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #103:
score: 0
Accepted
time: 501ms
memory: 3712kb
input:
5 471 337 0 490 353 19565336 917 -783 360170598 471 337 893561473 658 -739 119747863
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #104:
score: 0
Accepted
time: 501ms
memory: 3712kb
input:
5 -764 48 978489746 -754 118 213372808 -367 -474 111112453 -764 48 0 216 123 252660910
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #105:
score: 0
Accepted
time: 500ms
memory: 3712kb
input:
5 -599 -701 429014663 -513 211 352669398 -98 486 348646581 -599 -701 0 803 -793 322757035
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #106:
score: 0
Accepted
time: 400ms
memory: 3712kb
input:
4 0 0 1 1 400 1 100000 40000001 2 100000 39999999 2
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #107:
score: 0
Accepted
time: 1ms
memory: 3584kb
input:
4 100000000 100000000 1 100000001 100000400 1 100100000 140000001 2 100010000 104000001 2
output:
probably
result:
ok single line: 'probably'
Test #108:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
4 100000000 100000000 1 100000001 100001000 1 100100000 200000001 2 100010000 110000001 2
output:
probably
result:
ok single line: 'probably'
Test #109:
score: 0
Accepted
time: 1ms
memory: 3712kb
input:
4 800000000 800000000 1 800000001 800000040 1 801000000 840000001 2 800100000 804000001 2
output:
probably
result:
ok single line: 'probably'
Test #110:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
4 800000000 800000000 1 800000001 800000004 1 810000000 840000001 2 801000000 804000001 2
output:
probably
result:
ok single line: 'probably'
Test #111:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
4 800000000 800000000 1 800000001 800000008 1 810000000 880000001 2 801000000 808000001 2
output:
probably
result:
ok single line: 'probably'
Test #112:
score: 0
Accepted
time: 100ms
memory: 3712kb
input:
5 0 0 0 0 0 1 0 0 2 0 0 3 0 0 4
output:
probably
result:
ok single line: 'probably'
Test #113:
score: 0
Accepted
time: 1ms
memory: 3712kb
input:
3 0 0 3 1 2 1 2 4 2
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #114:
score: 0
Accepted
time: 100ms
memory: 3712kb
input:
3 0 0 3 1 2 0 2 4 1
output:
probably
result:
ok single line: 'probably'
Test #115:
score: 0
Accepted
time: 1ms
memory: 3712kb
input:
2 0 0 1 1 1 1
output:
probably
result:
ok single line: 'probably'
Test #116:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
2 0 0 1 0 0 0
output:
probably
result:
ok single line: 'probably'
Test #117:
score: 0
Accepted
time: 100ms
memory: 3712kb
input:
10 0 0 1 -2 -2 2 -3 -3 2 -4 -4 2 -5 -5 2 -6 -6 2 -7 -7 2 -8 -8 2 -2 2 2 2 -2 2
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #118:
score: 0
Accepted
time: 499ms
memory: 3712kb
input:
67 -50000000 0 45519 -49856000 3792000 48763 -49856000 -3792000 48763 -48923520 10319360 88888 -48923520 -10319360 88888 -48000000 14000000 45519 -48000000 -14000000 88888 -46800000 17600000 45519 -46800000 -17600000 48763 -45330432 21098624 88888 -45330432 -21098624 88888 -42160000 26880000 48763 -...
output:
probably
result:
ok single line: 'probably'
Test #119:
score: 0
Accepted
time: 501ms
memory: 3712kb
input:
67 -50000000 0 45519 -49856000 3792000 48763 -49856000 -3792000 48763 -48923520 10319360 88888 -48923520 -10319360 88888 -48000000 14000000 45519 -48000000 -14000000 88888 -46800000 17600000 45519 -46800000 -17600000 48763 -45330432 21098625 88888 -45330432 -21098624 88888 -42160000 26880000 48763 -...
output:
not a penguin
result:
ok single line: 'not a penguin'
Test #120:
score: 0
Accepted
time: 101ms
memory: 3712kb
input:
4 -1000000000 -1000000000 0 -999999999 0 2 -1000000000 1000000000 0 -1000000000 0 1
output:
not a penguin
result:
ok single line: 'not a penguin'
Extra Test:
score: -3
Extra Test Failed : Wrong Answer on 8
time: 500ms
memory: 3712kb
input:
5 0 0 0 0 0 2 0 0 1 0 1 1 1 999999999 1
output:
not a penguin
result:
wrong answer 1st lines differ - expected: 'probably', found: 'not a penguin'