QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#33173#1818. Apple OrchardbulijiojiodibuliduoAC ✓6115ms4592kbC++12.5kb2022-05-29 07:00:422022-05-29 07:00:45

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-29 07:00:45]
  • Judged
  • Verdict: AC
  • Time: 6115ms
  • Memory: 4592kb
  • [2022-05-29 07:00:42]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef basic_string<int> BI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

//typedef double db;
const db EPS = 1e-9;
  
inline int sign(db a) { return a < -EPS ? -1 : a > EPS; }
  
inline int cmp(db a, db b){ return sign(a-b); }
  
struct P {
	db x, y;
	P() {}
	P(db _x, db _y) : x(_x), y(_y) {}
	P operator+(P p) { return {x + p.x, y + p.y}; }
	P operator-(P p) { return {x - p.x, y - p.y}; }
	P operator*(db d) { return {x * d, y * d}; }
	P operator/(db d) { return {x / d, y / d}; }
 
	bool operator<(P p) const { 
		int c = cmp(x, p.x);
		if (c) return c == -1;
		return cmp(y, p.y) == -1;
	}
 
	bool operator==(P o) const{
		return cmp(x,o.x) == 0 && cmp(y,o.y) == 0;
	}
 
	db dot(P p) { return x * p.x + y * p.y; }
	db det(P p) { return x * p.y - y * p.x; }
	 
	db distTo(P p) { return (*this-p).abs(); }
	db alpha() { return atan2(y, x); }
	void read() { cin>>x>>y; }
	void write() {cout<<"("<<x<<","<<y<<")"<<endl;}
	db abs() { return sqrt(abs2());}
	db abs2() { return x * x + y * y; }
	P rot90() { return P(-y,x);}
	P unit() { return *this/abs(); }
	int quad() const { return sign(y) == 1 || (sign(y) == 0 && sign(x) >= 0); }
	P rot(db an){ return {x*cos(an)-y*sin(an),x*sin(an) + y*cos(an)}; }
};
  
struct L{ //ps[0] -> ps[1]
	P ps[2];
	P dir_;
	P& operator[](int i) { return ps[i]; }
	P dir() { return dir_; }
	L (P a,P b) {
		ps[0]=a;
		ps[1]=b;
		dir_ = (ps[1]-ps[0]).unit();
	}
	bool include(P p) { return sign((dir_).det(p - ps[0])) > 0; }
	L push(){ // push eps outward
		const double eps = 1e-8;
		P delta = (ps[1] - ps[0]).rot90().unit() * eps;
		return {ps[0] + delta, ps[1] + delta};
	}
};

#define cross(p1,p2,p3) ((p2.x-p1.x)*(p3.y-p1.y)-(p3.x-p1.x)*(p2.y-p1.y))
#define crossOp(p1,p2,p3) sign(cross(p1,p2,p3))
  
bool chkLL(P p1, P p2, P q1, P q2) {
	db a1 = cross(q1, q2, p1), a2 = -cross(q1, q2, p2);
	return sign(a1+a2) != 0;
}
 
P isLL(P p1, P p2, P q1, P q2) {
	db a1 = cross(q1, q2, p1), a2 = -cross(q1, q2, p2);
	return (p1 * a2 + p2 * a1) / (a1 + a2);
}
  
P isLL(L l1,L l2){ return isLL(l1[0],l1[1],l2[0],l2[1]); }
  
bool intersect(db l1,db r1,db l2,db r2){
	if(l1>r1) swap(l1,r1); if(l2>r2) swap(l2,r2); 
	return !( cmp(r1,l2) == -1 || cmp(r2,l1) == -1 );
}
  
bool isSS(P p1, P p2, P q1, P q2){
	return intersect(p1.x,p2.x,q1.x,q2.x) && intersect(p1.y,p2.y,q1.y,q2.y) && 
	crossOp(p1,p2,q1) * crossOp(p1,p2,q2) <= 0 && crossOp(q1,q2,p1)
			* crossOp(q1,q2,p2) <= 0;
}
  
bool isSS_strict(P p1, P p2, P q1, P q2){
	return crossOp(p1,p2,q1) * crossOp(p1,p2,q2) < 0 && crossOp(q1,q2,p1)
			* crossOp(q1,q2,p2) < 0;
}
  
bool isMiddle(db a, db m, db b) {
	return sign(a - m) == 0 || sign(b - m) == 0 || (a < m != b < m);
}
  
bool isMiddle(P a, P m, P b) {
	return isMiddle(a.x, m.x, b.x) && isMiddle(a.y, m.y, b.y);
}
  
