QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#749468#7468. 成都七中TheZoneAC ✓308ms78328kbC++205.3kb2024-11-15 01:11:212024-11-15 01:11:23

Judging History

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

  • [2024-11-15 01:11:23]
  • 评测
  • 测评结果:AC
  • 用时:308ms
  • 内存:78328kb
  • [2024-11-15 01:11:21]
  • 提交

answer

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <vector>
#include <algorithm>
#define MAXN 100005
using namespace std;
const int INF=0x7fffffff;
inline int read()
{
	int ans=0;
	char c=getchar();
	while (!isdigit(c)) c=getchar();
	while (isdigit(c)) ans=(ans<<3)+(ans<<1)+(c^48),c=getchar();
	return ans;
}
int col[MAXN];
struct node{int l,r,val;};
//ancestor: val=the index of the ancestor
//son: val=the color of the son
//query: val=the index of the query  
vector<int> e[MAXN];
vector<node> p[MAXN],s[MAXN],q[MAXN];
int rt,siz[MAXN],maxp[MAXN],vis[MAXN];
void findrt(int u,int f,int sum)
{
	siz[u]=1,maxp[u]=0;
	for (int i=0;i<(int)e[u].size();i++)
		if (!vis[e[u][i]]&&e[u][i]!=f)
		{
			findrt(e[u][i],u,sum);
			siz[u]+=siz[e[u][i]];
			maxp[u]=max(maxp[u],siz[e[u][i]]);
		}
	maxp[u]=max(maxp[u],sum-siz[u]);
	if (maxp[u]<maxp[rt]) rt=u;
}
void dfs(int u,int f,int l,int r)
{
	p[u].push_back((node){l,r,rt});
	s[rt].push_back((node){l,r,col[u]});
	siz[u]=1;
	for (int i=0;i<(int)e[u].size();i++)
		if (!vis[e[u][i]]&&e[u][i]!=f)
		{
			dfs(e[u][i],u,min(l,e[u][i]),max(r,e[u][i]));
			siz[u]+=siz[e[u][i]];
		}
}
void build()
{
	vis[rt]=1;
	dfs(rt,0,rt,rt);
	int u=rt;
	for (int i=0;i<(int)e[u].size();i++)
		if (!vis[e[u][i]])
		{
			rt=0,findrt(e[u][i],0,siz[e[u][i]]);
			build();
		}
}
const int N=1e5;
struct BIT
{
	int s[MAXN];
	inline int lowbit(const int& x){return x&-x;}
	inline void modify(int x,int v){for (;x<=N;s[x]+=v,x+=lowbit(x));}
	inline int query(int x,int ans=0){for (;x;ans+=s[x],x-=lowbit(x));return ans;}
}bit;
int mx[MAXN];
vector<node> tf[MAXN],tq[MAXN];
vector<int> lis;
int ans[MAXN];
int main()
{
	maxp[0]=INF;
	int n,m;
	n=read(),m=read();
	for (int i=1;i<=n;i++) col[i]=read();
	for (int i=1;i<n;i++) 
	{
		int u,v;
		u=read(),v=read();
		e[u].push_back(v),e[v].push_back(u);
	}
	findrt(1,0,n),build();
	for (int T=1;T<=m;T++)
	{
		int l,r,x;
		l=read(),r=read(),x=read();
		for (int i=0;i<(int)p[x].size();i++)
			if (l<=p[x][i].l&&p[x][i].r<=r)
			{
				q[p[x][i].val].push_back((node){l,r,T});
				break;
			}
	}
	for (int u=1;u<=n;u++)
	{
		lis.clear();
		for (int i=0;i<(int)s[u].size();i++)
			tf[s[u][i].r].push_back(s[u][i]),lis.push_back(s[u][i].r);
		for (int i=0;i<(int)q[u].size();i++)
			tq[q[u][i].r].push_back(q[u][i]),lis.push_back(q[u][i].r);
		sort(lis.begin(),lis.end());
		lis.erase(unique(lis.begin(),lis.end()),lis.end());
		for (int t=0;t<(int)lis.size();t++)
		{
			int r=lis[t];
			for (int i=0;i<(int)tf[r].size();i++)
				if (tf[r][i].l>mx[tf[r][i].val])
				{
					if (mx[tf[r][i].val]) bit.modify(mx[tf[r][i].val],-1);
					bit.modify(mx[tf[r][i].val]=tf[r][i].l,1);
				}
			for (int i=0;i<(int)tq[r].size();i++)
				ans[tq[r][i].val]=bit.query(r)-bit.query(tq[r][i].l-1);
		}
		for (int i=0;i<(int)s[u].size();i++)
		{
			if (mx[s[u][i].val]) bit.modify(mx[s[u][i].val],-1);
			mx[s[u][i].val]=0;
		}
		for (int i=0;i<(int)lis.size();i++) tf[lis[i]].clear(),tq[lis[i]].clear();
	}
	for (int i=1;i<=m;i++) printf("%d\n",ans[i]);
	return 0;
}
/*#include <iostream>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <vector>
#include <algorithm>
#define MAXN 100005
using namespace std;
const int INF=0x7fffffff;
inline int read()
{
	int ans=0;
	char c=getchar();
	while (!isdigit(c)) c=getchar();
	while (isdigit(c)) ans=(ans<<3)+(ans<<1)+(c^48),c=getchar();
	return ans;
}
int col[MAXN];
struct node{int l,r,val;};
//ancestor: val=the index of the ancestor
//son: val=the color of the son
//query: val=the index of the query  
vector<int> e[MAXN];
vector<node> p[MAXN],s[MAXN],q[MAXN];
int rt,siz[MAXN],maxp[MAXN],vis[MAXN];
void findrt(int u,int f,int sum)
{
	siz[u]=1,maxp[u]=0;
	for (int i=0;i<(int)e[u].size();i++)
		if (!vis[e[u][i]]&&e[u][i]!=f)
		{
			findrt(e[u][i],u,sum);
			siz[u]+=siz[e[u][i]];
			maxp[u]=max(maxp[u],siz[e[u][i]]);
		}
	maxp[u]=max(maxp[u],sum-siz[u]);
	if (maxp[u]<maxp[rt]) rt=u;
}
void dfs(int u,int f,int l,int r)
{
	p[u].push_back((node){l,r,rt});
	s[rt].push_back((node){l,r,col[u]});
	siz[u]=1;
	for (int i=0;i<(int)e[u].size();i++)
		if (!vis[e[u][i]]&&e[u][i]!=f)
		{
			dfs(e[u][i],u,min(l,e[u][i]),max(r,e[u][i]));
			siz[u]+=siz[e[u][i]];
		}
}
void build()
{
	vis[rt]=1;
	dfs(rt,0,rt,rt);
	int u=rt;
	for (int i=0;i<(int)e[u].size();i++)
		if (!vis[e[u][i]])
		{
			rt=0,findrt(e[u][i],0,siz[e[u][i]]);
			build();
		}
}
const int N=1e5;
struct BIT
{
	int s[MAXN];
	inline int lowbit(const int& x){return x&-x;}
	inline void modify(int x,int v){for (;x<=N;s[x]+=v,x+=lowbit(x));}
	inline int query(int x,int ans=0){for (;x;ans+=s[x],x-=lowbit(x));return ans;}
}bit;
int mx[MAXN];
vector<node> tf[MAXN],tq[MAXN];
vector<int> lis;
int ans[MAXN];
int main()
{
	maxp[0]=INF;
	int n,m;
	n=read(),m=read();
	for (int i=1;i<=n;i++) col[i]=read();
	for (int i=1;i<n;i++) 
	{
		int u,v;
		u=read(),v=read();
		e[u].push_back(v),e[v].push_back(u);
	}
	findrt(1,0,n),build();
	for (int T=1;T<=m;T++)
	{
		int l,r,x;
		l=read(),r=read(),x=read();
		for (int i=0;i<(int)p[x].size();i++)
			if (l<=p[x][i].l&&p[x][i].r<=r)
			{
				q[p[x][i].val].push_back((node){l,r,T});
				break;
			}
	}
	for (int u=1;u<=n;u++)
	{
	return 0;
}*/

