QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#480729#21529. 动态树(简单版)Clonoth#10 157ms6864kbC++172.6kb2024-07-16 17:54:402024-07-16 17:54:40

Judging History

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

  • [2024-07-16 17:54:40]
  • 评测
  • 测评结果:10
  • 用时:157ms
  • 内存:6864kb
  • [2024-07-16 17:54:40]
  • 提交

answer

#include<bits/stdc++.h>
#define fir first
#define sec second
#define all(x) begin(x),end(x)
using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef __int128 int128;
typedef __uint128_t uint128;
typedef pair<int,int> pii;
template<typename type>
inline void chmin(type &x,const type &y)
{
	if(y<x)
		x=y;
}
template<typename type>
inline void chmax(type &x,const type &y)
{
	if(x<y)
		x=y;
}
constexpr int Max=1.5e5+100;
int ch[Max][2],val[Max],sum[Max],fa[Max];
bool tag[Max];
#define ls(p) ch[p][0]
#define rs(p) ch[p][1]
inline bool get(const int &p)
{
	return rs(fa[p])==p;
}
inline bool is_root(const int &p)
{
	return ls(fa[p])!=p&&rs(fa[p])!=p;
}
inline void push_up(int p)
{
	sum[p]=val[p]^sum[ls(p)]^sum[rs(p)];
}
inline void set_tag(int p)
{
	swap(ls(p),rs(p));
	tag[p]^=1;
}
inline void push_down(int p)
{
	if(tag[p])
	{
		if(ls(p))
			set_tag(ls(p));
		if(rs(p))
			set_tag(rs(p));
		tag[p]=false;
	}
}
inline void rotate(const int x)
{
	const int y=fa[x],z=fa[y];
	const bool k=get(x);
	if(!is_root(y))
		ch[z][get(y)]=x;
	ch[y][k]=ch[x][!k];
	if(ch[x][!k])
		fa[ch[x][!k]]=y;
	ch[x][!k]=y,fa[y]=x,fa[x]=z;
	push_up(y),push_up(x);
}
inline void splay(const int &p)
{
	static int stk[Max];
	int x=p,top=0;
	for(;!is_root(x);x=fa[x])
		stk[++top]=x;
	push_down(x);
	for(;top;--top)
		push_down(stk[top]);
	for(int f;f=fa[p],!is_root(p);rotate(p))
		if(!is_root(f))
			rotate(get(p)==get(f)?f:p);
}
inline int access(int x)
{
	int p=0;
	for(;x;p=x,x=fa[x])
		splay(x),rs(x)=p,push_up(x);
	return p;
}
inline void make_root(const int &p)
{
	access(p),splay(p);
	set_tag(p);
}
inline int find_root(int p)
{
	access(p),splay(p),push_down(p);
	while(ls(p))
		p=ls(p),push_down(p);
	splay(p);
	return p;
}
inline void split(const int &x,const int &y)
{
	make_root(x),access(y),splay(y);
}
inline void link(const int &x,const int &y)
{
	make_root(x);
	if(find_root(y)!=x)
		fa[x]=y;
}
inline void cut(int x,int y)
{
	split(x,y);
	if(ls(y)==x)
		fa[x]=0,ls(y)=0,push_up(y);
}
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr),cout.tie(nullptr);
	int n,m,opt,x,y;
	cin>>n>>m;
	for(int i=1;i<=n;++i)
		cin>>val[i],push_up(i);
	while(m--)
	{
		cin>>opt>>x>>y;
		if(opt==0)
		{
			make_root(x);
			if(find_root(y)!=x)
				cout<<"-1\n";
			else
				split(x,y),cout<<sum[y]<<"\n";
		}
		if(opt==1)
			link(x,y);
		if(opt==2)
			cut(x,y);
		if(opt==3)
		{
			make_root(x);
			val[x]=y,push_up(x);
		}
	}
	return 0;
} 

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 3788kb

input:

1107 4572
234284072 388981847 391448440 477366271 186930123 127662721 932242109 729840760 723502273 878156702 139426149 109192182 895711735 300412478 644823004 751154835 198812322 989657237 667888533 708218412 411100292 639169500 41236867 919203199 712987474 102870210 402909302 646634540 248335431 9...