bool onSeg(P p1, P p2, P q){
	return crossOp(p1,p2,q) == 0 && isMiddle(p1, q, p2);
}
 
bool onSeg_strict(P p1, P p2, P q){
	return crossOp(p1,p2,q) == 0 && sign((q-p1).dot(p1-p2)) * sign((q-p2).dot(p1-p2)) < 0;
}
  
P proj(P p1, P p2, P q) {
	P dir = p2 - p1;
	return p1 + dir * (dir.dot(q - p1) / dir.abs2());
}
  
P reflect(P p1, P p2, P q){
	return proj(p1,p2,q) * 2 - q;
}
  
db nearest(P p1,P p2,P q){
	if (p1==p2) return p1.distTo(q);
	P h = proj(p1,p2,q);
	if(isMiddle(p1,h,p2))
		return q.distTo(h);
	return min(p1.distTo(q),p2.distTo(q));
}
  
db disSS(P p1, P p2, P q1, P q2){
	if(isSS(p1,p2,q1,q2)) return 0;
	return min(min(nearest(p1,p2,q1),nearest(p1,p2,q2)), min(nearest(q1,q2,p1),nearest(q1,q2,p2)));
}
  
db rad(P p1,P p2){
	return atan2l(p1.det(p2),p1.dot(p2));
}
  
db incircle(P p1, P p2, P p3){
	db A = p1.distTo(p2);
	db B = p2.distTo(p3);
	db C = p3.distTo(p1);
	return sqrtl(A*B*C/(A+B+C));
}
  
//polygon
  
db area(vector<P> ps){
	db ret = 0; rep(i,0,ps.size()) ret += ps[i].det(ps[(i+1)%ps.size()]); 
	return ret/2;
}
  
int contain(vector<P> ps, P p){ //2:inside,1:on_seg,0:outside
	int n = ps.size(), ret = 0; 
	rep(i,0,n){
		P u=ps[i],v=ps[(i+1)%n];
		if(onSeg(u,v,p)) return 1;
		if(cmp(u.y,v.y)<=0) swap(u,v);
		if(cmp(p.y,u.y) >0 || cmp(p.y,v.y) <= 0) continue;
		ret ^= crossOp(p,u,v) > 0;
	}
	return ret*2;
}
  
vector<P> convexHull(vector<P> ps) {
	int n = ps.size(); if(n <= 1) return ps;
	sort(ps.begin(), ps.end());
	vector<P> qs(n * 2); int k = 0;
	for (int i = 0; i < n; qs[k++] = ps[i++]) 
		while (k > 1 && crossOp(qs[k - 2], qs[k - 1], ps[i]) <= 0) --k;
	for (int i = n - 2, t = k; i >= 0; qs[k++] = ps[i--])
		while (k > t && crossOp(qs[k - 2], qs[k - 1], ps[i]) <= 0) --k;
	qs.resize(k - 1);
	return qs;
}
  
vector<P> convexHullNonStrict(vector<P> ps) {
	//caution: need to unique the Ps first
	int n = ps.size(); if(n <= 1) return ps;
	sort(ps.begin(), ps.end());
	vector<P> qs(n * 2); int k = 0;
	for (int i = 0; i < n; qs[k++] = ps[i++]) 
		while (k > 1 && crossOp(qs[k - 2], qs[k - 1], ps[i]) < 0) --k;
	for (int i = n - 2, t = k; i >= 0; qs[k++] = ps[i--])
		while (k > t && crossOp(qs[k - 2], qs[k - 1], ps[i]) < 0) --k;
	qs.resize(k - 1);
	return qs;
}
  
db convexDiameter(vector<P> ps){
	int n = ps.size(); if(n <= 1) return 0;
	int is = 0, js = 0; rep(k,1,n) is = ps[k]<ps[is]?k:is, js = ps[js] < ps[k]?k:js;
	int i = is, j = js;
	db ret = ps[i].distTo(ps[j]);
	do{
		if((ps[(i+1)%n]-ps[i]).det(ps[(j+1)%n]-ps[j]) >= 0)
			(++j)%=n;
		else
			(++i)%=n;
		ret = max(ret,ps[i].distTo(ps[j]));
	}while(i!=is || j!=js);
	return ret;
}
  
vector<P> convexCut(const vector<P>&ps, P q1, P q2) {
	vector<P> qs;
	int n = ps.size();
	rep(i,0,n){
		P p1 = ps[i], p2 = ps[(i+1)%n];
		int d1 = crossOp(q1,q2,p1), d2 = crossOp(q1,q2,p2);
		if(d1 >= 0) qs.pb(p1);
		if(d1 * d2 < 0) qs.pb(isLL(p1,p2,q1,q2));
	}
	return qs;
}
  
