QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#673991#5067. Two WallsmobbbWA 91ms3736kbC++205.8kb2024-10-25 12:56:072024-10-25 12:56:07

Judging History

你现在查看的是最新测评结果

  • [2024-10-25 12:56:07]
  • 评测
  • 测评结果:WA
  • 用时:91ms
  • 内存:3736kb
  • [2024-10-25 12:56:07]
  • 提交

answer

#include <bits/stdc++.h>

#define ll long long

#define db ll
constexpr db EPS = 0;
int sign(db a){ return a < -EPS ? -1 : a > EPS; }
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;}
	// a * b == |a| * |b| * cos<a,b>  ,大于0为锐角小于0为钝角等于0为直角
	db det(P p){return {x * p.y - y * p.x};} 
	// a * b == |a| * |b| * sin<a,b> == - (b * a) ,a逆时针转多少度可以转到b
	// 大于0 b在a的逆时针方向,等于0共线,小于0 b在a的顺时针方向
	void read(){std::cin >> x >> y;}
	void print(){std::cout << x << " " << y  << "\n";}
	db distTo(P p) {return (*this - p).abs();}
	db alpha() {return atan2l(y,x);}
	db abs() {return sqrtl(abs2());}
	db abs2() {return x * x + y * y;}
	P rot90() {return P(-y,x);} // 逆时针旋转90度
	int quad(){return sign(y) == 1 || (sign(y) == 0 && sign(x) == 1);}
	P unit() {return *this / abs();}
	// P rot(db an){return {x * cosl(an) - y * sinl(an),x * sinl(an) + y * cosl(an)};}
};
#define cross(p1,p2,p3) ((p2.x - p1.x) * (p3.y - p1.y) - (p2.y - p1.y) * (p3.x - p1.x))
#define crossOp(p1,p2,p3) sign(cross(p1,p2,p3)) // 以p1为起点去考虑<p1,p2> <p1,p3> 
// 大于p3在p2的逆时针方向,小于0在顺时针,等于0共线

// 两个直线是否相交
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);
}
// 判断区间 [l1,r1] ,[l2,r2] 是否相交
bool intersect(db l1,db r1,db l2,db r2){
	if (l1 > r1) std::swap(l1,r1);if (l2 > r2) std::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;
}
// m 在不在a和b之间
bool isMiddle(db a,db m,db b){
	return sign(a - m) == 0 || sign(b - m) == 0 || (a < m != b < m);
}
// 点m 在不在a和b之间
bool isMiddle(P a,P m,P b){
	return isMiddle(a.x,m.x,b.x) && isMiddle(a.y,m.y,b.y);
}
// 点q在线段上
bool onSeg(P p1,P p2, P q){
	return crossOp(p1,p2,q) == 0 && isMiddle(p1,q,p2);
}
// 点q严格在线段上
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));
}
// 求 q 到 p1p2的投影
P proj(P p1,P p2,P q){
	P dir = p2 - p1;
	return p1 + dir * (dir.dot(q - p1) / dir.abs2());
}
// 求 q以直线p1p2为轴的反射
P refect(P p1,P p2,P q){
	return proj(p1,p2,q) * 2 - q;
}
// 求q到线段p1p2的最短距离
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 std::min(p1.distTo(q),p2.distTo(q));
}
// 求线段p1p2 与线段q1q2的距离
db disSS(P p1,P p2,P q1,P q2){
	if(isSS(p1,p2,q2,q2)) return 0;
	return std::min({nearest(p1,p2,q1),nearest(p1,p2,q2),nearest(q1,q2,p1),nearest(q1,q2,p2)});
}
// 极角排序
// sort(p,p + n,[&](P a,P b){
// 	int qa = a.quad,qb = b.quad;
// 	if (qa != qb) return qa < qb;
// 	return sign(a.det(b)) > 0;
// })

