QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#188027#7447. wcirqCrysfly100 ✓5907ms889564kbC++202.6kb2023-09-25 11:51:062023-09-25 11:51:08

Judging History

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

  • [2023-09-25 11:51:08]
  • 评测
  • 测评结果:100
  • 用时:5907ms
  • 内存:889564kb
  • [2023-09-25 11:51:06]
  • 提交

answer

#include<bits/stdc++.h>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(register int i=(a);i>=(b);--i)
#define ll long long
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;

#define maxn 1000005
#define N 10000005
#define inf 0x3f3f3f3f

void op1(int x,int y);
void op2(int k);

// dep = 10~0 , dep = 0 is leaf 
int pw[114],num;
int sz[N],v0[N],rt,cnt=1000000; 
bool col[N];
vi ch[N],nd0[N],nd1[N];

inline void upsiz(int u){
	sz[u]=0;
	for(auto v:ch[u])sz[u]+=sz[v];
}
void dfs(int u,int d,int tp,int fg){
	if(!d){
		if(fg) nd1[tp].pb(u);
		else nd0[tp].pb(u);
	}
	for(auto v:ch[u])dfs(v,d-1,tp,fg); 
}
void color(int u,int d){
	v0[u]=++cnt,++cnt;
	col[cnt-1]=col[cnt]=col[u];
	int now=0,flag=0;
	for(int i=0;i<ch[u].size();++i){
		int v=ch[u][i];
		now+=sz[v];
		dfs(v,d-1,u,col[v]=flag);
		if(now>=pw[d-1])flag=1;
	}
}
void split(int u,int f,int d){
	col[v0[u]]=col[v0[u]+1]=col[u];
	for(auto v:ch[u]) ch[v0[u]+col[v]].pb(v);
	ch[u].clear(),ch[u].shrink_to_fit();
	vi nch;
	for(auto v:ch[f]){
		if(v==u) nch.pb(v0[u]),nch.pb(v0[u]+1);
		else nch.pb(v);
	}
	ch[f]=nch;
	upsiz(v0[u]),upsiz(v0[u]+1);
}
void ins(int&u,int pa,int d,int k)
{
	if(!u) u=++cnt;
	if(!d) exit(233);
	
	op1(u,num),++sz[u];
	
	if(d==1){
		vi nch;
		For(i,0,k-1)nch.pb(ch[u][i]);
		nch.pb(num);
		For(i,k,(int)ch[u].size()-1)nch.pb(ch[u][i]);
		ch[u]=nch;
		if(ch[u].size()==4){
			v0[u]=++cnt,++cnt;
			sz[cnt-1]=sz[cnt]=2;
			col[cnt-1]=col[cnt]=col[u];
			For(i,0,3){
				int v=ch[u][i];
				col[v]=(i>1);
				op1(v0[u]+col[v],v);
			}
			split(u,pa,d);
		}
		return;
	}
	
	if(!ch[u].size()) ch[u].pb(++cnt);
	if(sz[u]==3*pw[d-1]+1)
		color(u,d);
	
	for(auto v:ch[u]){
		if(k<=sz[v]){
			ins(v,u,d-1,k);
			if(sz[u]>3*pw[d-1]) op1(col[v]+v0[u],num);
			break;
		}
		k-=sz[v];
	}
	if(sz[u]>3*pw[d-1]){
		int s=3;
		while(s&&nd0[u].size()) op1(v0[u],nd0[u].back()),nd0[u].pop_back(),--s;
		while(s&&nd1[u].size()) op1(v0[u]+1,nd1[u].back()),nd1[u].pop_back(),--s;
	}
	if(sz[u]==pw[d]) split(u,pa,d);
}
void ask(int u,int l,int r)
{
	if(l>r||r<=0||l>sz[u])return;
	if(l==1&&r==sz[u])return op2(u);
	for(auto v:ch[u]){
		ask(v,max(l,1),min(r,sz[v]));
		l-=sz[v],r-=sz[v];
		if(r<=0)break;
	}
}