//min_dist
  
db min_dist(vector<P>&ps,int l,int r){
	if(r-l<=5){
		db ret = 1e100;
		rep(i,l,r) rep(j,l,i) ret = min(ret,ps[i].distTo(ps[j]));
		return ret;
	}
	int m = (l+r)>>1;
	db ret = min(min_dist(ps,l,m),min_dist(ps,m,r));
	vector<P> qs; rep(i,l,r) if(abs(ps[i].x-ps[m].x)<= ret) qs.pb(ps[i]);
	sort(qs.begin(), qs.end(),[](P a,P b) -> bool {return a.y<b.y; });
	rep(i,1,qs.size()) for(int j=i-1;j>=0&&qs[j].y>=qs[i].y-ret;--j)
		ret = min(ret,qs[i].distTo(qs[j]));
	return ret;
}
  
int type(P o1,db r1,P o2,db r2){
	db d = o1.distTo(o2);
	if(cmp(d,r1+r2) == 1) return 4;
	if(cmp(d,r1+r2) == 0) return 3;
	if(cmp(d,abs(r1-r2)) == 1) return 2;
	if(cmp(d,abs(r1-r2)) == 0) return 1;
	return 0;
}
  
vector<P> isCL(P o,db r,P p1,P p2){
	if (cmp(abs((o-p1).det(p2-p1)/p1.distTo(p2)),r)>0) return {};
	db x = (p1-o).dot(p2-p1), y = (p2-p1).abs2(), d = x * x - y * ((p1-o).abs2() - r*r);
	d = max(d,(db)0.0); P m = p1 - (p2-p1)*(x/y), dr = (p2-p1)*(sqrt(d)/y);
	return {m-dr,m+dr}; //along dir: p1->p2
}
  
vector<P> isCC(P o1, db r1, P o2, db r2) { //need to check whether two circles are the same
	db d = o1.distTo(o2); 
	if (cmp(d, r1 + r2) == 1) return {};
	if (cmp(d,abs(r1-r2))==-1) return {};
	d = min(d, r1 + r2);
	db y = (r1 * r1 + d * d - r2 * r2) / (2 * d), x = sqrt(r1 * r1 - y * y);
	P dr = (o2 - o1).unit();
	P q1 = o1 + dr * y, q2 = dr.rot90() * x;
	return {q1-q2,q1+q2};//along circle 1
}
  
vector<P> tanCP(P o, db r, P p) {
	db x = (p - o).abs2(), d = x - r * r;
	if (sign(d) <= 0) return {}; // on circle => no tangent
	P q1 = o + (p - o) * (r * r / x);
	P q2 = (p - o).rot90() * (r * sqrt(d) / x);
	return {q1-q2,q1+q2}; //counter clock-wise
}
  
  
vector<L> extanCC(P o1, db r1, P o2, db r2) {
	vector<L> ret;
	if (cmp(r1, r2) == 0) {
		P dr = (o2 - o1).unit().rot90() * r1;
		ret.pb(L(o1 + dr, o2 + dr)), ret.pb(L(o1 - dr, o2 - dr));
	} else {
		P p = (o2 * r1 - o1 * r2) / (r1 - r2);
		vector<P> ps = tanCP(o1, r1, p), qs = tanCP(o2, r2, p);
		rep(i,0,min(ps.size(),qs.size())) ret.pb(L(ps[i], qs[i])); //c1 counter-clock wise
	}
	return ret;
}
  
vector<L> intanCC(P o1, db r1, P o2, db r2) {
	vector<L> ret;
	P p = (o1 * r2 + o2 * r1) / (r1 + r2);
	vector<P> ps = tanCP(o1,r1,p), qs = tanCP(o2,r2,p);
	rep(i,0,min(ps.size(),qs.size())) ret.pb(L(ps[i], qs[i])); //c1 counter-clock wise
	return ret;
}
  
db areaCT(db r, P p1, P p2){
	vector<P> is = isCL(P(0,0),r,p1,p2);
	if(is.empty()) return r*r*rad(p1,p2)/2;
	bool b1 = cmp(p1.abs2(),r*r) == 1, b2 = cmp(p2.abs2(), r*r) == 1;
	if(b1 && b2){
		if(sign((p1-is[0]).dot(p2-is[0])) <= 0 &&
			sign((p1-is[0]).dot(p2-is[0])) <= 0)
		return r*r*(rad(p1,is[0]) + rad(is[1],p2))/2 + is[0].det(is[1])/2;
		else return r*r*rad(p1,p2)/2;
	}
	if(b1) return (r*r*rad(p1,is[0]) + is[0].det(p2))/2;
	if(b2) return (p1.det(is[1]) + r*r*rad(is[1],p2))/2;
	return p1.det(p2)/2;
}
  