output:

-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
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
580324260
-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
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
537311125
-1
-1
-1
-1
-1
-1
-...

result:

wrong answer 390th numbers differ - expected: '280775751', found: '4169348'

Test #2:

score: 0
Wrong Answer
time: 13ms
memory: 5688kb

input:

1478 22168
569881340 405035091 712551926 875554826 406645854 501242919 392949365 237044138 991917769 860919318 602666767 824537289 108866113 139591547 894475719 715734731 605755553 104022820 783400168 675196243 810628270 544549126 785362764 761421196 242193695 758505676 432747106 153822404 399249378...

output:

-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
-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
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
645416247
-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...

result:

wrong answer 505th numbers differ - expected: '803207573', found: '-1'

Test #3:

score: 0
Wrong Answer
time: 7ms
memory: 5736kb

input:

720 11779
407324044 416057248 215358620 397121163 266598227 672056288 355038763 181861594 133030450 600486797 355994904 811704323 150048063 448794624 613007406 711725050 320509098 8205562 915133242 916173863 732977813 545177862 220442466 670371541 485288754 64702329 364293219 825915255 108377643 463...

output:

-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
-1
-1
-1
-1
879514846
-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
-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
-1
-1
-1
-1
-1
-1...

result:

wrong answer 369th numbers differ - expected: '913464523', found: '317768680'

Test #4:

score: 0
Wrong Answer
time: 7ms
memory: 3764kb

input:

152 12209
691802886 215953826 702694628 981148343 975092377 201414321 739162800 21034610 849623247 174894124 308642547 863937500 45592629 757330862 742460999 305369753 932608714 856818299 619604710 74448671 893694992 867421355 443563472 437930232 428483966 96399062 384039387 462514529 756617956 5077...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
631459582
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
691802886
-1
-1
-1
-1
-1
-1
-1
-1
612383591
-1
-1
262115550
-1
-1
-1
-1
-1
-1
578672972
-1
1041534208
-1
1043553714
-1
-1
-1
-1
255045558
-1
43398241
-1
-1
-1
-1
-1
590383248
-...

result:

wrong answer 49th numbers differ - expected: '908701981', found: '612383591'

Test #5:

score: 0
Wrong Answer
time: 16ms
memory: 3808kb

input:

1318 28124
943679982 599490657 14188757 119556929 88798936 61758796 922635692 247956744 77588643 228621429 202899979 544372814 419025104 50246858 364847087 231889637 901747480 923895179 122012732 194794597 617348787 758367265 874514156 205729541 236090640 244220088 523285104 684687814 548533722 3745...

output:

-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
-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
991383051
-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
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1...

result:

wrong answer 449th numbers differ - expected: '138525428', found: '-1'

Test #6:

score: 0
Wrong Answer
time: 7ms
memory: 3756kb

input:

1480 13659
273091642 808945296 126909509 426498595 492288255 110231631 618200926 68848092 665081898 648499844 420071326 268296562 743750189 186575204 243086966 64901921 391261005 789769656 991716058 783849739 765280282 479547496 414236979 290401751 562020126 50771452 972287665 845368884 626840962 93...

output:

-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
-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
-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
-1
-1
-1
-1
-1
-1
542153026
-1
-1
-1
-1...

result:

wrong answer 548th numbers differ - expected: '377880972', found: '-1'

Test #7:

score: 0
Wrong Answer
time: 12ms
memory: 3732kb

input:

356 22139
431594498 480475890 373890370 228894305 640208283 595505266 344572785 806115258 525318212 7434316 670399747 732635286 366145994 719043994 889163353 481316643 334053518 322709687 488052698 271041133 556891981 503463278 570978111 418427570 706300514 701112253 465872167 343854348 10796679 693...

output:

-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
431594498
-1
-1
-1
-1
-1
-1
-1
-1
291525652
-1
-1
-1
-1
-1
-1
304860923
-1
950983334
-1
-1
-1
-1
-1
-1
-1
-1
905950145
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
950983334
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

wrong answer 132nd numbers differ - expected: '468808523', found: '-1'

Test #8:

score: 0
Wrong Answer
time: 6ms
memory: 3648kb

input:

50 11882
228789343 494106370 464015946 208607989 30612082 935090584 266792064 262927962 349871422 77246250 635002760 18143685 193705091 20037444 532253744 307000673 863700107 9612369 178632626 822516422 896134450 284228663 273573982 285506358 188837597 915857315 544342920 240006709 233771383 5753795...

output:

-1
-1
-1
-1
228789343
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
670051466
-1
-1
-1
-1
-1
-1
-1
-1
-1
496723761
-1
985713324
446098660
981353785
235019794
248718352
-1
31701732
234901435
262406188
451018392
814177284
-1
50730995
-1
758291106
242059141
-1
781502968
912196781
-1
-1
892450715
244613436
537008268
-1...

result:

wrong answer 29th numbers differ - expected: '580651259', found: '446098660'

Test #9:

score: 0
Wrong Answer
time: 3ms
memory: 5684kb

input:

285 3352
582038534 874354618 806726310 653674385 772297772 295186193 603563610 369069656 585686174 161390241 223515382 798993530 34839848 597858415 632305417 284461915 396182782 530803870 966531980 290709637 319172042 322032367 551133433 955737140 820397047 398986914 822982335 590004131 622683184 21...

output:

-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
-1
171271907
-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
-1
-1
-1
-1
-1
969279505
-1
-1
-1
-1
-1
-1
451817480
-1
-1
-1
-1
-1
-1
-1
-1
-1
598515280
-1
-1
-1
-1
-1
-1
-1
-1...

result:

wrong answer 163rd numbers differ - expected: '824550042', found: '722661873'

Test #10:

score: 0
Wrong Answer
time: 9ms
memory: 3744kb

input:

1166 23009
121814457 856493653 192559916 211488994 266914699 874209553 409596930 521761274 171258686 488998014 847143010 758487957 241689123 177868187 498361258 531899010 554998825 600016801 931216265 42371861 882290673 500897222 303856950 267299623 856437526 280941209 498838974 461656089 150317958 ...

output:

-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
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
165297198
-1
-1
-1
-1
506580399
-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
-1
-1
-1
-1
-1
-1
283002036
-1
-1
-1
-1
-1
-1
...

result:

wrong answer 469th numbers differ - expected: '748678413', found: '-1'

Test #11:

score: 0
Wrong Answer
time: 105ms
memory: 5784kb

input:

12141 173689
883175862 113587309 767153473 63975437 781113122 597898346 57194917 443752894 823881866 755317463 258127039 140087455 586957338 861574464 278039976 554788225 330807907 515220000 65153632 15145921 65920285 567738421 703565961 900932465 942403662 989985109 504981988 365887866 901807269 96...

output:

205927311
246910638
281480631
269809243
781690372
950987578
795168787
368183053
630371934
1054486961
1021757717
858558127
164464388
1022496619
450508741
110947610
382489852
165979918
540041007
123321689
1017540547
819371948
476090321
343101716
893402072
147828785
158172286
709216864
965434582
617574...

result:

wrong answer 107th numbers differ - expected: '877241920', found: '-1'

Test #12:

score: 0
Wrong Answer
time: 157ms
memory: 3804kb

input:

7752 250830
597631773 176661818 485156227 625568802 597294590 597435325 857348404 817085090 592523342 8614896 28048251 874404339 485657157 744874559 357367483 825719014 146803400 302383110 309083585 192999319 546762230 544643234 678653429 996556689 849883582 508400456 948668416 371621752 382613848 1...

output:

1050456831
419222368
488997989
336653449
195501599
327111052
434050715
767026564
441213261
790612651
901483462
506139160
932029560
918888522
1017140297
783288126
734884866
510970433
708293187
581833128
1048858256
226770859
994691624
143480183
509282192
150260487
772699110
195486339
1062932224
931947...

result:

wrong answer 124th numbers differ - expected: '712069226', found: '-1'

Test #13:

score: 0
Wrong Answer
time: 71ms
memory: 5836kb

input:

11097 120973
718385601 339533874 783190518 128303612 702689502 616478192 506735841 436109766 384473588 700034175 273821837 669150027 365238310 423587058 491529666 864149457 180078920 426454885 204104900 172286883 44243149 820224797 375205789 37076769 485913472 827308047 324202282 784645010 605128383...