int solve(){
	P a,b,c,d,e,f;
	a.read(),b.read();
	c.read(),d.read();
	e.read(),f.read();
	if (!isSS(a,b,c,d) && !isSS(a,b,e,f)){
		return 0;
	}
	if (!isSS_strict(c,d,e,f)){
		return 1;
	}
	if (crossOp(c,d,a) * crossOp(c,d,b) >= 0) {
		return 1;
	}
	if (crossOp(e,f,a) * crossOp(e,f,b) >= 0){
		return 1;
	}
	if (crossOp(e,f,a) > 0) {
		std::swap(e,f);
	}
	if (crossOp(d,c,a) > 0){
		std::swap(c,d);
	}
	if ((c - d).det(f - e) < 0){
		std::swap(c,f);
		std::swap(d,e);
	}

	// P la = e - a,ra = c - a;
	// P lb = f - b,rb = d  - b;
	// // c.print(),d.print(),e.print(),f.print();
	// std::vector<std::pair<P,int>> evt;
	// evt.push_back({la,1});
	// evt.push_back({ra,-1});
	// evt.push_back({lb,1});
	// evt.push_back({rb,-1});

	// auto cmp = [&](P a,P b){
	// 	int qa = a.quad(),qb = b.quad();
	// 	if (qa != qb) return qa < qb;
	// 	return sign(a.det(b)) > 0;
	// };

	// int cur = cmp(ra,la) + cmp(rb,lb);
	// // std::cerr << cur << '\n';
	// sort(evt.begin(),evt.end(),[&](std::pair<P,int> a,std::pair<P,int> b){
	// 	int qa = a.first.quad(),qb = b.first.quad();
	// 	if (qa != qb) return qa < qb;
	// 	if (a.first.det(b.first) == 0){
	// 		return a.second < b.second;
	// 	}
	// 	return a.first.det(b.first) > 0;
	// });
	// if (cur >= 2) return 1;
	// for (auto [a,b] : evt){
	// 	cur += b;
	// 	if (cur >= 2){
	// 		return 1;
	// 	}
	// }

	auto check = [&](P mid, P l, P r){
		if (l.det(r) >= 0){
			return (l.det(mid) >= 0 && r.det(mid) <= 0);
		}else{
			return !(l.det(mid) <= 0 && r.det(mid) >= 0);
		}
	};

	if (check(c - a,f - b,d - b)) return 1;
	if (check(e - a,f - b,d - b)) return 1;

	if (check(d - b,e - a,c - a)) return 1;
	if (check(f - b,e - a,c - a)) return 1;

	return 2;
}

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

	int t;
	
	std::cin >> t;

	while (t--){
		std::cout << solve() << '\n';
	}

	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3624kb

input:

3
0 0
1 1
2 2 3 3
4 4 5 5
0 0
1 1
2 2 3 3
2 2 3 3
0 0
10 10
10 0 0 10
1 1 2 2

output:

0
0
1

result:

ok 3 number(s): "0 0 1"

Test #2:

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

input:

2
-999999999 999999998
999999999 999999998
-1000000000 -1000000000 1000000000 1000000000
1000000000 -1000000000 -1000000000 1000000000
-999999999 999999998
999999999 999999998
-999999998 -999999998 1000000000 1000000000
999999998 -999999998 -1000000000 1000000000

output:

2
1

result:

ok 2 number(s): "2 1"

Test #3:

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

input:

1
0 0
1 1
2 2 3 3
4 4 5 5

output:

0

result:

ok 1 number(s): "0"

Test #4:

score: 0
Accepted
time: 89ms
memory: 3616kb

input:

100000
-851839419 34688642
-667081997 395784949
-624068418 -155389155 119194510 -758711821
-992436155 -812775173 851861070 -592596572
974613003 -179673992
-485749861 520596304
-115838823 -265233646 -573799007 -222234500
608830643 -887109945 483106217 -906910755
-597593284 384264657
940783 476657007
...

output:

0
0
0
0
0
0
1
0
0
0
0
1
0
0
1
1
0
0
1
1
1
0
1
0
0
1
0
1
0
0
0
0
0
1
0
0
1
0
1
0
0
0
0
0
1
1
1
1
1
0
1
1
0
0
0
0
1
1
0
1
0
0
0
0
0
0
0
0
1
1
0
1
0
0
1
0
0
0
0
1
1
1
1
1
1
0
0
0
1
1
1
0
0
0
0
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
1
1
1
0
1
1
0
0
0
0
0
0
1
0
1
1
0
1
0
0
1
0
0
1
1
0
0
0
1
0
1
0
1
0
0
0
1
1
...

result:

ok 100000 numbers

Test #5:

score: 0
Accepted
time: 91ms
memory: 3692kb

input:

100000
-496405053 -492673762
111401587 764822338
-588077735 774345046 959995351 -972693439
-729349041 -573156496 326664422 645305810
-477016787 -561855978
697257071 461011057
-416669921 377733217 784674141 -204150537
695471214 -642123788 -968584097 801626277
-329331824 68483816
945230774 982358552
-...

output:

1
1
1
1
0
0
0
0
0
0
0
0
1
1
0
0
0
0
0
0
1
0
0
1
0
0
0
0
0
0
0
0
0
1
1
0
1
1
1
1
1
0
1
1
0
1
1
1
0
0
1
1
0
1
0
0
0
0
0
1
0
0
0
0
0
0
1
0
1
1
0
1
0
1
0
0
0
0
1
1
0
1
1
0
0
0
1
1
1
1
1
1
0
1
1
0
0
0
0
0
1
0
1
0
1
1
1
0
1
1
1
1
1
1
1
1
0
0
0
0
0
1
0
1
0
0
1
1
0
1
0
1
0
1
0
0
1
1
1
0
0
0
0
0
0
0
1
1
1
1
...

result:

ok 100000 numbers

Test #6:

score: 0
Accepted
time: 90ms
memory: 3512kb

input:

100000
153996608 390029247
838007668 -918017777
-257119758 -244043252 390730779 813324945
-761229221 -38570526 634492154 -116791808
19475923 760994742
-119735998 991360398
-665623518 -632455126 -394909798 -481033868
-974798424 140919454 -715241704 510163308
-61070363 -542264319
-353569028 -511939904...

output:

1
0
0
1
1
1
0
0
0
1
1
0
1
1
0
0
0
1
0
1
1
1
1
0
1
1
1
1
0
1
0
0
0
1
1
0
0
1
0
0
1
1
0
0
0
1
0
0
0
1
0
1
1
0
1
0
1
0
1
1
1
0
0
0
1
0
0
0
0
0
1
1
1
0
0
0
1
0
1
0
0
1
0
1
1
0
1
0
1
0
0
1
0
0
0
0
0
0
1
0
1
1
0
0
1
0
0
0
0
1
0
0
1
0
1
1
0
1
0
0
0
1
0
0
0
0
0
0
1
0
0
0
0
0
0
1
0
0
0
0
1
1
1
1
0
0
1
0
0
0
...

result:

ok 100000 numbers

Test #7:

score: 0
Accepted
time: 86ms
memory: 3628kb

input:

100000
509430974 -432300451
-140418957 -600857890
-464218867 442601156 -768468380 61286241
-203174812 201048150 404262799 826143280
567846134 673780049
525213848 983652653
-671487323 600446325 963563350 -462949905
-888157854 628995403 -166932017 218700340
207191097 898865049
590720963 288728935
4143...

output:

0
0
0
1
0
0
1
1
0
0
1
0
0
1
0
0
0
0
1
0
0
1
0
0
0
0
0
0
0
0
0
1
1
1
0
0
1
1
0
1
1
0
1
0
0
0
0
0
0
1
0
1
0
1
1
0
0
0
0
0
0
1
0
1
1
0
0
0
1
1
0
0
0
0
0
0
1
0
1
0
1
0
0
0
1
1
1
0
0
0
1
1
0
0
0
1
0
0
0
0
1
1
0
0
1
0
1
1
0
1
1
1
0
0
0
0
0
0
0
1
1
1
0
0
1
1
0
0
0
0
0
0
1
1
1
0
1
0
0
1
0
0
0
0
0
1
1
0
1
0
...