bool parallel(L l0, L l1) { return sign( l0.dir().det( l1.dir() ) ) == 0; }
  
bool sameDir(L l0, L l1) { return parallel(l0, l1) && sign(l0.dir().dot(l1.dir()) ) == 1; }
  
bool cmp (P a,  P b) {
	if (a.quad() != b.quad()) {
		return a.quad() < b.quad();
	} else {
		return sign( a.det(b) ) > 0;
	}
}
  
bool operator < (L l0, L l1) {
	if (sameDir(l0, l1)) {
		return l1.include(l0[0]);
	} else {
		return cmp( l0.dir(), l1.dir() );
	}
}
  
bool check(L u, L v, L w) { 
	return w.include(isLL(u,v)); 
}
  
vector<P> halfPlaneIS(vector<L> &l) {
	sort(l.begin(), l.end());
	deque<L> q;
	for (int i = 0; i < (int)l.size(); ++i) {
		if (i && sameDir(l[i], l[i - 1])) continue;
		while (q.size() > 1 && !check(q[q.size() - 2], q[q.size() - 1], l[i])) q.pop_back();
		while (q.size() > 1 && !check(q[1], q[0], l[i])) q.pop_front();
		q.push_back(l[i]);
	}
	while (q.size() > 2 && !check(q[q.size() - 2], q[q.size() - 1], q[0])) q.pop_back();
	while (q.size() > 2 && !check(q[1], q[0], q[q.size() - 1])) q.pop_front();
	vector<P> ret;
	for (int i = 0; i < (int)q.size(); ++i) ret.push_back(isLL(q[i], q[(i + 1) % q.size()]));
	return ret;
}
 
P inCenter(P A, P B, P C) {
	double a = (B - C).abs(), b = (C - A).abs(), c = (A - B).abs();
	return (A * a + B * b + C * c) / (a + b + c);
}
 
P circumCenter(P a, P b, P c) { 
	P bb = b - a, cc = c - a;
	double db = bb.abs2(), dc = cc.abs2(), d = 2 * bb.det(cc);
	return a - P(bb.y * dc - cc.y * db, cc.x * db - bb.x * dc) / d;
}
 
P othroCenter(P a, P b, P c) { 
	P ba = b - a, ca = c - a, bc = b - c;
	double Y = ba.y * ca.y * bc.y,
	A = ca.x * ba.y - ba.x * ca.y,
	x0 = (Y + ca.x * ba.y * b.x - ba.x * ca.y * c.x) / A,
	y0 = -ba.x * (x0 - c.x) / ba.y + ca.y;
	return {x0, y0};
}