output:

16642499
866928015
491290382
20175087
849017793
957892935
442273857
952700538
730567793
379615236
929938784
662388043
605186702
-1
461711891
365621147
232060390
442651249
61302453
980869144
549001283
728452617
229415233
842082189
865820428
944724656
754940323
401832781
807708171
985620155
1004907112...

result:

wrong answer 93rd numbers differ - expected: '816496233', found: '-1'

Test #14:

score: 0
Wrong Answer
time: 19ms
memory: 5768kb

input:

12431 43068
32882151 121154219 299411874 283222799 337460974 218845250 713830636 148790236 720001343 301205091 440770942 40757843 968133429 923228052 289604734 736186667 587661347 708981435 813775951 874625904 567310343 442698414 997073675 253786372 940362862 304346555 655143795 383344997 990964675 ...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
13337457
993717516
-1
-1
-1
-1
-1
-1
-1
-1
34654090
811998591
-1
426209469
-1
-1
-1
967833304
-1
912420179
-1
746260061
-1
800182963
-1
-1
-1
948651189
188955015
328205473
456108887
-1
785130150
-1
-1
-1
-1
-1
-1
-1
44978402
429664792
-1
767107290
6...

result:

wrong answer 630th numbers differ - expected: '941743997', found: '-1'

Test #15:

score: 0
Wrong Answer
time: 53ms
memory: 5696kb

input:

3569 85355
340989274 973202648 19247282 372176232 424173632 284102222 245830630 76475251 210858782 148008017 411397336 319636788 743115436 301534714 718210948 378595413 108907563 232493902 73794699 941059411 454810198 266083392 313520643 505260936 551350077 898046823 922969746 326259168 864335128 98...

output:

1038885819
513687116
783996476
474637399
968721968
98519686
1066278525
386833047
925192817
163550927
699543770
866728130
359476524
708176528
932361529
274911950
295804743
1049458785
1039689933
531947647
438945604
215009755
926738759
846516082
731835150
807650956
1002936902
314768825
826270779
806937...

result:

wrong answer 58th numbers differ - expected: '632576023', found: '522257285'

Test #16:

score: 0
Wrong Answer
time: 122ms
memory: 5732kb

input:

8784 197628
236997472 828403196 555774219 209146695 253908918 61752823 460934705 127206200 950931157 904539626 559632554 637355378 154635658 923777011 445506141 558026378 363092290 420469819 26314289 345860659 453597653 870312681 830583024 629506845 264093034 191518281 406456617 458631008 21362144 7...

output:

591639787
421153822
29456765
322502311
482720930
847568115
906836675
551839663
137001206
931685400
609875210
939567620
656781528
750701676
281220702
826797240
267924607
1051164236
65645971
810385756
62567794
787504679
320608356
75272244
263215496
275942803
519968401
31334678
394381072
359367268
1024...

result:

wrong answer 169th numbers differ - expected: '1033783058', found: '-1'

Test #17:

score: 0
Wrong Answer
time: 109ms
memory: 5852kb

input:

12752 192017
732940391 996566657 646454429 744251174 63138814 179176243 284614360 952508860 453683567 308145294 446610428 622135210 87362818 430538092 168876272 217184978 660711366 578054685 287396340 33037653 390046707 68434008 534397884 708822780 949153297 380706604 402596156 453673915 280396532 1...

output:

551943332
186846837
794230633
477974123
616325420
56425310
486584270
381019607
840579445
193636645
124027339
484162574
10628006
974638964
778469647
500775157
785097108
475942864
621150115
423933377
73151766
399275589
707925405
57047553
919117332
643274700
912752747
452822303
714617274
628218997
7654...

result:

wrong answer 209th numbers differ - expected: '397676924', found: '-1'

Test #18:

score: 0
Wrong Answer
time: 94ms
memory: 3868kb

input:

7858 153287
293289490 588964112 217688247 620592747 422433255 257999041 241627372 235576742 791977172 224751651 588263307 173945591 213477227 594399068 54404444 422943469 9418343 714814000 179975901 999368692 518206286 869347173 458616660 728377002 724658548 50884538 715752571 642040443 170785705 65...

output:

677271913
446520805
215358948
58714512
1052617315
693273125
286561190
188899840
245944586
375644962
183197494
37146407
688673115
62568106
832260561
233090786
975654971
936035752
675624045
422237992
891522187
106678894
828401148
199927404
9619696
414466080
715853109
985606241
680298514
720769961
3143...

result:

wrong answer 89th numbers differ - expected: '567809309', found: '-1'

Test #19:

score: 0
Wrong Answer
time: 80ms
memory: 5724kb

input:

4529 135866
501087624 220268341 80802717 228455303 801802052 257083126 236800464 258533444 951300442 282155790 647175433 352367278 61151871 183837977 196166101 734996913 18605037 996804531 119099272 834963735 235477918 732059314 722206859 403838549 609425799 164049011 780668781 359667773 794323212 8...

output:

550087483
514892585
287161104
967100808
1008510070
110481808
132471835
305350555
719307232
335814434
614994292
332216949
677852515
669125688
50300393
184354888
568863777
13219134
610902912
419889452
935211758
330759620
654732323
598529392
752308878
433329881
846394627
957068408
353938094
84213526
42...

result:

wrong answer 113th numbers differ - expected: '1023906349', found: '-1'

Test #20:

score: 0
Wrong Answer
time: 104ms
memory: 3920kb

input:

9851 170182
633242875 976652177 677894597 46060529 207648941 397996028 499801060 808417663 957948925 568024571 224469034 664929538 245866813 510612401 80371256 215382485 745756821 499898703 887314964 45070813 482812731 51500757 45659822 555237038 76056146 46863105 685550623 839901898 449378156 95523...

output:

1022634335
430397305
706802927
792928199
234037317
614326837
19604859
174618205
573247941
328350162
754864326
21056750
405182427
4017809
417413741
123839444
360657272
754875606
257082604
238772157
68404383
24531669
10043144
339387299
1064465494
311607662
712701551
681289734
321677103
742046016
26866...

result:

wrong answer 60th numbers differ - expected: '604047783', found: '-1'

Test #21:

score: 0
Wrong Answer
time: 53ms
memory: 6532kb

input:

88850 169104
439219407 133382115 399964746 836979131 645620747 868404708 848737034 58938243 97319244 353759135 1215171 374936400 25992591 115486795 961065913 506783391 82698163 710319392 148676132 729664463 31992473 108553384 67398092 537908730 13852313 155118574 329404335 181982056 930216045 496154...

output:

-1
-1
-1
-1
-1
-1
-1
286229315
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
39280804
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
310698929
-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
-1
-1
-1
-1
43253869
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
562336464
148834...

result:

wrong answer 2707th numbers differ - expected: '383998413', found: '-1'

Test #22:

score: 0
Wrong Answer
time: 111ms
memory: 6300kb

input:

100686 276212
871549739 136160440 466533606 358530650 457719179 893818276 827731972 592096685 817772116 185943697 800658414 276247893 739963945 449453970 255084909 125882444 880433752 87861892 128476988 454878151 332781894 612647844 180211299 525852359 108314585 679923461 553988700 275471409 2692542...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
340219896
-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
-1
-1
-1
-1
-1
-1
-1
-1
354978419
-1
-1
-1
-1
-1
-1
-1
859899337
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
425105878
-1
-1
-1
-1
858390092
-1
-1
-1
-1
744394094
-1
-1
-1
-1
-1
-1
-1
591...

result:

wrong answer 2999th numbers differ - expected: '250743146', found: '-1'

Test #23:

score: 3.33333
Accepted
time: 6ms
memory: 5188kb

input:

71770 20174
184364221 351057781 887955123 330631468 743027612 227126917 476703531 191520813 940392109 510754770 82417281 11315438 842595967 295643926 714646834 423509406 136622757 409363353 192817091 758531572 498988374 821290269 480058802 228630481 544012211 715998787 150413218 866446360 8770725 72...

output:

-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
-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
-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
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 3457 numbers

Test #24:

score: 0
Wrong Answer
time: 89ms
memory: 6296kb

input:

87909 232192
840448446 798539162 348086368 316860154 288955927 519879240 53570589 162604471 532434703 847470642 63451649 527196736 821407946 337148398 921744942 398043127 711633512 463878886 799188433 845037842 959124918 445137886 186368588 462692408 497573685 41448214 677400774 935148558 949068213 ...