void init(){
	pw[0]=1; sz[0]=1;
	For(i,1,11)pw[i]=pw[i-1]<<2;
}
void solve(int x,int l,int r)
{
	if(!num)init();
	++num; op1(num,num); sz[num]=1;
	ins(rt,0,10,x-1);
	ask(rt,l,r);
}

//signed main(){
//	solve(1,1,1);
//	return 0;
//}

详细

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 128ms
memory: 707060kb

input:

1000
64 256
1 1 1
1 2 2
3 2 2
3 2 3
1 1 1
1 1 4
1 2 4
1 4 5
1 4 6
10 1 10
9 1 9
12 5 12
13 4 13
4 7 11
3 6 14
16 1 12
1 12 15
18 3 10
14 8 17
1 6 13
1 8 21
20 12 12
3 9 21
19 16 19
1 4 19
1 7 22
27 19 20
15 25 25
1 17 27
1 14 30
1 18 31
12 26 31
1 1 32
1 10 13
35 13 27
36 21 25
1 3 29
1 4 35
31 5 20...

output:

2014222606 2664606283
2014222606 2664606283
2014222606 2664606283
3643713394 821987049
2895435421 2688803510
4017939480 522335892
2003716874 2152696905
2524667448 1177692306
2003716874 2152696905
2596105510 2894201686
4264229821 2513336923
512702587 4014518344
1722866020 3348127369
2036787620 608727...

result:

ok 2000 numbers

Test #2:

score: 0
Accepted
time: 99ms
memory: 707348kb

input:

1000
64 256
1 1 1
1 1 1
1 2 2
4 1 4
2 2 5
4 1 3
3 5 7
8 1 4
2 2 6
1 5 7
1 11 11
1 3 9
13 3 9
1 7 10
3 1 3
4 8 8
17 17 17
1 1 18
19 9 14
5 10 20
10 10 15
11 16 22
1 1 5
24 1 24
18 1 12
26 13 26
20 13 20
1 1 1
7 1 7
22 1 7
7 7 7
16 8 24
16 1 33
25 1 34
35 8 17
27 1 18
1 9 9
9 9 19
9 19 29
20 20 30
20 ...

output:

2014222606 2664606283
3924199323 2783856092
3924199323 2783856092
4063879086 2473184589
1873413546 1999679355
3315601113 45033754
3122762820 1796991648
2008293572 2251414213
3732442830 2320524711
2095941208 1670273854
3210132359 1235282565
37227053 836932072
37227053 836932072
696409333 64110068
308...

result:

ok 2000 numbers

Test #3:

score: 0
Accepted
time: 115ms
memory: 707340kb

input:

1000
64 256
1 1 1
1 1 1
1 1 2
2 1 3
2 1 3
4 1 3
7 5 5
7 1 1
3 1 8
1 9 10
1 8 10
6 2 10
9 1 10
1 10 13
9 4 5
3 4 9
1 2 3
14 10 17
12 13 18
5 4 6
3 11 12
2 2 13
6 22 23
4 6 24
16 16 25
18 1 1
19 8 18
1 11 15
28 6 29
7 16 18
18 7 25
6 25 28
2 22 33
11 4 28
15 1 1
34 9 14
17 27 30
6 2 16
1 23 39
26 12 2...

output:

2014222606 2664606283
3924199323 2783856092
420165692 1651197540
2049656480 4103545602
1020892578 4008493020
1020892578 4008493020
3924199323 2783856092
790933665 3162308744
4094595197 1038755314
1902824818 3441663024
558619696 2388777644
759909680 520460396
2744676911 2939935729
2289733703 74738207...

result:

ok 2000 numbers

Subtask #2:

score: 10
Accepted

Test #4:

score: 10
Accepted
time: 2306ms
memory: 840688kb

input:

1000000
64 256
1 1 1
1 1 2
3 1 3
1 1 4
2 1 5
2 1 6
7 1 7
1 1 8
7 1 9
2 1 10
1 1 11
4 1 12
6 1 13
1 1 14
11 1 15
1 1 16
17 1 17
18 1 18
19 1 19
20 1 20
1 1 21
15 1 22
20 1 23
9 1 24
1 1 25
1 1 26
27 1 27
28 1 28
26 1 29
1 1 30
31 1 31
26 1 32
33 1 33
10 1 34
35 1 35
36 1 36
37 1 37
25 1 38
31 1 39
8 ...