详细

Test #1:

score: 100
Accepted
time: 229ms
memory: 68492kb

input:

100000 100000
12426 52829 57792 9847 23636 13858 65285 88100 46567 18584 84208 79165 91989 89923 24835 78503 41221 64985 58791 73101 78425 1929 65994 70117 98573 85025 25924 94865 71544 15145 79122 39161 79829 8416 47246 95396 10967 78576 34041 86822 58995 25791 2701 94289 24665 134 42922 65600 5793...

output:

16099
13262
1
71027
70591
908
71009
1677
71007
71017
28476
71017
26152
70999
13125
71010
57706
3125
71001
10850
2973
3687
44392
47118
908
138
981
71014
17861
71050
71030
3726
70999
13643
283
41255
71012
5850
2649
3
42994
47117
71008
2852
2973
71019
71032
42997
1
71031
647
64
70586
71004
48910
1082
1...

result:

ok 100000 numbers

Test #2:

score: 0
Accepted
time: 246ms
memory: 65588kb

input:

100000 100000
88894 51163 86640 45619 86533 51275 85634 69402 94266 94427 34558 47215 60851 82825 29802 5224 2834 72043 28235 32537 99020 97519 36848 1125 73675 26563 34805 47529 98835 96037 66632 28214 40503 33522 64698 30750 2743 59135 42893 93687 55877 21442 13637 57936 95259 16088 43189 8617 831...