const int N=3010;
int n,q,r[N];
bool del[N];
P p[N];
vector<P> reg[N];
int main() {
	scanf("%d%d",&n,&q);
	rep(i,0,n) {
		int x,y;
		scanf("%d%d%d",&x,&y,&r[i]);
		p[i]=P(x,y);
	}
	rep(i,0,n) {
		rep(j,0,n) if (i!=j&&mp(r[i],i)<=mp(r[j],j)) 
		if (cmp(p[i].distTo(p[j]),r[j]-r[i])<=0) {
			del[i]=1;
		}
	}
	int nn=0;
	rep(i,0,n) if (!del[i]) {
		p[nn]=p[i]; r[nn]=r[i];
		++nn;
	}
	n=nn;
	int M=3e6;
	db ss=0;
	rep(i,0,n) {
		vector<L> l;
		l.pb(L(P(M,M),P(-M,M)));
		l.pb(L(P(-M,M),P(-M,-M)));
		l.pb(L(P(-M,-M),P(M,-M)));
		l.pb(L(P(M,-M),P(M,M)));
		rep(j,0,n) if (i!=j) {
			P d=(p[j]-p[i])*2;
			db v=(p[j].dot(p[j])-1.*r[j]*r[j])-(p[i].dot(p[i])-1.*r[i]*r[i]);
			P p1(0,0);
			if (fabs(d.x)>fabs(d.y)) p1=P(v/d.x,0);
			else p1=P(0,v/d.y);
			P p2=p1+d.rot90();
			l.pb(L(p1,p2));
		}
		reg[i]=halfPlaneIS(l);
		ss+=area(reg[i]);
		//printf("%d/%d (%.10Lf,%.10Lf) %d\n",i,n,p[i].x,p[i].y,r[i]);
		//for (auto q:reg[i]) printf("(%.10Lf,%.10Lf)\n",q.x,q.y); puts("");
		//assert(contain(reg[i],p[i])==2);
	}
	rep(i,0,q) {
		int x1,y1,w,h,x2,y2;
		scanf("%d%d%d%d",&x1,&y1,&w,&h);
		//x2,&y2);
		x2=x1+w; y2=y1+h;
		db bb=0;
		rep(j,0,n) {
			vector<P> rr=reg[j];
			rr=convexCut(rr,P(x1,y1),P(x2,y1));
			rr=convexCut(rr,P(x2,y1),P(x2,y2));
			rr=convexCut(rr,P(x2,y2),P(x1,y2));
			rr=convexCut(rr,P(x1,y2),P(x1,y1));
			//printf("cnm %d\n",i);
			int m=SZ(rr);
			if (m<3) continue;
			db aa=0;
			rep(i,0,m) {
				aa+=areaCT(r[j],rr[i]-p[j],rr[(i+1)%m]-p[j]);
			}
			bb+=aa;
		}
		bb=bb*100/w/h;
		bb=min(max(bb,(db)0),(db)100);
		printf("%.10f\n",bb);
		//puts("----");
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3820kb

input:

2 2
0 0 3
2 1 4
0 0 3 3
-3 -3 6 6

output:

100.0000000000
89.5367847292

result:

ok 2 numbers

Test #2:

score: 0
Accepted
time: 2ms
memory: 3996kb

input:

4 3
-1 -1 3
1 -1 3
-1 1 3
1 1 3
-4 -4 8 8
-1 -4 2 8
-3 -1 12 3

output:

87.2221423776
98.5869913729
57.8623304576

result:

ok 3 numbers

Test #3:

score: 0
Accepted
time: 139ms
memory: 4056kb

input:

1000 1
-651497 -620928 2827
-659248 -612693 2827
-666895 -604360 2827
-674437 -595932 2827
-681872 -587410 2827
-689200 -578795 2827
-696418 -570089 2827
-703527 -561293 2827
-710525 -552408 2827
-717410 -543436 2827
-724183 -534378 2827
-730840 -525236 2827
-737383 -516010 2827
-743809 -506704 2827...

output:

100.0000000000

result:

ok found '100.00000', expected '100.00000', error '0.00000'

Test #4:

score: 0
Accepted
time: 2ms
memory: 3992kb

input:

1 1
-5 -2 2
-6 -9 3 10

output:

33.6987707238

result:

ok found '33.69877', expected '33.69877', error '0.00000'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3852kb

input:

9 1
-408263 436346 665941
43802 787157 1
462222 854102 832897
-640110 -626882 527229
684514 -860698 828055
986302 -384366 776389
-341940 -634506 278431
108949 247194 890223
898151 -809302 973099
161501 -800190 639733 841809

output:

100.0000000000

result:

ok found '100.00000', expected '100.00000', error '0.00000'

Test #6:

score: 0
Accepted
time: 2ms
memory: 3840kb

input:

1 1
-8 31 15
1 19 7 24

output:

59.9056095538

result:

ok found '59.90561', expected '59.90561', error '0.00000'

Test #7:

score: 0
Accepted
time: 4007ms
memory: 4444kb

input:

2979 3000
-962850 -987009 20057
-923550 -987009 19977
-884250 -987009 20186
-844950 -987009 19893
-805650 -987009 19980
-766350 -987009 20114
-727050 -987009 19899
-687750 -987009 20043
-648450 -987009 20001
-609150 -987009 20212
-569850 -987009 20077
-530550 -987009 20017
-491250 -987009 20194
-451...

output:

93.0216098450
93.6078715968
93.1116608197
93.3254253757
93.4198752218
93.5218254561
93.4643330786
93.4496920620
93.6574570016
93.5569134129
93.4826686524
93.1877549450
93.5765168015
93.6911779763
93.0718413839
93.4633218538
93.3570021318
93.4557217683
93.4762546685
93.4110692451
93.2780540212
93.814...

result:

ok 3000 numbers

Test #8:

score: 0
Accepted
time: 3938ms
memory: 4592kb

input:

2979 3000
-962850 -987009 19342
-923550 -987009 19297
-884250 -987009 19338
-844950 -987009 19723
-805650 -987009 19345
-766350 -987009 19878
-727050 -987009 19859
-687750 -987009 19764
-648450 -987009 20106
-609150 -987009 19239
-569850 -987009 19151
-530550 -987009 19062
-491250 -987009 19614
-451...

output:

90.4780258296
90.3994537953
91.2321741077
90.3921557474
90.7650269180
89.6256851710
90.8192880423
90.2456260014
92.0155605280
90.6615071596
90.6148906470
90.5804217394
90.0440470824
90.4947950331
90.3543630232
90.6890614452
90.5975039645
90.3886149316
90.3387985350
90.8790435577
90.7889377696
89.804...

result:

ok 3000 numbers

Test #9:

score: 0
Accepted
time: 3753ms
memory: 4496kb

input:

2979 3000
-962850 -987009 19296
-923550 -987009 19243
-884250 -987009 19122
-844950 -987009 19249
-805650 -987009 19300
-766350 -987009 19106
-727050 -987009 19127
-687750 -987009 19304
-648450 -987009 19311
-609150 -987009 19182
-569850 -987009 19262
-530550 -987009 19208
-491250 -987009 19443
-451...

output:

88.0707584514
87.0861170079
84.8021357700
84.7412283299
87.7823457522
86.1747929101
87.0084349329
87.2841330957
87.5364285319
87.3882934272
87.0043788959
87.2508872970
87.5734043789
87.2784661266
87.5097047982
87.6620824909
87.1270193619
87.0983410436
86.8594431102
86.7509415167
87.0627309587
87.273...

result:

ok 3000 numbers

Test #10:

score: 0
Accepted
time: 2ms
memory: 3992kb

input:

1 4
0 0 10
-9 -9 18 18
-1 -10 2 20
-10 -1 20 2
-1000 -1 2000 2

output:

89.7126242617
99.8330824361
99.8330824361
0.9983308244

result:

ok 4 numbers

Test #11:

score: 0
Accepted
time: 4ms
memory: 3936kb

input:

2 756
20 20 2
23 19 1
17 17 1 1
17 17 1 2
17 17 1 3
17 17 1 4
17 17 1 5
17 17 1 6
17 17 2 1
17 17 2 2
17 17 2 3
17 17 2 4
17 17 2 5
17 17 2 6
17 17 3 1
17 17 3 2
17 17 3 3
17 17 3 4
17 17 3 5
17 17 3 6
17 17 4 1
17 17 4 2
17 17 4 3
17 17 4 4
17 17 4 5
17 17 4 6
17 17 5 1
17 17 5 2
17 17 5 3
17 17 5 ...

output:

0.0000000000
0.0000000000
0.0000000000
0.0000000000
0.0000000000
0.0000000000
0.0000000000
7.8786685907
20.4728283101
26.7699081699
24.5673939722
20.4728283101
0.0000000000
20.4728283101
34.9065850399
42.1234634048
41.8879020479
34.9065850399
0.0000000000
26.7699081699
42.1234634048
49.8002410222
50...

result:

ok 756 numbers

Test #12:

score: 0
Accepted
time: 885ms
memory: 4160kb

input:

1000 1000
-250 165 300
-250 -165 300
-249 167 300
-249 -167 300
-248 168 300
-248 -168 300
-247 170 300
-247 -170 300
-246 171 300
-246 -171 300
-245 173 300
-245 -173 300
-244 174 300
-244 -174 300
-243 175 300
-243 -175 300
-242 177 300
-242 -177 300
-241 178 300
-241 -178 300
-240 180 300
-240 -1...

output:

84.1531128490
84.3413826692
84.4991616260
84.6365488342
84.7563599573
84.8606419000
84.9498760145
85.0252322679
85.0874614660
85.1364899043
85.1727239740
85.1968881332
85.2090297401
85.2090297401
85.1968881332
85.1727239740
85.1364899043
85.0874614660
85.0252322679
84.9498760145
84.8606419000
84.756...

result:

ok 1000 numbers

Test #13:

score: 0
Accepted
time: 5033ms
memory: 4212kb

input:

3000 3000
-1000000 0 666
-999333 0 665
-998666 0 664
-997999 0 663
-997332 0 662
-996665 0 661
-995998 0 660
-995331 0 659
-994664 0 658
-993997 0 657
-993331 0 656
-992664 0 655
-991997 0 654
-991330 0 653
-990663 0 652
-989996 0 651
-989329 0 650
-988662 0 649
-987995 0 648
-987329 0 647
-986662 0...

output:

66.2716190479
66.2715853195
66.2715515910
66.2715178624
66.2714841338
66.2714504051
66.2714166764
66.2713829476
66.2713492187
66.2713154897
66.2712817607
66.2712480316
66.2712143025
66.2711805732
66.2711468439
66.2711131146
66.2710793851
66.2710456556
66.2710119261
66.2709781964
66.2709444667
66.270...

result:

ok 3000 numbers

Test #14:

score: 0
Accepted
time: 5162ms
memory: 4392kb

input:

3000 3000
-1000000 0 666
-999333 0 665
-998666 0 664
-997999 0 663
-997332 0 662
-996665 0 661
-995998 0 660
-995331 0 659
-994664 0 658
-993997 0 657
-993331 0 656
-992664 0 655
-991997 0 654
-991330 0 653
-990663 0 652
-989996 0 651
-989329 0 650
-988662 0 649
-987995 0 648
-987329 0 647
-986662 0...

output:

45.5568629346
45.5568084917
45.5567540491
45.5566996071
45.5566451659
45.5565907257
45.5565362867
45.5564818492
45.5564274134
45.5563729795
45.5563185478
45.5562641184
45.5562096917
45.5561552677
45.5561008468
45.5560464292
45.5559920151
45.5559376047
45.5558831983
45.5558287960
45.5557743981
45.555...

result:

ok 3000 numbers

Test #15:

score: 0
Accepted
time: 5375ms
memory: 4208kb

input:

3000 3000
0 -1000000 666
0 -999333 665
0 -998666 664
0 -997999 663
0 -997332 662
0 -996665 661
0 -995998 660
0 -995331 659
0 -994664 658
0 -993997 657
0 -993331 656
0 -992664 655
0 -991997 654
0 -991330 653
0 -990663 652
0 -989996 651
0 -989329 650
0 -988662 649
0 -987995 648
0 -987329 647
0 -986662...

output:

66.2716190479
66.2715853195
66.2715515910
66.2715178624
66.2714841338
66.2714504051
66.2714166764
66.2713829476
66.2713492187
66.2713154897
66.2712817607
66.2712480316
66.2712143024
66.2711805732
66.2711468439
66.2711131146
66.2710793851
66.2710456556
66.2710119261
66.2709781965
66.2709444668
66.270...

result:

ok 3000 numbers

Test #16:

score: 0
Accepted
time: 5527ms
memory: 4348kb

input:

3000 3000
0 -1000000 666
0 -999333 665
0 -998666 664
0 -997999 663
0 -997332 662
0 -996665 661
0 -995998 660
0 -995331 659
0 -994664 658
0 -993997 657
0 -993331 656
0 -992664 655
0 -991997 654
0 -991330 653
0 -990663 652
0 -989996 651
0 -989329 650
0 -988662 649
0 -987995 648
0 -987329 647
0 -986662...

output:

45.6253513559
45.6252969812
45.6252426064
45.6251882314
45.6251338564
45.6250794813
45.6250251060
45.6249707307
45.6249163552
45.6248619796
45.6248076039
45.6247532282
45.6246988523
45.6246444763
45.6245901001
45.6245357239
45.6244813476
45.6244269711
45.6243725946
45.6243182179
45.6242638411
45.624...

result:

ok 3000 numbers

Test #17:

score: 0
Accepted
time: 6037ms
memory: 4492kb

input:

3000 3000
-1000000 -1000000 1
-998665 -1000000 666
-997331 -1000000 665
-995997 -1000000 664
-994663 -1000000 663
-993328 -1000000 662
-991994 -1000000 661
-990660 -1000000 660
-989326 -1000000 659
-987991 -1000000 658
-986657 -1000000 657
-985323 -1000000 656
-983989 -1000000 655
-982655 -1000000 6...

output:

0.0411224933
0.0411247821
0.0411247824
0.0411237058
0.0411224044
0.0411215449
0.0411223580
0.0411247604
0.0411264269
0.0411258980
0.0411246464
0.0411233870
0.0411228306
0.0411244495
0.0411268494
0.0411276804
0.0411268082
0.0411254779
0.0411243570
0.0411242882
0.0411265249
0.0411287581
0.0411286745
0...

result:

ok 3000 numbers

Test #18:

score: 0
Accepted
time: 216ms
memory: 3964kb

input:

3000 3000
-746962 -594125 831471
963285 556258 512696
-44530 -282161 506650
-761350 -749041 316150
478637 895054 544219
-808446 651862 884965
-715791 816516 150184
-888338 -563074 921068
-384287 708029 534607
-233387 -619016 870637
-755239 561369 879287
-852868 878038 665773
161640 -992108 105225
54...

output:

100.0000000000
100.0000000000
100.0000000000
100.0000000000
100.0000000000
100.0000000000
100.0000000000
100.0000000000
100.0000000000
100.0000000000
100.0000000000
95.4653209868
100.0000000000
100.0000000000
100.0000000000
100.0000000000
100.0000000000
100.0000000000
100.0000000000
100.0000000000
1...

result:

ok 3000 numbers

Test #19:

score: 0
Accepted
time: 1018ms
memory: 4156kb

input:

3000 3000
364365 -335539 45680
331814 148548 56300
-271120 -410872 33790
368845 -129556 24185
-281842 269118 3264
401341 -26588 27097
210800 185460 30043
14959 413121 4194
50900 5027 8005
-163996 -453124 10859
365858 133812 30873
352552 -215922 51752
-446910 259545 24088
-207371 -343081 35566
160057...

output:

0.0000000000
64.9968492031
59.3336589722
100.0000000000
0.0000000000
23.9151933173
99.3148370775
61.0136357700
0.0000000000
17.3845041162
40.0142680005
1.6531303009
0.0000000000
0.0000000000
47.4672744060
0.0000000000
0.0000000000
0.0000000000
0.3769881198
69.9049080753
27.6113518159
64.0366480897
1...

result:

ok 3000 numbers

Test #20:

score: 0
Accepted
time: 1969ms
memory: 4336kb

input:

3000 3000
-218277 276181 9366
-64711 339037 14999
186634 -425029 8767
-76284 -432478 11729
-5061 194018 16443
-46704 469485 27159
-287513 393511 26141
200225 195732 27020
450769 -484542 7828
-469256 404361 5171
-339695 67596 24447
121746 -185763 5915
-40165 -391818 12045
-6631 399895 20292
-49488 67...

output:

33.1610981858
31.8827938002
68.1399524176
0.0000000000
58.0484804793
51.5886117237
0.0000000000
0.0000000000
95.8365001368
0.0000000000
0.0000000000
0.0000000000
0.0000000000
0.0000000000
0.0000000000
10.1343580759
0.0000000000
48.2119686680
0.0000000000
0.0000000000
11.1935584177
0.0000000000
0.000...

result:

ok 3000 numbers

Test #21:

score: 0
Accepted
time: 6115ms
memory: 4492kb

input:

3000 3000
-272257 314630 7492
289573 229521 555
152794 129189 48
-142329 172844 2831
117362 -238159 2647
-178654 68842 525
-305984 42528 1882
-362421 75426 3660
379957 -9963 4166
-321415 -339416 5812
206963 -146966 1899
-158865 -224695 5030
-294632 -291118 1360
280467 59126 4815
-347217 -474088 5538...

output:

17.7672780355
17.5495936031
13.0718266117
18.0529417811
18.6037448164
11.5796573421
4.4088128450
7.5255857113
12.9593902554
15.6568339596
7.5356618185
13.5741980527
14.1567501922
8.9383831600
3.8457228785
7.8899717349
10.7821834819
13.7924735007
18.4347009014
5.2161711018
17.5066942862
17.7942874760...

result:

ok 3000 numbers

Test #22:

score: 0
Accepted
time: 2ms
memory: 3936kb

input:

1 1
0 0 1
-1 -1 2 2

output:

78.5398163397

result:

ok found '78.53982', expected '78.53982', error '0.00000'

Test #23:

score: 0
Accepted
time: 0ms
memory: 3848kb

input:

4 1
899981 899946 23
899995 900049 67
900004 899904 15
900018 899918 26
899978 899983 2 1

output:

9.4705594440

result:

ok found '9.47056', expected '9.47056', error '0.00000'

Test #24:

score: 0
Accepted
time: 4048ms
memory: 4448kb

input:

3000 3000
1 1 10095
12850 -12847 10095
4 -25696 10095
-18166 -25698 10095
-33003 -15209 10095
-40607 1294 10095
-40028 19456 10095
-32084 35799 10095
-18552 47927 10095
-1606 54487 10095
16557 55022 10095
33957 49787 10095
48969 39549 10095
60386 25414 10095
67435 8667 10095
69751 -9355 10095
67337 ...

output:

29.2381993553
19.9435524879
29.9530547311
30.2712892443
29.6895450222
24.9580806658
30.4077304873
29.7333777115
29.7854514849
29.5890969462
29.5962108124
29.8105089841
30.0416259519
25.5961876185
29.9029907354
30.2613647230
30.2394948649
26.6344379191
31.5761652899
29.3275381299
29.4793755382
29.844...

result:

ok 3000 numbers