output:

2014222606 2664606283
1643454633 1153495079
2434388298 20836527
4063879086 2473184589
2664347211 867020803
2143396637 1842025402
836089096 4048405861
4046221455 988721130
2787287656 3245135773
2596105510 2894201686
569014044 1029744284
635643032 2097666018
2366757039 456270444
1386748956 3077472576
...

result:

ok 2000000 numbers

Test #5:

score: 0
Accepted
time: 1986ms
memory: 855752kb

input:

1000000
64 256
1 1 1
1 1 2
1 1 3
3 1 4
4 1 5
2 1 6
3 1 7
1 1 8
1 1 9
10 1 10
3 1 11
9 1 12
6 1 13
8 1 14
4 1 15
4 1 16
1 1 17
1 1 18
17 1 19
20 1 20
21 1 21
19 1 22
2 1 23
7 1 24
12 1 25
2 1 26
24 1 27
1 1 28
29 1 29
15 1 30
1 1 31
1 1 32
9 1 33
30 1 34
28 1 35
36 1 36
22 1 37
38 1 38
23 1 39
1 1 40...

output:

2014222606 2664606283
1643454633 1153495079
2434388298 20836527
4063879086 2473184589
2664347211 867020803
2143396637 1842025402
836089096 4048405861
4046221455 988721130
2787287656 3245135773
2596105510 2894201686
569014044 1029744284
635643032 2097666018
2366757039 456270444
1386748956 3077472576
...

result:

ok 2000000 numbers

Subtask #3:

score: 10
Accepted

Test #6:

score: 10
Accepted
time: 3267ms
memory: 889564kb

input:

1000000
64 256
1 1 1
2 1 1
3 1 1
4 2 3
5 4 4
6 2 6
7 1 4
8 4 7
9 4 5
10 5 10
11 7 9
12 5 8
13 8 11
14 3 9
15 3 10
16 9 11
17 3 10
18 9 16
19 4 4
20 19 20
21 5 14
22 17 17
23 15 19
24 2 2
25 10 15
26 9 21
27 10 22
28 2 18
29 4 13
30 6 19
31 5 24
32 9 22
33 16 26
34 8 12
35 4 28
36 4 7
37 25 28
38 15 ...

output:

2014222606 2664606283
2014222606 2664606283
2014222606 2664606283
420165692 1651197540
1629490788 2452348062
129174031 3472386415
4063879086 2473184589
2696668094 4027569334
229958913 846184276
2827193720 421017097
643891019 1403110371
4277309665 2810503837
4027892244 1276305719
1143833023 209164069...

result:

ok 2000000 numbers

Test #7:

score: 0
Accepted
time: 2066ms
memory: 885608kb

input:

1000000
64 256
1 1 1
2 1 1
3 1 1
4 1 2
5 2 4
6 3 3
7 4 7
8 1 5
9 2 7
10 1 1
11 6 11
12 1 2
13 5 6
14 1 5
15 4 15
16 1 9
17 3 10
18 3 5
19 7 7
20 1 12
21 1 8
22 1 19
23 18 20
24 7 21
25 15 17
26 1 10
27 1 16
28 8 22
29 5 8
30 3 9
31 6 9
32 3 32
33 1 26
34 10 20
35 7 24
36 1 10
37 33 37
38 3 22
39 1 1...

output:

2014222606 2664606283
2014222606 2664606283
2014222606 2664606283
1643454633 1153495079
2049656480 4103545602
790933665 3162308744
2696668094 4027569334
2664347211 867020803
3116833786 1383799578
2014222606 2664606283
2199634129 162723481
1643454633 1153495079
2374484847 3663808109
2664347211 867020...

result:

ok 2000000 numbers

Subtask #4:

score: 20
Accepted

Dependency #1:

100%
Accepted

Test #8:

score: 20
Accepted
time: 119ms
memory: 708272kb

input:

10000
64 256
1 1 1
1 1 1
2 3 3
4 1 2
1 3 4
1 1 2
1 1 5
1 2 7
8 1 5
3 2 4
9 1 8
1 3 7
1 7 11
8 3 9
15 5 7
15 5 12
1 1 6
14 9 14
19 2 14
20 18 20
16 6 12
11 4 19
1 18 20
1 4 19
5 17 22
15 14 25
13 13 27
16 3 27
29 8 25
7 17 17
1 2 29
19 12 16
33 3 29
34 5 25
35 12 23
10 7 18
37 11 26
1 3 36
1 10 33
4 ...

output:

2014222606 2664606283
3924199323 2783856092
2014222606 2664606283
420165692 1651197540
2805156271 1531947731
2374484847 3663808109
1487342998 3226418812
3501565604 1596057799
3906541692 1299392633
2275527035 2830450971
2225548521 2480406277
505227187 4008143277
3302732253 845182635
2735351463 356966...

result:

ok 20000 numbers

Test #9:

score: 0
Accepted
time: 115ms
memory: 710200kb

input:

10000
64 256
1 1 1
1 1 1
3 1 1
4 1 4
1 1 4
6 2 5
1 2 7
8 2 6
1 3 9
1 8 10
11 8 11
1 1 9
1 4 7
1 1 12
1 5 9
1 2 6
1 7 13
1 12 16
19 8 11
1 3 7
21 4 10
22 1 12
1 4 10
24 7 21
25 4 5
1 14 22
1 3 3
28 18 18
29 5 24
1 3 19
1 6 24
1 6 30
33 5 32
34 7 27
35 7 26
36 7 28
1 7 36
38 22 26
39 7 39
40 20 36
1 8...

output:

2014222606 2664606283
3924199323 2783856092
3924199323 2783856092
4063879086 2473184589
1034856423 2709640037
4063879086 2473184589
2143396637 1842025402
2664347211 867020803
1058561700 3077307967
23705277 367667930
2291581107 2798177824
4268520009 1751836256
4253393404 1345520112
203708063 37066474...

result:

ok 20000 numbers

Test #10:

score: 0
Accepted
time: 119ms
memory: 709956kb

input:

10000
64 256
1 1 1
1 1 2
1 2 2
2 4 4
3 3 5
4 1 2
5 1 1
8 1 4
7 3 7
4 1 10
8 1 1
4 12 12
10 5 10
1 1 2
6 12 15
1 1 6
6 1 13
18 10 14
3 3 11
20 4 12
4 21 21
8 4 22
4 4 4
19 1 19
20 1 5
10 10 20
16 5 16
1 5 5
17 1 11
24 12 18
6 6 12
12 12 19
19 1 33
13 34 34
35 7 21
14 7 14
22 1 29
38 7 38
23 1 15
32 1...

output:

2014222606 2664606283
1643454633 1153495079
3924199323 2783856092
2014222606 2664606283
243922758 3842298589
2420424453 1319689510
790933665 3162308744
499942004 688530323
3732442830 2320524711
2596105510 2894201686
790933665 3162308744
3210132359 1235282565
1608781603 2108454087
4105892878 14885435...

result:

ok 20000 numbers

Test #11:

score: 0
Accepted
time: 124ms
memory: 709656kb

input:

10000
64 256
1 1 1
2 1 1
2 1 2
3 1 1
3 1 4
3 1 1
5 2 4
7 4 7
9 2 2
1 3 9
1 5 8
9 1 1
1 11 11
11 4 12
1 3 5
7 1 5
3 1 13
1 1 5
15 1 9
2 3 18
6 1 10
5 13 22
15 1 20
17 1 4
8 1 2
17 21 21
1 8 14
1 1 13
15 16 24
24 15 19
8 3 7
16 21 21
31 15 17
10 17 23
17 1 22
13 5 10
6 7 10
1 22 25
8 17 23
33 26 32
31...

output:

2014222606 2664606283
2014222606 2664606283
2805156271 1531947731
2014222606 2664606283
3035115184 2378132007
2014222606 2664606283
3165418512 2531149557
2132783731 4287847300
790933665 3162308744
2031998849 2619082143
2696668094 4027569334
2267875830 2430509894
3210132359 1235282565
3503610333 1893...