result:

ok 100000 numbers

Test #8:

score: 0
Accepted
time: 89ms
memory: 3620kb

input:

100000
-840167367 450402558
586187125 -231820501
-428228185 -627664644 367299755 142271917
59912302 735634121 469000739 64045662
-935661158 291598063
-291779221 -780965301
-920440920 -409742018 -216020590 965199471
-801517283 -587961356 -156679415 465294457
423575055 583084208
-759956341 794430480
8...

output:

1
1
1
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
1
0
1
0
0
0
1
1
0
0
1
0
0
1
1
1
0
1
0
1
0
0
1
0
0
0
1
1
1
0
0
0
0
0
0
1
1
0
1
0
1
0
0
0
1
0
1
1
0
1
0
0
1
0
0
1
1
1
0
1
1
0
0
0
0
0
0
1
0
0
0
1
0
0
1
1
0
0
1
0
1
1
1
0
0
0
0
1
1
0
0
0
0
1
1
0
0
1
0
0
0
0
1
0
0
1
1
1
0
1
0
1
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
...

result:

ok 100000 numbers

Test #9:

score: 0
Accepted
time: 90ms
memory: 3660kb

input:

100000
-779700294 -76959846
-340361999 380306679
-392237502 58979764 -201964817 -314799493
28032122 -729779910 -56195909 -454962165
-387290947 -142461426
891227711 -493705752
778727982 823159433 899362766 983283434
-471786920 -48007905 391630272 173831488
691836515 -322631221
236211152 -699867976
-3...

output:

0
0
0
0
0
1
0
0
1
1
0
1
0
0
1
0
0
0
0
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
1
1
1
0
1
0
1
0
0
0
0
0
1
0
1
1
1
0
0
0
1
1
0
1
0
0
0
1
0
1
0
0
1
0
0
0
0
0
0
0
1
1
1
1
0
0
0
1
0
0
0
0
0
1
1
0
0
1
0
0
0
1
0
1
0
0
0
0
0
1
0
0
1
1
1
1
0
1
0
0
0
0
0
0
1
1
0
0
0
1
0
0
1
0
0
0
0
1
0
0
1
0
1
0
1
1
0
0
0
...

result:

ok 100000 numbers

Test #10:

score: 0
Accepted
time: 81ms
memory: 3564kb

input:

100000
-181176136 805743163
681211377 454376774
-599336611 988713965 638836024 -823748404
586086531 -490161233 251631822 782940218
-133888029 -524643413
74234642 -553290999
529774386 -533873706 -332098675 -998632604
-385146349 735035338 350005371 -412598775
960097976 -638412062
-819498858 -194166431...

output:

1
0
1
1
1
0
1
0
0
1
0
0
0
1
1
0
0
1
0
1
0
0
1
0
0
0
0
0
1
0
1
0
1
1
1
0
1
1
1
1
1
1
0
0
0
0
1
0
1
1
0
1
1
0
1
0
1
0
0
1
0
1
0
0
0
0
0
0
0
0
0
1
0
0
0
1
1
0
0
1
0
0
1
0
0
0
1
0
0
0
1
0
1
1
0
1
0
0
0
0
0
1
1
1
0
0
0
0
0
0
0
0
0
1
0
0
0
0
1
1
0
0
1
1
0
0
0
1
0
0
0
1
1
0
0
0
1
1
0
0
0
0
0
0
1
0
0
0
0
1
...

result:

ok 100000 numbers

Test #11:

score: 0
Accepted
time: 85ms
memory: 3736kb

input:

100000
469225525 -311553829
-592182543 -933496047
-268378634 -29674334 -225395842 -985852520
849173645 44424737 21402468 20842600
657571974 -906825400
-742758427 -266031450
228943287 455937953 783284681 724484066
-593473073 -776888715 603347764 -460971951
-528550773 -954192903
-170176161 68445323
76...

output:

1
1
0
0
1
1
1
0
1
0
0
0
0
0
1
1
1
0
0
1
0
1
1
0
1
0
1
1
1
0
0
0
0
1
1
1
0
1
1
1
0
0
1
0
0
0
0
1
1
0
1
0
1
0
0
0
1
0
0
0
0
1
1
0
0
1
0
0
0
1
1
0
0
0
0
0
0
1
0
1
1
0
0
0
1
1
1
0
1
1
1
1
1
0
0
0
0
1
0
0
0
0
0
0
1
0
0
1
1
1
0
0
1
0
0
1
1
1
1
1
1
0
0
1
1
0
1
0
1
1
0
1
0
1
0
1
1
0
1
1
0
1
0
0
0
0
1
0
1
0
...

result:

ok 100000 numbers

Test #12:

score: 0
Accepted
time: 85ms
memory: 3612kb

input:

100000
824659891 866116474
429390833 -564458658
-232387951 656970075 910372293 505198569
817293465 579010708 86140408 963777688
616007597 416025321
440248505 -325616697
-20010310 -311160598 -101331964 742568030
-506832502 -236935264 -848342550 -752434920
-850223901 435058963
825991332 574146868
-776...

output:

1
0
0
0
1
1
1
0
0
1
0
0
1
0
1
0
1
1
0
1
0
0
0
1
0
0
1
1
0
0
1
0
1
1
0
0
0
1
1
0
0
1
0
0
1
1
0
1
0
1
1
0
0
0
0
0
1
0
0
1
0
1
0
0
0
0
0
1
0
1
1
0
0
0
1
0
0
0
0
1
0
0
0
0
1
0
0
0
1
1
0
1
0
1
0
1
0
1
1
1
1
1
0
1
1
0
0
1
1
0
0
0
0
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
0
1
0
1
0
0
1
0
0
1
1
0
0
1
0
1
1
1
...

result:

ok 100000 numbers

Test #13:

score: 0
Accepted
time: 86ms
memory: 3612kb

input:

100000
-181402541 -196228170
624722764 328251238
783857631 682518931 547715844 969228879
823684584 -149364638 -913952210 833196798
62726516 -554264004
664711179 426420047
-418659204 986117749 725195722 -692340474
963934566 206423874 688322091 -850621504
-259681786 -92095128
52318280 220754482
262610...

output:

1
1
0
1
0
0
0
1
1
0
0
0
1
0
0
1
0
1
1
0
0
0
0
1
1
0
1
1
0
1
1
0
0
0
0
0
1
1
0
0
1
0
0
0
0
1
1
0
0
0
0
0
1
0
0
1
1
0
1
1
0
0
1
1
1
1
0
0
0
0
1
0
0
1
0
1
0
0
0
1
1
1
0
0
0
1
1
0
0
0
0
0
1
1
0
0
1
0
1
0
1
1
1
0
1
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
1
0
0
1
1
0
0
1
0
1
0
0
1
0
0
1
1
0
0
1
0
1
0
1
1
1
...

result:

ok 100000 numbers

Test #14:

score: 0
Accepted
time: 86ms
memory: 3688kb

input:

100000
417121618 686474839
-353703861 697288626
-885184394 -630836661 -611483316 755247261
-618261009 -204713255 855818437 -223868114
316129433 -641478697
-152281890 661802094
-962580095 219019198 -159420924 -969223805
-654457570 989467117 -763368223 562948234
251669466 -702843263
996608271 -9785766...

output:

0
0
1
0
0
0
0
1
0
0
1
0
0
0
0
1
0
0
0
1
1
1
1
0
0
0
0
0
1
1
0
1
1
0
0
0
1
0
1
0
0
0
1
0
0
0
0
0
0
1
1
0
0
1
0
0
1
1
1
0
0
1
1
0
1
0
0
1
0
0
0
1
0
0
1
1
0
0
1
0
0
0
1
0
1
0
0
1
1
0
0
0
1
1
0
1
0
0
1
0
1
1
0
1
0
0
0
1
0
0
0
0
1
0
1
0
1
0
1
1
0
0
1
0
1
1
0
1
0
0
0
0
1
1
0
0
0
1
0
0
1
1
1
0
0
0
0
1
0
1
...

