QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#466025#8468. Collinear ArrangementsLRAC ✓183ms7076kbC++205.0kb2024-07-07 14:53:122024-07-07 14:53:15

Judging History

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

  • [2024-07-07 14:53:15]
  • 评测
  • 测评结果:AC
  • 用时:183ms
  • 内存:7076kb
  • [2024-07-07 14:53:12]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define mod 998244353
#define int long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
void print(vector<int> x){for(int i=0;i<(int)x.size();i++) printf("%d%c",x[i]," \n"[i==(int)x.size()-1]);}
#define N 200005
struct Vec
{
	int x,y;
	Vec(int a=0,int b=0) {x=a,y=b;}
};
Vec operator + (const Vec &x,const Vec &y) {return Vec(x.x+y.x,x.y+y.y);}
Vec operator - (const Vec &x,const Vec &y) {return Vec(x.x-y.x,x.y-y.y);}
Vec operator * (const Vec &x,const int y) {return Vec(x.x*y,x.y*y);}
Vec operator / (const Vec &x,const int y) {return Vec(x.x/y,x.y/y);}
int cdot(const Vec &x,const Vec &y) {return x.x*y.x+x.y*y.y;}
int cross(const Vec &x,const Vec &y) {return x.x*y.y-x.y*y.x;}
int norm(Vec x) {return x.x*x.x+x.y*x.y;}
Vec rot90(Vec x) {return Vec(x.y,-x.x);}
Vec a[N];
int n,QQ;

//void solve()
//{
//    Vec P,Q;
//    P.x=read(),P.y=read();
//    Q.x=read(),Q.y=read();
//    Vec v=rot90(Q-P);
//    int orig=1;
//    while(cdot(a[orig+1]-a[orig],v)==0) orig++;
//    int c1=orig;
//    if(cdot(a[c1+1]-a[c1],v)<0) v=v*(-1);
//    // printf("%d %d\n",v.x,v.y);
//    for(int i=17;i>=0;i--)
//    {
//        if(c1+(1<<i)<=orig+n-1)
//        {
//            int tw=c1+(1<<i);
//            if(cdot(v,a[tw+1]-a[tw])>0&&cdot(v,a[tw]-a[c1])>=0) c1+=(1<<i);
//        }
//    }
//    c1=c1%n+1;
//    int c2=c1;
//    v=v*(-1);
//    // printf("%d %d\n",v.x,v.y);
//    // cout<<cdot(v,a[tw]-a[i])<<endl;
//    for(int i=17;i>=0;i--)
//    {
//        if(c2+(1<<i)<=c1+n-1)
//        {
//            int tw=c2+(1<<i);
//            if(cdot(v,a[tw+1]-a[tw])>0&&cdot(v,a[tw]-a[c2])>=0) c2+=(1<<i);
//        }
//    }
//    c2++;
//    // printf("%d %d\n",c1,c2);
//    auto find=[&](int l,int r)->int
//    {
//        int o=cross(Q-P,a[l]-P);
//        if(o==0) return 1;
//        while(l<=r)
//        {
//            int mid=(l+r)/2;
//            int tw=cross(Q-P,a[mid]-P);
//            if(tw==0) return 1;
//            if((tw>0)==(o>0)) l=mid+1;
//            else r=mid-1;
//        }
//        return 0;
//    };
//    int ans=0;
//    ans+=find(c1+1,c2);
//    ans+=find(c2+1,c1+n);
//    printf("%lld\n",ans);
//}