result:

ok 20000 numbers

Subtask #5:

score: 10
Accepted

Dependency #4:

100%
Accepted

Test #12:

score: 10
Accepted
time: 305ms
memory: 718372kb

input:

100000
64 256
1 1 1
1 1 1
3 2 3
1 1 1
5 2 3
1 3 6
7 1 7
8 4 4
1 1 8
2 4 4
11 5 10
6 1 1
5 5 11
14 7 12
3 9 9
9 14 14
13 5 5
10 4 12
19 7 9
20 4 12
10 2 21
2 13 22
18 9 18
8 18 21
10 3 23
1 7 17
27 24 27
6 16 25
1 9 20
1 8 28
15 3 15
1 2 25
26 2 15
13 4 29
1 3 33
4 16 24
37 7 29
1 21 27
1 7 29
12 3 3...

output:

2014222606 2664606283
3924199323 2783856092
2805156271 1531947731
1629490788 2452348062
1643454633 1153495079
1034856423 2709640037
836089096 4048405861
2014222606 2664606283
3872122593 2009853208
1629490788 2452348062
2937681241 1856335765
3036033497 2256414643
1525291877 47579360
3375078202 140401...

result:

ok 200000 numbers

Test #13:

score: 0
Accepted
time: 286ms
memory: 721348kb

input:

100000
64 256
1 1 1
2 2 2
3 2 2
1 1 4
1 2 5
1 1 3
7 4 4
8 3 4
1 3 7
10 6 9
1 2 11
12 10 10
13 1 7
14 4 11
15 6 10
1 12 13
17 3 9
18 15 18
19 2 10
20 1 16
21 10 14
1 19 19
1 5 17
24 8 15
1 7 13
26 2 18
1 11 26
1 2 26
29 7 20
30 20 23
1 8 30
32 11 12
1 8 8
34 1 5
1 3 27
1 9 27
37 11 27
1 8 29
1 11 29
...

output:

2014222606 2664606283
3924199323 2783856092
3924199323 2783856092
4063879086 2473184589
4063879086 2473184589
4003975635 1821188875
2014222606 2664606283
3643713394 821987049
2664347211 867020803
2322990510 797893268
2596105510 2894201686
3210132359 1235282565
2361405003 3366641195
81022587 39577497...

result:

ok 200000 numbers

Test #14:

score: 0
Accepted
time: 245ms
memory: 721636kb

input:

100000
64 256
1 1 1
1 1 1
1 2 3
1 1 4
5 3 4
1 1 6
4 1 5
6 3 8
9 1 3
10 8 8
4 2 8
9 4 9
13 2 2
14 1 11
12 3 6
1 6 12
6 6 13
10 1 14
15 11 11
1 1 1
8 1 8
8 8 17
4 1 9
14 9 24
15 15 15
26 1 5
27 1 27
5 11 22
23 1 5
1 6 30
24 6 31
25 12 12
13 6 33
27 13 34
1 14 14
21 28 36
22 7 14
22 22 38
7 1 1
24 24 3...

output:

2014222606 2664606283
3924199323 2783856092
1643454633 1153495079
4063879086 2473184589
1643454633 1153495079
2143396637 1842025402
221398365 2989963364
2937681241 1856335765
1899473879 2294694109
2895435421 2688803510
3939612438 4050390211
1585816973 3798622435
1629490788 2452348062
826825178 24486...

result:

ok 200000 numbers

Test #15:

score: 0
Accepted
time: 299ms
memory: 719024kb

input:

100000
64 256
1 1 1
1 1 1
1 1 2
2 1 1
4 3 5
3 1 2
5 3 6
7 5 6
1 1 5
7 1 7
1 2 8
6 1 10
13 2 4
1 4 12
7 11 14
7 4 10
2 11 13
8 6 12
3 1 2
4 4 11
15 1 11
9 9 15
8 3 21
19 8 21
3 10 24
15 9 19
1 17 24
6 7 19
6 6 7
13 4 15
16 7 21
30 14 18
25 1 29
2 19 27
16 29 30
18 28 33
21 17 31
23 3 34
9 1 31
3 4 18...