result:

ok 100000 numbers

Test #15:

score: 0
Accepted
time: 89ms
memory: 3632kb

input:

100000
-932476723 -135854859
667869515 -985551488
-849193711 593864833 819252113 298175852
-650141189 329872715 -836353833 -985965732
-892410565 976339317
-969274959 654094349
-968443900 -791169144 660995138 -951139842
-567817000 -470579434 -510025830 566452559
519930927 686408603
-302191531 -472875...

output:

1
0
1
1
0
0
1
1
0
0
0
1
0
0
1
1
1
0
0
0
0
0
1
0
1
1
1
1
1
1
0
0
1
1
0
1
0
1
1
0
0
1
0
0
0
0
1
0
0
1
0
0
0
1
0
0
1
0
0
0
0
1
0
0
1
0
0
0
1
1
1
0
1
1
0
1
0
0
0
0
0
0
1
1
0
1
0
1
0
0
0
1
1
1
0
1
0
0
0
0
0
0
1
0
1
0
1
0
1
0
0
0
1
0
1
0
1
1
1
1
1
0
1
1
0
1
0
1
0
0
1
0
1
0
1
0
0
1
1
1
1
0
0
0
0
0
1
0
0
0
...

result:

ok 100000 numbers

Test #16:

score: 0
Accepted
time: 90ms
memory: 3548kb

input:

100000
-577042357 -958184557
-553646903 -616514099
-761325526 -719490759 -44979753 -210773060
-387054074 864458686 638449520 546903944
-639007648 299190036
213731973 889476396
782602504 -148202282 19468285 -933055879
-238086637 17496515 -204805935 518079383
493225093 127537970
642098459 32826410
215...

output:

0
0
0
0
1
0
1
0
0
0
1
0
1
1
0
0
1
0
0
0
1
0
1
0
0
1
1
0
1
1
1
1
1
1
1
0
1
0
0
1
1
0
1
1
1
0
0
0
0
0
0
0
1
0
1
1
1
1
1
0
0
1
1
1
0
0
0
1
1
0
0
0
1
1
0
0
1
1
1
1
1
1
1
1
1
1
0
0
0
1
0
1
0
0
0
0
1
1
0
1
0
0
0
1
0
1
0
0
0
1
0
1
1
1
1
0
1
1
0
0
1
0
0
0
1
0
0
1
0
1
0
0
1
0
0
0
0
0
0
1
0
0
0
0
1
0
0
1
1
1
...

result:

ok 100000 numbers

Test #17:

score: 0
Accepted
time: 90ms
memory: 3620kb

input:

100000
-516575284 219485746
172959179 -299354213
979697864 -32846351 795821088 -372877176
171000334 -895922639 703187460 -510160968
-142514938 -82991950
-308293802 881768651
776738700 -915300832 839884347 790060792
-151446066 800539757 48536459 226616414
709609051 -188242871
-656701343 538527956
912...

output:

0
0
1
1
1
1
0
0
1
1
0
0
0
1
1
0
0
0
0
1
1
0
0
0
1
1
0
0
1
0
1
1
1
1
0
1
0
0
0
1
0
0
1
0
0
1
0
0
0
0
0
0
1
0
0
0
1
1
0
0
1
1
0
0
1
0
1
0
0
0
1
0
0
1
1
1
1
0
0
1
1
0
1
0
0
0
1
0
0
0
0
0
1
1
1
1
1
0
0
0
0
0
0
1
1
0
0
0
1
1
0
1
0
1
0
0
1
0
1
1
0
1
1
0
1
1
0
0
0
0
0
0
0
0
0
0
1
1
0
1
1
0
1
0
0
0
0
1
0
1
...

result:

ok 100000 numbers

Test #18:

score: 0
Accepted
time: 91ms
memory: 3696kb