output:

-1
-1
-1
333627611
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
512505876
-1
-1
184479639
-1
-1
-1
612175597
-1
664606284
880036642
-1
-1
-1
-1
-1
-1
-1
-1
734223002
-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
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1...

result:

wrong answer 2849th numbers differ - expected: '768450710', found: '-1'

Test #25:

score: 0
Wrong Answer
time: 128ms
memory: 6000kb

input:

44255 241838
306372607 145838026 12744333 277579217 799007713 884285235 294354874 427411240 336661027 222390100 487638233 995501988 830486319 382941773 466029436 721504416 171216448 912534314 360374297 574640391 19876216 922985185 155197303 784807491 21513409 573064275 98966826 789945189 32147274 18...

output:

-1
912613622
-1
471020288
-1
-1
-1
409878032
99265915
802876035
-1
-1
-1
-1
228609685
-1
681159646
530072540
258136947
-1
414155644
-1
-1
-1
-1
-1
215720133
-1
-1
-1
1072553668
-1
889370878
148245608
583134719
197918857
-1
853663447
-1
-1
-1
165850600
-1
-1
-1
174081333
584302692
-1
561135778
-1
-1
...

result:

wrong answer 776th numbers differ - expected: '98071260', found: '-1'

Test #26:

score: 0
Wrong Answer
time: 28ms
memory: 6864kb

input:

146469 105266
687560601 637165872 441062755 584116731 556695856 515380725 585339808 903253758 805470547 357493584 229359761 134463633 156065639 228688299 743405146 382576767 109098874 880362763 738419828 250624618 44896046 118841397 136431313 685391452 67276138 21915261 172678386 326150466 403210766...

output:

-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
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
707646521
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
101792229
-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
-...

result:

wrong answer 18080th numbers differ - expected: '949629984', found: '703407464'

Test #27:

score: 0
Wrong Answer
time: 59ms
memory: 6380kb

input:

112953 202967
197284148 928802535 251937479 121244058 288345774 975569553 787386847 924361223 298271426 323903146 673044180 333269914 65502445 131967789 189709201 790481915 822824468 89085604 274904826 541555685 623488377 273602551 388677449 492681157 876734975 55064512 716538926 994623213 564098007...

output:

-1
-1
899396878
-1
-1
725845812
-1
-1
-1
-1
482914230
-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
-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
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

wrong answer 7012th numbers differ - expected: '749342537', found: '-1'

Test #28:

score: 0
Wrong Answer
time: 29ms
memory: 5912kb

input:

31437 78846
86857094 881151353 593146160 278108630 406500293 686412410 205681479 179868394 172610736 499973030 543936064 747238933 483715739 180460896 268030784 455270700 694413874 463547835 347514079 692026356 346703794 786009263 534100007 934944507 599505567 340940560 261977671 369493300 211771924...

output:

-1
-1
-1
-1
-1
-1
74449735
749348950
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
318452315
-1
-1
-1
94824138
-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
639438054
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
164449356
-1
-1
585007174
-1
-1
8...

result:

wrong answer 1151st numbers differ - expected: '176563802', found: '-1'

Test #29:

score: 3.33333
Accepted
time: 11ms
memory: 6716kb

input:

146155 19544
53461408 808048986 500213095 878164415 999654460 709393475 228471199 919424252 66896735 788719948 555663678 750644591 481969923 694955785 754663033 991994778 742698390 980213089 151399712 193051784 439140743 388837715 954068772 366730069 465171183 766271313 238952337 735839583 264773286...

output:

-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
-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
-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
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 3413 numbers

Test #30:

score: 3.33333
Accepted
time: 19ms
memory: 6404kb

input:

112696 57845
47907900 343450520 89144409 440456264 667543391 303895553 210902706 781845523 713539202 146722972 969702927 847501427 938093585 911332046 426960599 881156825 49738742 286641108 661570895 153564993 724415099 844706297 133510385 692926046 82731928 239636558 544427419 969092958 564525153 8...

output:

-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
-1
-1
-1
37848484
-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
-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
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 10127 numbers