output:

2014222606 2664606283
3924199323 2783856092
420165692 1651197540
790933665 3162308744
243922758 3842298589
2420424453 1319689510
696409333 64110068
1588127880 600216673
269772107 3039997548
3066249716 600476624
3066249716 600476624
4001222659 2492744466
1161490654 3576104153
1907445691 3336069790
36...

result:

ok 200000 numbers

Subtask #6:

score: 20
Accepted

Test #16:

score: 20
Accepted
time: 5907ms
memory: 827804kb

input:

1000000
64 64
1 1 1
2 2 2
1 3 3
4 1 1
5 2 3
1 6 6
3 2 4
7 7 8
1 1 3
6 4 9
1 9 11
3 1 2
9 1 7
2 2 2
12 2 13
13 8 12
8 5 11
6 11 11
4 1 17
1 4 6
9 15 17
12 9 9
14 7 15
5 22 24
4 19 19
26 6 24
26 18 19
26 4 22
19 14 24
28 7 25
20 9 9
5 13 25
11 2 33
14 20 27
26 6 28
11 27 27
37 3 12
24 5 23
37 8 24
6 4...

output:

2014222606 2664606283
3924199323 2783856092
3924199323 2783856092
790933665 3162308744
1643454633 1153495079
2895435421 2688803510
1497848730 3738328190
1810600484 3924086075
3306016588 2098760690
689620797 2401604782
3440091272 2081466841
1008942031 391957241
2052469175 1878244468
3314959213 262120...

result:

ok 2000000 numbers

Subtask #7:

score: 20
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Dependency #5:

100%
Accepted

Dependency #6:

100%
Accepted

Test #17:

score: 20
Accepted
time: 3588ms
memory: 833932kb

input:

1000000
64 256
1 1 1
1 1 2
3 2 2
1 1 3
1 2 3
4 1 2
4 4 7
8 3 7
5 3 7
1 7 8
1 1 1
1 2 10
1 6 10
14 9 10
7 3 8
12 3 11
17 5 6
1 1 12
3 15 19
20 13 14
8 4 16
6 17 17
16 13 16
22 7 15
25 11 24
1 17 22
27 1 24
12 4 13
29 1 2
24 2 28
15 1 25
32 4 4
1 1 9
34 3 6
18 28 30
36 10 32
1 3 3
26 6 6
25 19 19
40 2...

output:

2014222606 2664606283
1643454633 1153495079
2014222606 2664606283
3272945421 3605843141
1258722815 941236858
229958913 846184276
976898156 418365493
606130183 3202221585
2851230015 2296327484
1493272032 3639610882
2267875830 2430509894
862915316 927120271
2466498197 2084069263
2515082923 3231419242
...

result:

ok 2000000 numbers

Test #18:

score: 0
Accepted
time: 3001ms
memory: 859120kb

input:

1000000
64 256
1 1 1
1 1 1
1 1 1
1 1 3
5 2 3
1 1 5
7 2 2
1 2 5
9 1 1
10 8 9
11 7 7
1 7 11
1 5 13
14 7 13
15 9 12
16 1 16
1 9 15
18 13 16
19 6 8
1 6 11
21 18 18
1 19 22
23 4 11
24 10 10
1 8 16
1 3 6
1 18 21
28 12 20
29 1 12
1 15 18
1 17 20
32 1 20
1 19 23
1 6 10
1 1 28
36 5 34
37 5 31
38 4 28
39 11 2...

output:

2014222606 2664606283
3924199323 2783856092
790933665 3162308744
2049656480 4103545602
420165692 1651197540
3542928512 3448189188
1629490788 2452348062
1528705906 783582905
3210132359 1235282565
1728725956 167827806
2895435421 2688803510
2152234541 875336216
2174799555 3114424416
4049342398 17947349...

result:

ok 2000000 numbers

Test #19:

score: 0
Accepted
time: 2139ms
memory: 862408kb

input:

1000000
64 256
1 1 1
1 1 1
1 1 1
4 1 4
3 1 5
2 1 6
1 1 4
8 4 8
3 1 7
4 4 10
11 2 6
9 1 12
13 10 13
14 8 14
1 9 12
3 9 12
17 1 10
7 10 14
7 7 7
4 16 16
1 12 21
17 1 22
13 1 9
9 14 24
5 1 10
1 1 10
21 10 27
16 5 5
5 23 29
12 18 18
24 6 24
6 6 25
6 1 26
6 13 34
35 1 21
7 14 14
7 14 29
38 30 30
39 1 31
...

output:

2014222606 2664606283
3924199323 2783856092
790933665 3162308744
4063879086 2473184589
2664347211 867020803
2143396637 1842025402
2886874873 537615302
788578609 3234961920
2242631805 3852472442
76445889 3859032432
2744066469 236715399
635643032 2097666018
248678392 181777651
1349521903 2240540504
26...

result:

ok 2000000 numbers

Test #20:

score: 0
Accepted
time: 3051ms
memory: 847220kb

input:

1000000
64 256
1 1 1
1 1 1
1 1 1
1 1 3
4 1 3
4 1 2
1 3 3
4 1 3
1 2 3
5 2 10
9 3 9
9 2 3
13 5 12
11 4 6
6 10 14
10 5 8
15 2 11
15 1 12
13 1 13
10 16 16
13 1 17
4 2 9
16 10 17
2 1 11
16 3 8
17 14 20
18 15 25
2 24 24
12 1 11
18 1 22
20 9 16
24 2 14
16 23 23
14 4 21
25 16 35
23 3 5
14 25 29
19 6 12
15 5...

output:

2014222606 2664606283
3924199323 2783856092
790933665 3162308744
2049656480 4103545602
2049656480 4103545602
2420424453 1319689510
790933665 3162308744
1113116912 3526069969
322183247 363761225
3855039309 637787043
2520564653 4098441277
322183247 363761225
781459919 610148702
3809883878 4046657222
1...

result:

ok 2000000 numbers

Test #21:

score: 0
Accepted
time: 4486ms
memory: 832388kb

input:

1000000
64 256
1 1 1
1 1 1
2 1 1
1 1 3
1 1 1
2 3 4
5 1 3
4 1 2
1 5 7
3 1 8
9 6 9
8 9 11
10 4 10
7 1 8
3 10 11
4 2 8
13 1 6
1 1 4
6 1 9
11 2 19
15 1 16
1 5 14
20 1 9
17 12 16
6 13 17
3 4 9
12 13 24
10 7 9
28 3 4
11 24 24
15 21 28
18 12 16
30 15 20
33 16 18
5 21 24
35 3 33
26 9 18
6 8 23
32 22 32
27 2...

output:

2014222606 2664606283
3924199323 2783856092
3924199323 2783856092
2049656480 4103545602
2895435421 2688803510
1258722815 941236858
4003975635 1821188875
2374484847 3663808109
1532056845 1930551820
4085916535 1362253955
3799932675 66094418
1751501954 3504231801
143372758 489463345
118248697 177707562...

result:

ok 2000000 numbers

Test #22:

score: 0
Accepted
time: 5820ms
memory: 831684kb

input:

1000000
64 256
1 1 1
1 1 1
1 1 2
1 1 3
1 1 1
5 1 1
1 2 5
4 1 2
2 1 3
6 2 8
4 3 7
1 5 11
6 8 9
12 11 12
1 6 7
6 9 12
10 9 10
8 1 3
12 9 12
4 1 2
11 3 20
4 1 21
17 2 20
1 10 11
11 16 23
2 1 12
15 12 20
18 1 16
17 5 16
4 23 28
12 1 4
21 14 28
23 11 24
1 10 30
7 33 34
33 24 34
6 28 28
32 25 28
34 7 20
5...

output:

2014222606 2664606283
3924199323 2783856092
420165692 1651197540
2049656480 4103545602
2895435421 2688803510
2895435421 2688803510
650124605 2497381816
1588127880 600216673
329194081 2856631316
2410141019 1343177641
1221817660 4161042648
2520564653 4098441277
3018950213 884348478
2944191240 11100909...

result:

ok 2000000 numbers