output:

1
4988
29143
54754
6956
3237
70950
64268
4072
1
20381
1937
2
727
3
3848
5942
70955
13095
29350
53989
29139
9182
62240
70960
70957
1
16413
29145
7937
29147
70948
140
21527
9183
6175
1693
43738
70949
8222
70946
70953
54758
5122
48999
1
70946
70948
20020
65931
70954
65932
29936
1
2436
2958
5341
20381
2...

result:

ok 100000 numbers

Test #3:

score: 0
Accepted
time: 219ms
memory: 65460kb

input:

100000 100000
83003 47527 88456 99252 27901 70139 87228 21814 75813 39673 7732 40880 46993 35835 9877 31436 56931 56644 26352 56871 17073 89080 82876 85683 59257 67949 78390 28798 98080 93746 94379 2263 4618 21377 98895 72389 64631 95833 99095 56012 55300 50844 25475 20748 4033 26021 89375 96386 582...

output:

4
2432
1
505
70863
70828
848
70832
2
1
18980
1775
1
867
1976
70849
13428
25960
70862
16650
11517
52054
4
313
70837
1667
70823
2155
18980
1
29018
51993
724
5
3495
273
2185
34468
34257
3
4
222
70833
1377
45379
4993
51965
3
313
29017
70867
16391
70829
1438
36766
106
10
70826
1936
38490
1
52046
70846
1
...

result:

ok 100000 numbers

Test #4:

score: 0
Accepted
time: 212ms
memory: 69548kb

input:

100000 100000
3012 70420 85243 5196 58891 6982 11792 77342 10609 47995 60226 50033 20873 18722 22077 8378 78227 52596 26629 36612 519 65913 38176 55418 1737 66033 25697 74073 84706 68358 6170 70911 38426 21309 75068 24130 42881 60664 60206 78411 37579 75743 19164 78742 89534 80970 30924 19231 74852 ...

output:

63326
14856
14859
2790
760
63307
27696
943
388
7160
63315
56399
297
4277
47928
1
737
27689
27691
60806
16356
6595
2679
63326
136
12363
1586
50692
2
15921
6257
2392
2
63317
713
63322
62070
24181
2653
27684
14817
63339
63310
31853
47930
27723
547
47
196
30549
982
1
33
2
2679
901
28005
1
47944
4540
2
6...

result:

ok 100000 numbers

Test #5:

score: 0
Accepted
time: 241ms
memory: 69600kb

input:

100000 100000
49893 74967 40184 60804 86772 3476 44066 74220 63499 12931 20668 39173 90417 52532 40707 75938 95669 44708 7557 88543 41362 48932 32529 91756 30135 97591 73721 95636 31744 70396 81448 67327 33171 91530 76465 99994 6437 30504 10882 95295 60418 6413 31838 98471 52103 6165 9078 97091 3962...

output:

57164
45155
28167
17358
57142
9
6517
122
1958
5582
45158
20754
57161
4181
57160
45159
28175
4739
26544
3042
45159
803
28166
45161
5
2876
57154
28167
4
32157
11423
57153
3433
57174
2313
2
418
29212
2569
57166
28170
2876
14
1090
470
5582
140
4453
26549
5909
57150
8616
44265
18549
1
629
45159
57162
395...

result:

ok 100000 numbers

Test #6:

score: 0
Accepted
time: 239ms
memory: 68464kb

input:

100000 100000
78261 19840 55380 23314 26265 40856 52613 95285 68294 11947 6003 65230 48353 28564 33199 47369 54152 3724 35967 54363 1758 36591 87001 52899 62514 1882 90501 84891 90041 3198 94631 25439 39196 22258 89146 38233 36429 22952 25049 35246 71500 89899 78351 69288 71111 3248 29611 80403 8872...

output:

19906
61698
10724
17718
155
8181
70884
70891
70889
70886
70888
70889
2706
70890
1
7212
1161
41232
70888
1
41228
2
35652
41224
536
311
49163
8682
41224
45172
70887
39792
8
70888
2705
14349
46176
70889
41224
45174
19
61699
46176
3584
1
456
66304
5088
2720
24923
1467
49164
4733
46177
966
1
45172
70892
...

result:

ok 100000 numbers

Test #7:

score: 0
Accepted
time: 241ms
memory: 69472kb

input:

100000 100000
8120 91830 58852 45673 17136 44639 34505 83822 89282 16326 4759 22220 64390 34515 4922 1175 43154 42727 60159 45978 17345 59385 54088 83928 87033 84642 97682 83860 50139 6066 48063 45238 42594 39034 75304 40790 92867 8857 95886 40716 54416 76042 26776 504 29005 45515 66876 1416 73142 3...

output:

5935
44325
63405
63404
63405
36134
20907
63404
40718
31748
63405
17054
2
15647
17054
1426
63405
63404
63404
1
34835
104
63405
18326
38649
5
63404
63404
60630
2
2
46520
61643
63404
5251
681
63404
38644
288
50002
1
63404
14455
25617
17054
2
38653
60629
52402
63404
63404
1
12245
52401
1
63404
61643
156...

result:

ok 100000 numbers

Test #8:

score: 0
Accepted
time: 143ms
memory: 47872kb

input:

100000 100000
14160 64022 14249 98982 99082 67271 13297 46349 99872 93974 47372 28329 54057 24820 57343 92495 11399 12323 57789 86321 55293 23125 29515 67055 25731 46591 56668 18602 91769 57301 75841 9212 16390 75377 53894 74009 38768 50553 22431 14834 13557 48274 43064 62098 35269 7879 82708 65231 ...

output:

4162
2755
11
1
1
294
50053
1
1
1
1
1
1
2
3105
1
32518
1
2
1
1
1
2
1
25578
1
1
1
2
1
1
2375
44174
34033
1
1
1
1
1
1
1
1
19986
1
3838
1
4305
1
1137
19992
1
1
2
1939
1
6207
1
1
1
2
1
1
4401
1
1
2687
2
14247
1
1
1
1
1
5
1
656
1
1
1
1
1
20746
1
1
1
76
1
1
1
10
4374
1
1
1
1872
1
1
1461
1
11173
1
1361
1
45...

result:

ok 100000 numbers

Test #9:

score: 0
Accepted
time: 142ms
memory: 47592kb

input:

100000 100000
86870 39092 76528 13129 27201 6720 85690 10007 87376 67508 54935 2310 83042 42469 54351 17301 40390 63384 37262 85456 65229 56985 79488 7371 37814 73196 83004 62263 90735 21033 54622 34049 97236 4279 24797 64472 47489 84247 5717 31406 58775 46341 18410 74820 88444 58889 95691 92647 839...

output:

1
1
3
2
1
1
2
5765
1
1
12677
4033
1
1
1
2
1
1
1
1
1
1
3947
21198
1
21006
2
1352
1
1
1
1
1
6198
1
1
7468
5225
1
1
1
1
1
9
1
1
1
15451
1
1
1
1
2643
1
1
21896
1
1
1
1
7441
3540
1
3
6
1
1
3849
1
351
32648
6238
12590
4717
1
12987
1
1
32647
1
1
35529
1
1
1
3942
1
1
2
1
1
1
1
1
4136
1
3095
15604
1
1
20708
...

result:

ok 100000 numbers

Test #10:

score: 0
Accepted
time: 150ms
memory: 47188kb

input:

100000 100000
74981 46480 65956 85248 683 35366 22476 95147 46760 66475 15135 83179 52423 14987 94360 21972 76255 44883 33630 4506 23583 12683 98154 49402 95611 18126 10509 608 59845 28601 37070 98051 28066 64205 70845 78064 14894 55649 73994 77591 2107 89767 37593 879 54845 7195 84457 58221 12357 4...