signed main()
{
	cin>>n>>QQ;
	for(int i=1;i<=n;i++) a[i].x=read(),a[i].y=read(),a[i+n]=a[i];
	a[n+n+1]=a[1];
	while(QQ--)
	{
		int op=read();
		if(op==2)
		{
			Vec P,Q;
			P.x=read(),P.y=read();
			Q.x=read(),Q.y=read();
			Vec v=rot90(Q-P);
			int orig=1;
			while(cdot(a[orig+1]-a[orig],v)==0) orig++;
			int c1=orig;
			if(cdot(a[c1+1]-a[c1],v)<0) v=v*(-1);
			// printf("%d %d\n",v.x,v.y);
			for(int i=17;i>=0;i--)
			{
				if(c1+(1<<i)<=orig+n-1)
				{
					int tw=c1+(1<<i);
					if(cdot(v,a[tw+1]-a[tw])>0&&cdot(v,a[tw]-a[c1])>=0) c1+=(1<<i);
				}
			}
			c1=c1%n+1;
			int c2=c1;
			v=v*(-1);
			// printf("%d %d\n",v.x,v.y);
			// cout<<cdot(v,a[tw]-a[i])<<endl;
			for(int i=17;i>=0;i--)
			{
				if(c2+(1<<i)<=c1+n-1)
				{
					int tw=c2+(1<<i);
					if(cdot(v,a[tw+1]-a[tw])>0&&cdot(v,a[tw]-a[c2])>=0) c2+=(1<<i);
				}
			}
			c2++;
			// printf("%d %d\n",c1,c2);
			auto find=[&](int l,int r)->int
			{
				int o=cross(Q-P,a[l]-P);
				if(o==0) return 1;
				while(l<=r)
				{
					int mid=(l+r)/2;
					int tw=cross(Q-P,a[mid]-P);
					if(tw==0) return 1;
					if((tw>0)==(o>0)) l=mid+1;
					else r=mid-1;
				}
				return 0;
			};
			int ans=0;
			ans+=find(c1+1,c2);
			ans+=find(c2+1,c1+n);
			printf("%lld\n",ans);
		}
		else
		{
			Vec P;
			P.x=read(),P.y=read();
			int siz1=0,siz2=0;
			for(int i=1;i<=n;i++) siz1+=abs(cross(a[i+1]-P,a[i]-P));
			for(int i=2;i+1<=n;i++) siz2+=abs(cross(a[i+1]-a[1],a[i]-a[1]));
			// printf("%d %d\n",siz1,siz2);
			if(siz1==siz2)
			{
				int ans=0,j=1;
				for(int i=1;i<=n;i++)
				{
					while(i==j||cross(a[i]-P,a[j]-P)>0) j++;
					// printf("%d %d %d\n",i,j,cross(a[i]-P,a[j]-P));
					if(cross(a[i]-P,a[j]-P)==0) ans++;
				}
				printf("%d\n",ans/2);
			}
			else
			{
				int l=1,r=1;
				for(int i=2;i<=n;i++)
				{
					if(cross(P-a[l],P-a[i])>0 || (cross(P-a[l],P-a[i])==0&&norm(P-a[i])>norm(P-a[l]))) l=i;
					if(cross(P-a[r],P-a[i])<0 || (cross(P-a[r],P-a[i])==0&&norm(P-a[i])>norm(P-a[r]))) r=i;
				}
				swap(l,r);
				// printf("%d %d\n",l,r);
				int cl=l,cr=l-1+n,ans=0;
				if((r+1)%n==l%n) {}
				else
				{
					while(1)
					{
						if(cross(P-a[cl],P-a[cr])==0) ans++;
						// printf("* %d %d\n",cl,cr);
						if(cl%n==r%n&&cr%n==(r+1)%n) break;
						if(cl%n==r%n) cr--;
						else if(cr%n==(r+1)%n) cl++;
						else
						{
							if(cross(P-a[cl],P-a[cr])>0) cl++;
							else cr--;
						}
					}
				}
				printf("%d\n",ans);
			}
		}
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

1
1
2

result:

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

Test #2:

score: 0
Accepted
time: 1ms
memory: 6876kb

input:

3 1
0 0
1 0
0 1
2 1 1 2 2

output:

1

result:

ok 1 number(s): "1"

Test #3:

score: 0
Accepted
time: 1ms
memory: 6936kb

input:

1000 1
-139438978 -172098481
-125097652 -169056403
155419484 -28898293
186215972 6874955
240691742 77644763
334255616 236444333
342049790 274206233
342049766 274611851
342049472 275025569
342049298 275242193
342048794 275724449
341967248 297262013
341966000 297569423
341963012 298092233
341960624 29...

output:

2

result:

ok 1 number(s): "2"

Test #4:

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

input:

1000 1000
-468718512 100559444
-466285968 100587272
-463035240 100649294
-461326068 100761398
-459427038 100900610
-455064924 101233256
-452216364 101462348
-450021522 101653544
-449086266 101738960
-433665372 103152428
-429959922 103532498
-427457166 103795826
-418983006 104802926
-416443854 105124...

output:

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

result:

ok 1000 numbers

Test #5:

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

input:

1000 1000
291905682 -484091301
292345158 -484089105
293043996 -484085421
293229030 -484083753
294173520 -484069809
295110540 -484052169
295788516 -484035897
296416644 -484020435
297309864 -483994563
298153872 -483966843
298820190 -483943245
299094912 -483933453
299710446 -483910407
300478542 -483880...

output:

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

result:

ok 1000 numbers

Test #6:

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

input:

1000 1000
463991467 -623310294
464470495 -623309436
465819133 -623286270
467660659 -623248944
468504043 -623229894
469509451 -623204460
470851615 -623169126
471516523 -623147304
472441747 -623112894
472919839 -623093316
474518035 -623025924
474804205 -623012706
475235047 -622991898
476703709 -622918...

output:

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

result:

ok 1000 numbers

Test #7:

score: 0
Accepted
time: 3ms
memory: 6852kb

input:

1000 1000
597768588 -776829559
695444592 -772463455
710728284 -769091269
734199300 -761581069
739470810 -759493921
753859266 -752938249
776956332 -740945395
796659384 -730287457
808527768 -720807907
812395620 -716639341
825659472 -700122877
827653218 -697247683
842474466 -675492391
851577600 -653064...

output:

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

result:

ok 1000 numbers

Test #8:

score: 0
Accepted
time: 3ms
memory: 6880kb

input:

1000 1000
579713329 -733712553
582502873 -733705833
583276357 -733693923
584906899 -733655109
585175081 -733646925
585834175 -733622973
586633297 -733577085
587460043 -733521285
588822205 -733427661
590453503 -733304973
597306625 -732777171
598333501 -732693489
599098081 -732627291
600848677 -732431...

output:

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

result:

ok 1000 numbers

Test #9:

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

input:

1000 1000
383687106 -662965444
404629848 -661971364
456196932 -656303110
481565838 -653442130
491580000 -652286890
513183840 -649621300
524886738 -648156736
541734714 -643846294
553325220 -640595362
571836426 -634565194
585246582 -627706948
591259860 -623361106
597943836 -617700448
605975550 -610284...

output:

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

result:

ok 1000 numbers

Test #10:

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

input:

1000 1000
-89995087 -831851181
-87346021 -831828921
-84891511 -831744171
-79568203 -831225225
-76494727 -830921307
-73235665 -830589153
-66234565 -829871907
-61345657 -829265043
-56094727 -828518091
-47397535 -827143263
-45247975 -826735329
-38182327 -825371001
-32179177 -823926267
-27420181 -822702...

output:

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

result:

ok 1000 numbers

Test #11:

score: 0
Accepted
time: 3ms
memory: 7012kb

input:

1000 1000
-521920755 -589450110
-520843161 -589430664
-517059531 -589333902
-516294063 -589313100
-515588943 -589289712
-514711401 -589245060
-514212489 -589217784
-513590589 -589180032
-513090177 -589143018
-512462637 -589093266
-510832209 -588943758
-510717465 -588932748
-510366333 -588897438
-508...

output:

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

result:

ok 1000 numbers

Test #12:

score: 0
Accepted
time: 3ms
memory: 6872kb

input:

1000 1000
135678973 -512731173
138245143 -512730873
139620511 -512727279
140549359 -512723109
141179551 -512719341
143033407 -512699013
144022339 -512685993
144735325 -512673687
145503247 -512659455
147606127 -512618625
148360033 -512597373
149010193 -512578485
149738023 -512546715
149970055 -512536...

output:

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

result:

ok 1000 numbers

Test #13:

score: 0
Accepted
time: 3ms
memory: 6924kb

input:

1000 1000
351347924 -65748475
372897926 -65360617
383223914 -65023771
395934266 -64493569
518888294 -52852315
534293948 -49392937
547110512 -45728953
559110452 -41992699
564454634 -40209025
568267940 -37798795
570194018 -36499723
575066318 -32769325
577860548 -30401929
589115126 -18589639
592627520 ...

output:

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

result:

ok 1000 numbers

Test #14:

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

input:

3920 1000
0 -1179960
60 -1179960
2460 -1179900
4800 -1179840
7080 -1179780
9300 -1179720
11460 -1179660
13560 -1179600
15600 -1179540
17580 -1179480
19500 -1179420
21360 -1179360
23160 -1179300
24900 -1179240
26580 -1179180
28200 -1179120
29760 -1179060
31260 -1179000
32700 -1178940
34080 -1178880
3...

output:

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

result:

ok 1000 numbers

Test #15:

score: 0
Accepted
time: 5ms
memory: 7076kb

input:

3920 1000
0 -1179960
60 -1179960
2460 -1179900
4800 -1179840
7080 -1179780
9300 -1179720
11460 -1179660
13560 -1179600
15600 -1179540
17580 -1179480
19500 -1179420
21360 -1179360
23160 -1179300
24900 -1179240
26580 -1179180
28200 -1179120
29760 -1179060
31260 -1179000
32700 -1178940
34080 -1178880
3...

output:

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

result:

ok 1000 numbers

Test #16:

score: 0
Accepted
time: 5ms
memory: 6936kb

input:

3920 1000
0 -1179960
60 -1179960
2460 -1179900
4800 -1179840
7080 -1179780
9300 -1179720
11460 -1179660
13560 -1179600
15600 -1179540
17580 -1179480
19500 -1179420
21360 -1179360
23160 -1179300
24900 -1179240
26580 -1179180
28200 -1179120
29760 -1179060
31260 -1179000
32700 -1178940
34080 -1178880
3...

output:

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

result:

ok 1000 numbers

Test #17:

score: 0
Accepted
time: 5ms
memory: 6860kb

input:

3920 1000
0 -1179960
60 -1179960
2460 -1179900
4800 -1179840
7080 -1179780
9300 -1179720
11460 -1179660
13560 -1179600
15600 -1179540
17580 -1179480
19500 -1179420
21360 -1179360
23160 -1179300
24900 -1179240
26580 -1179180
28200 -1179120
29760 -1179060
31260 -1179000
32700 -1178940
34080 -1178880
3...

output:

0
1
1
2
2
1
1
2
0
1
0
0
0
2
1
0
1
1
4
1
0
2
2
1
0
2
0
0
0
2
2
1
0
1
1
1
2
2
0
1
2
1
1
2
1
2
1
2
2
0
0
2
1
1
2
1
1
2
0
1
1
1
0
1
1
2
0
0
1
1
0
1
1
2
1960
1
2
2
1
0
1
0
2
2
1960
2
1
2
0
1
2
0
1
1
0
2
2
1960
0
1
2
1
1
1
1
0
1
2
1
0
0
0
2
2
1
2
2
2
1
0
0
2
1
0
1
1960
2
1
0
1
1
0
0
1
0
0
1
1
1
0
2
2
2
2
...

result:

ok 1000 numbers

Test #18:

score: 0
Accepted
time: 5ms
memory: 6876kb

input:

3920 1000
0 -1179960
60 -1179960
2460 -1179900
4800 -1179840
7080 -1179780
9300 -1179720
11460 -1179660
13560 -1179600
15600 -1179540
17580 -1179480
19500 -1179420
21360 -1179360
23160 -1179300
24900 -1179240
26580 -1179180
28200 -1179120
29760 -1179060
31260 -1179000
32700 -1178940
34080 -1178880
3...

output:

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

result:

ok 1000 numbers

Test #19:

score: 0
Accepted
time: 179ms
memory: 7004kb

input:

100000 100000
-418102239 223818986
-418082643 223818992
-418037097 223819010
-418023831 223819016
-418013145 223819022
-418002855 223819028
-417913239 223819082
-417895167 223819094
-417868593 223819112
-417852999 223819124
-417829815 223819142
-417815205 223819154
-417786147 223819184
-417768957 22...

output:

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

result:

ok 100000 numbers

Test #20:

score: 0
Accepted
time: 162ms
memory: 6940kb

input:

100000 100000
-276134066 -503012660
-275738384 -503012546
-275663552 -503012498
-275354702 -503012090
-275128778 -503011136
-274660916 -503009024
-274354484 -503007566
-274104674 -503006222
-273798758 -503004422
-273725066 -503003792
-273284342 -502999136
-272695652 -502992620
-272299490 -502988048
...

output:

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

result:

ok 100000 numbers

Test #21:

score: 0
Accepted
time: 176ms
memory: 6952kb

input:

100000 100000
228477106 -369814133
228540658 -369814127
228577504 -369814121
228588958 -369814115
228644038 -369814085
228654424 -369814079
228695050 -369814055
228714850 -369814043
228729544 -369814031
228743362 -369814019
228767248 -369813995
228778834 -369813983
228807766 -369813953
228830632 -36...

output:

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

result:

ok 100000 numbers

Test #22:

score: 0
Accepted
time: 174ms
memory: 6924kb

input:

100000 100000
525617893 -226281892
525629629 -226281886
525637555 -226281880
525645085 -226281874
525652075 -226281868
525658885 -226281862
525665629 -226281856
525671911 -226281850
525677935 -226281844
525683869 -226281838
526227271 -226281268
526232989 -226281262
526238629 -226281256
526244119 -22...

output:

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

result:

ok 100000 numbers

Test #23:

score: 0
Accepted
time: 146ms
memory: 6920kb

input:

100000 100000
163690066 -967463502
165164092 -967456410
167387284 -967382670
170056414 -967290504
172555138 -967177284
175929010 -966885726
177606868 -966726282
184872424 -966023100
186231028 -965882244
188396074 -965647470
190660930 -965372988
192604990 -965132958
194405512 -964854216
195336406 -96...

output:

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

result:

ok 100000 numbers

Test #24:

score: 0
Accepted
time: 175ms
memory: 6920kb

input:

100000 100000
-64915802 65837742
-64875074 65837748
-64839002 65837754
-64805768 65837760
-64775174 65837766
-64709402 65837784
-64678898 65837796
-64651604 65837808
-64614236 65837826
-64578602 65837844
-64567022 65837850
-64527572 65837874
-64519796 65837880
-64480490 65837916
-64455026 65837940
-...

output:

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

result:

ok 100000 numbers

Test #25:

score: 0
Accepted
time: 182ms
memory: 6936kb

input:

100000 100000
-491933540 35290201
-491877926 35290207
-491852606 35290213
-491827430 35290219
-491787680 35290237
-491749004 35290255
-491718734 35290273
-491680310 35290303
-491646686 35290333
-491618120 35290363
-491583362 35290405
-491578508 35290411
-491516978 35290507
-491438336 35290639
-49125...

output:

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

result:

ok 100000 numbers

Test #26:

score: 0
Accepted
time: 182ms
memory: 6940kb

input:

100000 100000
-230292634 242663945
-230276314 242663951
-230260138 242663957
-230246698 242663963
-230236120 242663969
-230227096 242663975
-230218252 242663981
-230210476 242663987
-230203042 242663993
-230188810 242664005
-230182510 242664011
-230170432 242664023
-230164600 242664029
-230146810 24...

output:

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

result:

ok 100000 numbers

Test #27:

score: 0
Accepted
time: 183ms
memory: 6924kb

input:

100000 100000
-289389717 109262396
-289366203 109262402
-289344537 109262408
-289332597 109262414
-289321521 109262420
-289202493 109262486
-289192659 109262492
-289183143 109262498
-289173753 109262504
-289164669 109262510
-289155765 109262516
-289147389 109262522
-289139925 109262528
-289132803 10...

output:

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

result:

ok 100000 numbers

Test #28:

score: 0
Accepted
time: 182ms
memory: 6848kb

input:

99712 100000
0 -151425780
60 -151425780
12180 -151425720
24240 -151425660
36240 -151425600
48180 -151425540
60060 -151425480
71880 -151425420
83640 -151425360
95340 -151425300
106980 -151425240
118560 -151425180
130080 -151425120
141540 -151425060
152940 -151425000
164280 -151424940
175560 -15142488...

output:

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

result:

ok 100000 numbers

Test #29:

score: 0
Accepted
time: 180ms
memory: 7008kb

input:

99712 100000
0 -151425780
60 -151425780
12180 -151425720
24240 -151425660
36240 -151425600
48180 -151425540
60060 -151425480
71880 -151425420
83640 -151425360
95340 -151425300
106980 -151425240
118560 -151425180
130080 -151425120
141540 -151425060
152940 -151425000
164280 -151424940
175560 -15142488...

output:

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

result:

ok 100000 numbers

Test #30:

score: 0
Accepted
time: 163ms
memory: 6920kb

input:

99712 100000
0 -151425780
60 -151425780
12180 -151425720
24240 -151425660
36240 -151425600
48180 -151425540
60060 -151425480
71880 -151425420
83640 -151425360
95340 -151425300
106980 -151425240
118560 -151425180
130080 -151425120
141540 -151425060
152940 -151425000
164280 -151424940
175560 -15142488...

output:

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

result:

ok 100000 numbers

Test #31:

score: 0
Accepted
time: 159ms
memory: 6932kb

input:

99712 100000
0 -151425780
60 -151425780
12180 -151425720
24240 -151425660
36240 -151425600
48180 -151425540
60060 -151425480
71880 -151425420
83640 -151425360
95340 -151425300
106980 -151425240
118560 -151425180
130080 -151425120
141540 -151425060
152940 -151425000
164280 -151424940
175560 -15142488...

output:

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

result:

ok 100000 numbers

Test #32:

score: 0
Accepted
time: 164ms
memory: 7008kb

input:

99712 100000
0 -151425780
60 -151425780
12180 -151425720
24240 -151425660
36240 -151425600
48180 -151425540
60060 -151425480
71880 -151425420
83640 -151425360
95340 -151425300
106980 -151425240
118560 -151425180
130080 -151425120
141540 -151425060
152940 -151425000
164280 -151424940
175560 -15142488...

output:

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

result:

ok 100000 numbers