input:

100000
133826376 -897811246
-805467447 69683176
-984311454 896887850 226556516 -881826087
139120154 -361336668 472958105 727741414
110887979 -465173937
631623338 -882849303
475907601 74510826 -44732299 513177461
-359772790 -416417001 596846146 -64846555
977870511 -798991006
287588648 -955770500
-633...

output:

0
0
0
1
0
0
0
0
0
1
0
1
1
0
0
1
0
1
1
0
0
0
0
1
0
1
0
1
0
0
1
0
1
0
0
0
0
1
1
0
0
1
1
0
0
0
0
0
0
0
1
0
1
1
0
0
0
1
0
0
0
0
0
1
0
1
1
0
0
0
0
1
0
0
0
0
1
1
1
1
1
0
0
0
1
0
1
1
0
0
0
0
0
0
0
0
1
0
1
1
1
0
0
0
0
0
0
0
1
0
0
1
0
0
1
0
0
1
1
0
0
0
1
0
1
0
0
0
0
1
0
0
0
1
1
0
0
0
0
0
0
0
0
1
0
0
1
0
0
0
...

result:

ok 100000 numbers

Test #19:

score: 0
Accepted
time: 89ms
memory: 3620kb

input:

100000
489260742 -15108237
-78861365 681810357
-896443270 -416467743 -932642644 904192296
402207268 173249302 537696045 -329323498
902347982 -899233426
-480337024 -595589754
-68013290 -692587724 -981226446 531261424
-30042427 123536449 850188539 -356309523
-753868029 885228154
936911345 -450068955
1...

output:

1
1
1
0
0
0
1
0
1
1
1
1
0
0
1
0
0
0
0
0
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
0
1
1
1
1
0
1
0
1
0
0
1
0
0
0
0
0
1
0
0
1
1
1
0
0
1
1
1
0
0
0
0
0
0
1
0
0
1
0
0
1
1
0
0
0
0
0
0
1
0
0
0
0
0
0
1
0
1
0
0
1
0
1
0
1
1
0
0
1
0
0
0
0
0
1
0
1
1
0
1
0
0
0
0
1
1
0
0
0
0
0
1
0
0
1
0
1
0
1
0
0
1
0
0
1
0
1
1
1
1
0
0
...

result:

ok 100000 numbers

Test #20:

score: 0
Accepted
time: 90ms
memory: 3624kb

input:

100000
-617247806 -542470641
699622219 998970243
-860452587 565143960 203125491 447120886
960261677 707835273 550556483 908578885
-844249102 718584588
702669908 -360207707
-73877095 297223934 -160810384 254378093
56598144 611612398 -601501775 -109715406
-780573863 569447313
-361888457 350599884
5702...

output:

1
1
0
0
1
1
0
0
0
0
1
0
1
1
1
0
0
1
0
0
1
1
0
1
1
0
1
0
0
0
1
1
1
1
0
0
1
0
0
0
0
0
1
0
1
0
0
0
0
0
0
0
0
0
1
0
0
0
1
1
0
0
0
0
0
1
0
0
1
0
0
1
0
1
0
0
0
0
0
0
1
1
0
1
1
1
1
0
1
0
1
0
0
0
0
0
1
0
0
0
1
0
0
0
0
1
0
1
0
1
1
0
1
0
1
0
0
0
0
0
0
0
0
1
1
0
1
0
1
0
0
0
0
1
1
1
0
0
1
0
0
1
0
0
0
0
0
1
0
0
...

result:

ok 100000 numbers

Test #21:

score: 0
Accepted
time: 85ms
memory: 3664kb

input:

100000
-261813440 340232368
-573771701 -631992369
-529494610 -505121840 -661106375 233139268
928381497 947453949 320327128 389571058
-52789098 336402602
-114323161 -124825660
-617797985 940190796 659605678 272462056
143238715 -605344361 -591249174 -401178375
-269222611 -41300822
877368828 856301429
...

output:

1
0
0
0
0
0
0
1
0
0
1
1
1
0
1
1
0
0
1
1
1
1
1
0
0
0
0
0
0
1
1
1
0
1
0
1
1
1
1
1
1
1
1
1
0
0
1
1
1
0
0
1
1
0
1
1
0
1
1
0
1
0
1
0
0
1
0
0
1
1
0
0
1
0
1
0
0
0
0
0
0
0
1
0
0
0
1
0
1
0
1
0
0
1
0
1
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
1
1
0
1
0
1
0
0
1
1
0
1
0
1
0
1
1
0
0
0
0
0
0
0
0
0
0
0
1
0
1
0
0
1
0
0
0
0
...

result:

ok 100000 numbers

Test #22:

score: 0
Accepted
time: 90ms
memory: 3548kb

input:

100000
-201346367 -482097330
742768969 -19865188
-736593719 -113444726 474661760 -223932141
-808531390 -517960081 90097774 -667493854
200613819 -45779385
-931316230 -132533405
-623661790 -69997546 18078824 -4421275
767936371 -65390910 -337906780 -987608637
-961151 -652048957
-473308476 -637997027
-5...

output:

1
0
0
0
0
0
1
0
0
1
0
1
1
1
1
1
0
1
0
1
0
0
1
1
1
0
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1
1
0
0
1
0
0
1
1
0
0
0
0
0
0
0
0
0
0
1
0
1
1
1
0
0
0
1
0
1
1
1
0
0
0
1
0
0
1
0
1
1
0
0
0
0
0
0
0
1
0
1
0
1
0
0
0
0
1
1
0
0
0
0
1
1
0
1
0
1
0
1
0
0
1
1
0
1
1
1
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
1
1
1
0
0
1
0
0
0
...

result:

ok 100000 numbers

Test #23:

score: 0
Accepted
time: 90ms
memory: 3604kb

input:

100000
889700307 83152852
81040013 -449413311
374958682 300600303 -247400099 -855076598
-624900532 -785317715 857266066 -410224840
872271274 -850603331
-975572718 973091933
421906561 -222540906 -675309230 591089749
-544630032 -809400213 70027428 -810848022
902977690 -179653965
-183689299 262567523
7...

output:

0
1
0
0
1
1
0
0
0
1
1
0
1
0
0
1
0
0
0
1
1
1
0
0
1
0
0
0
1
0
0
0
0
0
1
0
1
0
1
1
1
1
0
1
0
1
1
0
0
0
0
1
0
0
0
0
0
1
0
1
1
2
1
0
0
1
1
0
0
1
1
1
1
1
1
0
0
0
1
0
1
0
0
0
0
1
0
0
1
1
1
1
0
0
0
1
0
0
0
0
1
0
0
0
1
1
0
1
1
1
1
0
0
0
1
1
1
1
0
0
1
0
0
0
1
1
0
0
0
1
1
1
0
1
0
0
0
0
1
0
0
0
0
1
1
1
1
0
0
1
...

result:

ok 100000 numbers

Test #24:

score: -100
Wrong Answer
time: 27ms
memory: 3736kb

input:

45369
0 0
0 -1
999999997 999999997 -999999997 -999999998
-999999997 -999999997 999999997 999999998
0 0
0 -1
999999997 999999997 -999999997 -1000000000
-999999997 -999999997 999999997 999999998
0 0
0 -1
999999997 999999997 -999999998 -999999997
-999999997 -999999997 999999997 999999998
0 0
0 -1
99999...

output:

1
0
0
1
1
0
0
1
0
0
0
1
0
0
1
1
0
0
1
0
0
0
1
0
0
1
1
0
0
1
0
0
0
1
1
1
1
1
1
1
1
1
1
1
1
0
0
1
1
0
0
1
0
0
0
1
0
0
1
1
0
0
1
0
0
0
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
0
1
1
0
0
1
0
0
0
1
0
0
1
1
0
0
1
0
0
0
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
0
1
1
0
0
...

result:

wrong answer 34th numbers differ - expected: '2', found: '1'