output:

1
1
3301
2
1
1
1
1
4202
1
1
1
1
2074
17
1
1
1
3961
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
32869
6706
1
1
1
1
1
1
2510
1
1519
1
1
3407
1
1
1
1
11024
3180
29915
2316
1
38883
1
1
1
9
10
1
11783
1843
1
1075
21938
28054
1
1
1
1
1
1
2271
1
6306
1
1
1
7025
1
1
1103
1
1
1695
1
1
1564
1
1
1
1
1
1
1
1
40363
1
1
1
...

result:

ok 100000 numbers

Test #11:

score: 0
Accepted
time: 211ms
memory: 77912kb

input:

100000 100000
38768 41058 26901 52767 7853 41260 74683 95681 87392 79612 17130 7687 78640 56267 92622 30501 46012 71381 86436 65483 43889 6785 50223 18785 93176 75088 20084 22400 473 41381 38118 21417 55456 31978 14099 76586 2131 23306 63743 89092 75657 10368 76803 6903 62662 78974 63187 18380 11891...

output:

3
33263
47908
3931
47908
7551
33256
47914
20102
3
32294
3946
7506
2761
47907
508
7519
33264
1007
33971
3922
4661
3935
15
3907
47915
3907
8166
13887
1003
3
3893
1011
47909
1780
47911
28898
32419
47910
20190
6744
47918
47913
34086
13871
509
34089
4661
32422
47909
32420
3914
2727
3932
47922
3921
47913
...

result:

ok 100000 numbers

Test #12:

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

input:

100000 100000
22482 33042 79160 79266 62495 21503 63816 10085 78467 94783 30053 5197 13305 38846 81772 58972 94511 66395 41101 31865 70779 23534 64485 30931 71038 13446 92732 49711 80954 26034 32016 10905 52273 86505 92839 38358 17229 9223 24081 21420 57348 42716 80667 13765 36677 13580 80360 1727 1...

output:

22495
25929
4036
7241
472
25081
1303
8769
4036
1
601
32308
6677
32306
3164
1
823
32307
8772
2577
32307
24358
32307
24358
32307
20145
32308
6347
32307
32308
32306
5178
2344
1558
10914
24405
2
426
645
24354
2508
22909
24405
1137
22221
3534
32308
1740
6347
24144
1480
2591
18862
548
808
26559
24557
1137...

result:

ok 100000 numbers

Test #13:

score: 0
Accepted
time: 194ms
memory: 70084kb

input:

100000 100000
76785 46615 47084 19713 48083 31625 48665 42032 87632 8514 86491 99715 48289 2465 42134 95122 3490 24466 69628 19545 93741 65595 47595 42279 77205 70631 4394 11195 16433 32846 77297 43254 43324 13838 89710 36165 50075 52347 23365 48590 38475 44756 90751 30212 58726 71112 68984 85153 80...

output:

3
42686
42686
2
26636
12017
4150
12009
42687
9334
2258
31684
4982
26371
32536
1306
42686
29261
29261
42684
42685
42686
42684
1
13480
31684
22048
14703
2321
31683
31683
333
15853
29260
4364
12017
12009
2002
42683
3624
4786
42684
42684
2426
29261
15313
1170
42683
41133
41133
42684
214
29188
1081
11608...

result:

ok 100000 numbers

Test #14:

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

input:

100000 100000
11030 10378 89585 38490 88360 65387 25380 4694 68286 40347 37409 30996 13762 11962 19183 61447 12497 9885 6641 14147 57708 42056 22597 55164 52122 59882 90823 54951 99733 65244 49225 5849 1748 63526 92803 52652 15400 76237 36047 87930 62325 82334 89610 87902 85488 30787 30967 18498 151...

output:

2115
20107
1
1243
1
3856
99
1
3356
9635
1
8042
16427
15466
20107
20107
2130
16426
1
8633
16426
12465
1
7869
10259
3
9284
13400
10
1
7870
1
11923
5167
16426
1
7709
1
16997
532
14020
16400
20107
15176
4009
3563
1
3924
14380
16427
13527
2513
20107
16172
1
13
6092
1
6
2
9649
16427
16426
1
20107
16426
1
...

result:

ok 100000 numbers

Test #15:

score: 0
Accepted
time: 270ms
memory: 73332kb

input:

100000 100000
25144 62580 79993 37290 80012 77382 35378 72847 751 10770 98935 91403 10935 14542 76259 65367 29514 75666 59419 91151 99388 87715 37138 76572 7409 28564 6302 96433 89111 97766 64242 21115 32154 23294 86020 325 92217 21399 64950 42973 3145 21571 62525 74957 8197 69207 29380 29968 47097 ...

output:

1
1
1
1
114
1
2
1
2
1
25
1
3
18
829
1
1
6
2
87
1
2
1
1
3277
3
1
3
1
1
4271
1
1
1
30
10
245
2
4
2
1
1
1
14
2
1
1
116
8
1
6
1
1
2
1
8
3
1
2
1
1
1
1
1
3
3
1
56
63
5
39
3
1
3
1
25
2
12
3
1
2
2
1
1
2
1
1
1
60
1
3
11
1
11
1
8
107
129
6
1
4
3
1
3
1
430
2
33
19
1
1
16
3
2
1
1
1
1
2
11
1
4
5
3
3
71
1
1
1
3
1...

result:

ok 100000 numbers

Test #16:

score: 0
Accepted
time: 287ms
memory: 74620kb

input:

100000 100000
14987 78491 75939 16358 83960 88105 73784 50629 40770 6104 51226 95810 40862 2793 48348 86037 63387 53226 8111 89264 92946 34684 96230 55133 44705 42246 63821 90950 30352 33052 75434 45936 87311 64797 44598 40647 73748 50425 43548 48574 75692 76804 86941 21930 71777 2668 71096 47577 63...

output:

1
1
1
4
53296
62479
62968
2
874
2
62823
5
62791
62742
1
1
53528
1
1
4
954
2
53627
1
6
1
1
1
1804
3
17
5
62725
1
2
2
1
1
7
1
8
3
1
71
14
2
9
1
3
2
63051
1
7
62816
52890
13
15831
1
21
53206
33
4
1
61671
63072
62551
61346
52780
2
650
1
1
62665
1
12
14
52771
62672
5
17
1
1
62781
3
62459
25
2
2
1
1
8
1
1...

result:

ok 100000 numbers

Test #17:

score: 0
Accepted
time: 274ms
memory: 73020kb

input:

100000 100000
85009 98434 38158 62734 63712 39423 18410 19858 96312 88946 53892 80128 38145 14113 88935 26919 45782 58859 37870 45711 17690 96271 73677 2994 47328 81281 66751 73445 17498 15461 68687 69294 15299 78980 81481 7180 48543 11684 41562 19880 62777 40747 12179 10150 13564 85064 47334 90810 ...

output:

4
9
1
26644
29749
3
29096
21
1
1
32481
32484
24678
21
26701
13
1
31866
5
37
12
41
1
5
1
1
24
8
7
3
18
25876
2
1
1
1438
28144
1
1
1
1
1
3
3
33500
2
26876
7
1
6
1
11
1
12
1
26712
2
1
1
82
15
252
1
1093
28393
6546
1
36
4
54
3
28833
31751
2
2
1
41949
24620
5551
2
6
2
6405
2
5
1
1
23813
3
3
6
4
1
7
1
3
1...

result:

ok 100000 numbers

Test #18:

score: 0
Accepted
time: 265ms
memory: 73544kb

input:

100000 100000
68522 23766 85055 60743 20389 26762 78323 22403 53523 74376 53840 78455 13127 77661 19454 27181 29302 84267 71094 77044 52893 55754 15233 90235 80198 50117 17314 72423 96055 55346 72944 2507 51604 51715 34475 90026 89410 45957 89847 33531 87702 61622 53349 11436 75993 72408 47010 69845...

output:

26243
1
1
3
2664
1
823
1
7
1
2
2
19939
7
19703
88
8456
1
1
28394
1
890
1
2
6
2571
34
6
1269
23856
9
2779
1
2
47
24179
1
1
2
22677
1
38
3
1
13
1
1
8604
1
26
8369
2
5959
1
3
1
30231
3
1
5
74
1
3
23170
27393
2
5283
5
681
1
2
1
24530
4
24880
26401
382
9
1
24192
2
9
2
3
23922
24185
832
1
1
1
119
2
1
9
50...

result:

ok 100000 numbers

Test #19:

score: 0
Accepted
time: 221ms
memory: 64268kb

input:

100000 100000
32874 81216 51785 53927 67753 34535 61605 84368 51919 92706 78870 74636 6592 72651 58446 18917 4166 49326 34442 50502 44138 31320 77130 62407 25857 97956 39376 95710 65304 27835 81706 41731 37859 563 5228 47111 97922 60741 52128 22756 46488 31374 41859 99902 40890 29808 16467 71514 349...

output:

360
516
24705
2064
1117
9884
3897
9
35
395
86
20890
1888
2
20
544
14168
39
7
29811
3697
25
12250
53
1
4737
40594
16
4200
3310
544
15
454
2
146
45
22931
35
20778
60
2
3
29337
1293
645
87
2
27644
1
1
55
16
108
3
2341
1401
4
25
2
18
779
30960
16
132
408
20253
26722
26466
29
2036
33398
4
2
31
10
24
3
1
...

result:

ok 100000 numbers

Test #20:

score: 0
Accepted
time: 199ms
memory: 65484kb

input:

100000 100000
89983 6505 30469 35358 27276 37630 83821 98033 92389 96403 25379 87340 27106 89320 72770 28132 10980 13575 95018 25634 14817 55331 39836 45926 21684 7196 71228 62506 68710 52103 85607 96091 27094 58053 18021 41063 2715 38163 78770 71212 3819 23178 72439 2670 61481 97667 27225 15169 866...

output:

22899
2795
1080
15581
24364
1227
615
40
1
34460
57494
9229
35550
10591
16180
1
13212
14452
2
29174
35457
6306
900
7554
5888
1453
5849
23229
22680
4116
5359
309
13567
28820
2529
4
26939
4688
18
4672
34892
1955
3553
333
33010
28242
22695
7367
3743
11860
3437
1581
30740
1378
18798
20489
16
1614
8227
82...

result:

ok 100000 numbers

Test #21:

score: 0
Accepted
time: 308ms
memory: 76140kb

input:

100000 100000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 9...

output:

2
1
2
10
1
2
13936
1
1
1
1
1
12
1
1
1
4
46615
16222
1
1
39781
11379
1
26054
1
2
2
1
1
6
2
1
13
13698
1
3
3
1
7
45344
1
17
32209
3
78896
1
12409
9282
1
1
1
6
1
2
1
1
4
1
971
1
1
1
329
2
1
1
2
1
25237
1
1
22275
1
1
11899
1
1
37225
2
1
13273
2
2
1
2
2
36599
4
3
1
9711
11019
1
6
1
1
1
3
1
8
5
1
4
2
3
15...

result:

ok 100000 numbers

Test #22:

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

input:

100000 100000
24912 6198 16941 37970 15234 39411 9160 14331 22513 5707 8384 33514 38863 24054 2360 9543 38536 31372 1830 36435 19885 1365 14154 4134 24194 18402 11367 2922 39916 31422 32859 28770 23537 20104 23696 19075 4818 36452 19426 157 11944 4644 26494 14885 39412 159 23142 35393 12636 1812 188...

output:

13987
13444
3
13401
13987
1
7416
3
15
13446
13378
7064
15
13431
507
13401
7394
7373
1011
7
13438
1
13955
13987
13438
15
1562
7373
3
13436
15
24543
6794
1
10873
3866
1482
15992
13401
1
19505
13401
3881
13955
7373
13987
3
22359
28528
13378
7421
4286
13401
1
8063
13378
13444
1991
13378
7416
1080
13615
...

result:

ok 100000 numbers

Test #23:

score: 0
Accepted
time: 181ms
memory: 68604kb

input:

100000 100000
1290 36420 30921 20525 12799 21666 38459 26986 9879 24045 19108 39074 10858 35738 2706 10714 21335 22687 8142 9462 8906 357 29031 33599 12772 11092 38290 4242 11011 34301 22801 30879 16911 12992 3242 10570 39601 24226 6964 13113 18784 28681 15536 38664 37971 15807 38295 29036 987 27214...

output:

13465
7422
7424
31441
22385
22333
16395
21026
13428
22396
7389
13465
13473
15127
506
28562
22396
6625
7389
13465
24953
13428
506
31781
28706
22396
22385
7382
7382
7389
29453
15900
35823
31674
13473
14990
34471
31905
508
13415
14369
34037
25527
8265
33539
11769
13244
7422
22333
13428
22385
13428
2238...

result:

ok 100000 numbers