QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#554784#8560. Just Shuffle the InputPhantomThreshold#AC ✓402ms66000kbC++204.4kb2024-09-09 15:45:502024-09-09 15:45:50

Judging History

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

  • [2024-09-09 15:45:50]
  • 评测
  • 测评结果:AC
  • 用时:402ms
  • 内存:66000kb
  • [2024-09-09 15:45:50]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

namespace NTT{
	const int MOD=998244353,g=3,ig=332748118;
	const int MAXN=1077777;
	inline long long poww(long long x,long long y){
		long long ret=1;
		while (y){
			if (y&1) ret=ret*x,ret%=MOD;
			x*=x,x%=MOD;
			y>>=1;
		}
		return ret;
	}
	inline long long inv(long long x){return poww(x,MOD-2);}
	int R[MAXN];
	inline void fft(vector<long long> &a,int L,int ty){
		for (int i=0;i<L;i++) i>R[i]?swap(a[i],a[R[i]]):void(0);
		for (int i=1;i<L;i<<=1){
			long long w=poww(ty,(MOD-1)/(i<<1));
			for (int j=0;j<L;j+=(i<<1)){
				long long wn=1;
				for (int k=j;k<i+j;k++){
					long long t=wn*a[i+k]%MOD;
					a[i+k]=a[k]-t;a[i+k]<0?a[i+k]+=MOD:0;
					a[k]+=t;a[k]>=MOD?a[k]-=MOD:0;
					wn=wn*w%MOD;
				}
			}
		}
	}
	inline vector<long long> mul(vector<long long> A,vector<long long> B){
		int L=1,n=(int)A.size()-1,m=(int)B.size()-1;
		while (L<=n+m) L<<=1;
		A.resize(L);
		B.resize(L);
		for (int i=1;i<L;i<<=1)
			for (int j=0;j<i;j++)
				R[i+j]=R[j]+L/(i<<1);
		fft(A,L,g);
		fft(B,L,g);
		vector<long long> ret(L);
		for (int i=0;i<L;i++)
			ret[i]=A[i]*B[i]%MOD;
		fft(ret,L,ig);
		long long invL=inv(L);
		for (int i=0;i<L;i++) ret[i]=ret[i]*invL%MOD;
		ret.resize(n+m+1);
		return ret;
	}
}
namespace NTT2{
	const int MOD=1004535809,g=3;
	const int MAXN=1077777;
	inline long long poww(long long x,long long y){
		long long ret=1;
		while (y){
			if (y&1) ret=ret*x,ret%=MOD;
			x*=x,x%=MOD;
			y>>=1;
		}
		return ret;
	}
	inline long long inv(long long x){return poww(x,MOD-2);}

	const int ig=inv(g);

	int R[MAXN];
	inline void fft(vector<long long> &a,int L,int ty){
		for (int i=0;i<L;i++) i>R[i]?swap(a[i],a[R[i]]):void(0);
		for (int i=1;i<L;i<<=1){
			long long w=poww(ty,(MOD-1)/(i<<1));
			for (int j=0;j<L;j+=(i<<1)){
				long long wn=1;
				for (int k=j;k<i+j;k++){
					long long t=wn*a[i+k]%MOD;
					a[i+k]=a[k]-t;a[i+k]<0?a[i+k]+=MOD:0;
					a[k]+=t;a[k]>=MOD?a[k]-=MOD:0;
					wn=wn*w%MOD;
				}
			}
		}
	}
	inline vector<long long> mul(vector<long long> A,vector<long long> B){
		int L=1,n=(int)A.size()-1,m=(int)B.size()-1;
		while (L<=n+m) L<<=1;
		A.resize(L);
		B.resize(L);
		for (int i=1;i<L;i<<=1)
			for (int j=0;j<i;j++)
				R[i+j]=R[j]+L/(i<<1);
		fft(A,L,g);
		fft(B,L,g);
		vector<long long> ret(L);
		for (int i=0;i<L;i++)
			ret[i]=A[i]*B[i]%MOD;
		fft(ret,L,ig);
		long long invL=inv(L);
		for (int i=0;i<L;i++) ret[i]=ret[i]*invL%MOD;
		ret.resize(n+m+1);
		return ret;
	}
}

typedef long long ll;

inline long long poww(long long x,long long y,long long mod){
	long long ret=1;
	while (y){
		if (y&1) ret=ret*x,ret%=mod;
		x*=x,x%=mod;
		y>>=1;
	}
	return ret;
}
inline long long inv(long long x,long long mod){return poww(x,mod-2,mod);}

const int maxn=200000;
const ll mod=998244353;
const ll mod2=1004535809;
const ll base=114;
const ll base2=514;

ll pw[maxn+50];
ll pw2[maxn+50];
void prepare(){
	pw[0]=1;
	for (int i=1;i<=maxn;i++) pw[i]=pw[i-1]*base%mod;
	pw2[0]=1;
	for (int i=1;i<=maxn;i++) pw2[i]=pw2[i-1]*base2%mod2;
}

ll n,m;
ll p[maxn+50];

string s,t;
ll ht[maxn+50];
ll ht2[maxn+50];

int main(){
    ios_base::sync_with_stdio(false);
	prepare();

    cin >> n >> m;
	for (int i=0;i<m;i++){
		cin >> p[i];
		p[i]--;
	}
	cin >> s;
	for (int i=0;i<n;i++){
		ht[i]=(s[i]-'a'+1)*pw[i]%mod;
		if (i>0) ht[i]=(ht[i]+ht[i-1])%mod;

		ht2[i]=(s[i]-'a'+1)*pw2[i]%mod2;
		if (i>0) ht2[i]=(ht2[i]+ht2[i-1])%mod2;
	}
	map<pair<ll,ll>,ll> dict;
	for (int i=0;i+m-1<n;i++){
		pair<ll,ll> ttt;
		{
			ll ed=ht[i+m-1];
			ll st=0;
			if (i>0) st=ht[i-1];
			ll tmp=(ed-st+mod)*inv(pw[i],mod)%mod;
			ttt.first=tmp;
		}
		{
			ll ed=ht2[i+m-1];
			ll st=0;
			if (i>0) st=ht2[i-1];
			ll tmp=(ed-st+mod2)*inv(pw2[i],mod2)%mod2;
			ttt.second=tmp;
		}
		dict[ttt]++;
	}

	vector<int> order;
	{
		ll x=0;
		order.emplace_back(x);
		for (x=p[x];x!=0;x=p[x]){
			order.emplace_back(x);
		}
	}

	cin >> t;

	vector<ll> A(m);
	vector<ll> B(m+m);
	vector<ll> B2(m+m);
	for (int i=0;i<m;i++){
		A[i]=t[order[i]]-'a'+1;
		B[m-1-i+m]=B[m-1-i]=pw[order[i]];
		B2[m-1-i+m]=B2[m-1-i]=pw2[order[i]];
	}

	vector<ll> C=NTT::mul(A,B);
	vector<ll> C2=NTT2::mul(A,B2);

	int pos=-1;
	for (int i=0;i<m;i++) if (dict.count(make_pair(C[m+m-1-i],C2[m+m-1-i]))){pos=i;break;}
	cout << pos << "\n";
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 3ms
memory: 11744kb

input:

3 2
2 1
aba
ba

output:

0

result:

ok 1 number(s): "0"

Test #2:

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

input:

7 4
3 4 2 1
dcabadc
abcd

output:

1

result:

ok 1 number(s): "1"

Test #3:

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

input:

100 10
5 3 8 10 7 1 4 9 6 2
dkrwvaottzwtarzokdvtwtarzokdvtzadtkwrvotottkwvzadrazkodtvrtwkdvtrztowakdvtrztowaazkodtvrtwzadtkwrvot
dkrwvaottz

output:

0

result:

ok 1 number(s): "0"

Test #4:

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

input:

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

output:

6

result:

ok 1 number(s): "6"

Test #5:

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

input:

1000 10
7 3 8 5 6 1 9 4 10 2
xfxjdlbgsrxlxsrfgbjdsgjlxbrdfxsgjlxbrdfxgxbrfxjsdlxfxjdlbgsrxfxjdlbgsrdsrxgjlfxbsgjlxbrdfxxfxjdlbgsrxfxjdlbgsrdsrxgjlfxbrjdxbsflxgrjdxbsflxgxfxjdlbgsrdsrxgjlfxbfdlbsrxxgjsgjlxbrdfxgxbrfxjsdlxlxsrfgbjdjbsfxgdrlxsgjlxbrdfxrjdxbsflxgrjdxbsflxgsgjlxbrdfxxlxsrfgbjdgxbrfxjsdlb...

output:

0

result:

ok 1 number(s): "0"

Test #6:

score: 0
Accepted
time: 53ms
memory: 18608kb

input:

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

output:

0

result:

ok 1 number(s): "0"

Test #7:

score: 0
Accepted
time: 43ms
memory: 18872kb

input:

100000 1000
583 913 457 431 934 337 447 735 412 555 211 46 254 341 368 835 72 171 651 180 986 47 354 500 887 379 528 867 541 833 525 296 300 57 992 821 646 996 468 49 856 573 929 656 979 416 94 610 349 88 655 13 387 748 312 15 316 826 230 212 146 317 438 617 781 561 465 298 328 417 941 20 943 942 86...

output:

3

result:

ok 1 number(s): "3"

Test #8:

score: 0
Accepted
time: 118ms
memory: 27604kb

input:

200000 20000
6760 18178 12483 17065 11456 14033 17871 7962 5800 17761 14375 9410 18027 16141 7619 1346 15586 9306 1188 14463 8823 7941 6635 1573 111 9338 4795 587 8124 3742 13297 6999 19280 18055 13069 14941 10755 6525 17386 15651 1766 6566 13355 17546 15938 7074 17517 5655 5526 254 5433 2549 4763 7...

output:

662

result:

ok 1 number(s): "662"

Test #9:

score: 0
Accepted
time: 59ms
memory: 12512kb

input:

200000 10
9 8 7 6 10 2 4 1 5 3
gfatgztmiggizmtgfgatmzgtitafggggtfamzigtimtzgftggamzgtitafggztigmagtfgggtfamzigtimtzgftggagizmtgfgatftgagtgzmitaggfgitzmggtfamzigttaggfgitzmgizmtgfgatggtfamzigtztigmagtfgmzgtitafggagfgtimgtzggtfamzigtmzgtitafggztigmagtfgimtzgftggaagfgtimgtzgfatgztmigtaggfgitzmimtzgftgg...

output:

0

result:

ok 1 number(s): "0"

Test #10:

score: 0
Accepted
time: 53ms
memory: 13748kb

input:

200000 1
1
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...

output:

0

result:

ok 1 number(s): "0"

Test #11:

score: 0
Accepted
time: 395ms
memory: 66000kb

input:

200000 200000
10346 154885 184424 149680 35636 48097 98625 160831 56852 149801 86780 179411 104814 6787 84033 26166 28348 147641 105020 21606 162086 51344 55220 66864 57151 15213 20770 104682 138735 30216 88163 154578 95744 77774 89460 75134 68771 5466 96323 24521 1271 86484 199015 157678 39152 1171...

output:

123942

result:

ok 1 number(s): "123942"

Test #12:

score: 0
Accepted
time: 4ms
memory: 11828kb

input:

100 10
5 3 6 10 8 1 9 4 2 7
abaabbbabbabbbbbaababbbaaabbbababbbbbaaaabaabbbabbbbbaaabbbababbbbbaaaabaabbbabbaabbbaabbbbabbbbbaaa
aabbbaabbb

output:

0

result:

ok 1 number(s): "0"

Test #13:

score: 0
Accepted
time: 4ms
memory: 11852kb

input:

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

output:

9

result:

ok 1 number(s): "9"

Test #14:

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

input:

1000 10
6 7 5 9 1 10 8 4 3 2
ababaabbabababaabbbabbaabbaaabaabbbaabbaababaabbabbabbbaaabaababaabbbaaabbaabbbaababaabbbabbaabbaaabbabbbaaabaabaaabbbabababaabbbaababaabbbabbaabbaaababaaabbbabbababbaabaababaabbabababaabbabbababbaaabbbaaabbaababaaabbbabbbaaabbaabbabbbaaabaaabbbaabbababbbaaabaababaabbabb...

output:

0

result:

ok 1 number(s): "0"

Test #15:

score: 0
Accepted
time: 56ms
memory: 18100kb

input:

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

output:

0

result:

ok 1 number(s): "0"

Test #16:

score: 0
Accepted
time: 55ms
memory: 17160kb

input:

100000 1000
907 32 955 913 277 307 44 812 798 355 771 727 442 951 678 36 145 833 360 486 629 293 283 448 564 390 50 274 488 1 168 171 829 190 119 588 560 506 711 35 62 200 540 520 256 905 255 176 287 349 330 582 946 21 163 1000 687 911 348 621 918 897 483 434 95 534 218 735 344 2 616 449 957 864 603...

output:

2

result:

ok 1 number(s): "2"

Test #17:

score: 0
Accepted
time: 131ms
memory: 26988kb

input:

200000 20000
15511 10580 9789 4102 11500 11858 6547 2740 17641 7839 7320 13382 13398 18347 6391 1433 10223 3505 8718 12592 15786 2808 5582 2209 351 4089 5765 15026 14226 16196 2231 13578 10895 2268 3272 8795 13010 2883 11797 5096 12303 3262 15433 9546 3941 11947 15572 17046 11848 6802 14963 5598 169...

output:

365

result:

ok 1 number(s): "365"

Test #18:

score: 0
Accepted
time: 57ms
memory: 13588kb

input:

200000 10
2 6 9 3 8 7 5 10 1 4
abbbababbabaabaabbbbaababbabbbbbabbabababaabaabbbbaababbabbbbbabbabababaabbbbaabbbbabbabaaabbbbabbaababaabbabbbbbbbaaaabbabaabbabbbbbbbaaaabbbabbabababaabbbbaabbbbbbaaaabaababbabbbbabaabbabbbaabbbbaabbabaabbabbabbbbabbaabbabbabababbbabbabaabbabbabababaabbbbaabaababbabb...

output:

0

result:

ok 1 number(s): "0"

Test #19:

score: 0
Accepted
time: 401ms
memory: 65796kb

input:

200000 200000
18930 128303 172934 36589 134433 123453 7842 48088 163157 108462 155453 64136 66846 176479 159707 60453 102803 180757 53568 21512 131391 106465 23141 185525 60617 82584 81584 42261 48454 183714 32825 59223 115874 159063 69331 144458 106127 152054 103566 169284 44763 141520 99891 33436 ...

output:

77606

result:

ok 1 number(s): "77606"

Test #20:

score: 0
Accepted
time: 402ms
memory: 65844kb

input:

200000 200000
120911 170729 21569 44924 40105 18276 49235 9067 130445 34699 5786 2126 170272 35449 24243 194896 16753 21429 193829 157509 137337 119302 160749 193402 117165 64678 3720 68305 70603 121106 145443 44701 161968 127404 180108 131265 174067 131339 189923 43356 47379 53905 126377 82058 4335...

output:

0

result:

ok 1 number(s): "0"

Test #21:

score: 0
Accepted
time: 53ms
memory: 11884kb

input:

200000 1
1
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

0

result:

ok 1 number(s): "0"

Test #22:

score: 0
Accepted
time: 205ms
memory: 41172kb

input:

200000 100000
18019 99098 92006 39309 14798 39019 18141 63356 96191 48013 82759 41014 45274 14722 39926 93566 24253 45058 96771 69453 4643 32602 21249 22979 14573 48655 66376 38406 752 4545 70103 33096 52139 18839 74322 31632 18990 22302 38893 44589 31024 88263 24128 14855 90379 27911 95199 80240 61...

output:

0

result:

ok 1 number(s): "0"

Test #23:

score: 0
Accepted
time: 120ms
memory: 24644kb

input:

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

output:

-1

result:

ok 1 number(s): "-1"

Test #24:

score: 0
Accepted
time: 118ms
memory: 25048kb

input:

200000 1000
303 9 670 482 882 690 355 433 996 384 642 276 525 823 234 395 657 903 289 341 734 961 788 909 951 17 31 179 475 978 373 470 987 572 460 578 724 84 275 73 141 954 837 128 666 947 762 508 621 974 684 307 294 834 603 147 669 848 896 959 861 663 87 683 329 811 880 426 321 290 782 285 935 375...

output:

-1

result:

ok 1 number(s): "-1"

Test #25:

score: 0
Accepted
time: 123ms
memory: 25208kb

input:

200000 2000
902 1610 1589 1487 1064 1359 1956 1390 513 323 1764 1876 262 1461 1997 1921 1011 1307 1433 943 142 237 1244 291 9 1153 1504 561 1988 1748 1781 1023 1084 1049 392 219 475 143 231 1696 1633 1245 801 750 1839 1130 649 1098 128 645 1521 1786 497 798 1611 930 489 1242 1163 960 1677 721 894 10...

output:

-1

result:

ok 1 number(s): "-1"

Test #26:

score: 0
Accepted
time: 121ms
memory: 25692kb

input:

200000 5000
952 4061 1878 4380 2274 321 1552 576 868 3460 387 1952 1202 4042 3007 1950 3462 1957 2488 3743 259 4343 3871 3857 659 4597 4926 3491 4920 3424 132 3838 4661 2650 1128 2830 531 2921 3756 4187 2791 2928 3520 1504 737 2414 2002 3138 3848 890 3932 4607 1535 4735 1587 3159 1873 4006 394 3224 ...

output:

-1

result:

ok 1 number(s): "-1"

Test #27:

score: 0
Accepted
time: 127ms
memory: 27332kb

input:

200000 20000
7497 11085 9088 16475 2631 11393 4669 9597 14566 11666 13479 5316 10131 4205 3356 17505 3723 15386 11541 8755 6494 12622 12780 1588 4728 9105 1498 4994 994 2677 13217 11835 18797 6413 16453 3703 5463 18781 12936 512 2637 9499 3722 4517 2507 9960 7052 11684 18039 9844 6521 108 11245 1458...

output:

-1

result:

ok 1 number(s): "-1"

Test #28:

score: 0
Accepted
time: 252ms
memory: 45500kb

input:

200000 100000
34132 21715 80187 68842 62662 40314 12148 3065 49338 87321 28340 90700 40087 98759 44912 43069 56042 62336 12256 99807 79599 80593 99361 67038 19817 76079 8524 69408 36490 86095 63828 31477 44922 33135 53202 620 50814 67080 15481 43903 35318 75488 14749 31235 92 86817 69401 2169 89892 ...

output:

-1

result:

ok 1 number(s): "-1"

Test #29:

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

input:

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

output:

15

result:

ok 1 number(s): "15"

Test #30:

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

input:

200000 1000
327 409 297 258 955 888 836 988 544 716 377 886 543 561 299 433 764 465 842 457 846 624 61 137 536 102 520 468 338 20 233 779 490 519 979 57 18 948 136 640 535 15 37 576 85 171 562 71 966 546 699 517 655 133 303 448 947 153 545 59 648 304 831 594 984 184 272 662 447 134 32 206 895 107 40...

output:

349

result:

ok 1 number(s): "349"

Test #31:

score: 0
Accepted
time: 120ms
memory: 25124kb

input:

200000 2000
1191 615 620 891 1408 900 737 940 1733 602 503 754 1637 1541 584 1181 1997 1546 530 823 542 288 929 1743 119 177 494 1579 1840 1391 1578 1176 1708 748 314 1783 137 456 1117 644 1980 732 19 1883 1589 385 989 1744 1891 1508 581 871 323 1197 1718 592 1875 79 81 405 878 971 1403 1807 1734 88...

output:

686

result:

ok 1 number(s): "686"

Test #32:

score: 0
Accepted
time: 117ms
memory: 26348kb

input:

200000 5000
2892 3962 3236 4311 412 1794 2697 3157 736 1809 1300 348 4175 2102 2970 1759 2974 2201 2006 3902 3784 3648 2523 1091 3368 409 1390 4025 661 4442 3904 1363 4333 1198 2218 1730 4335 2320 1575 133 1564 2206 3562 758 2915 3543 3920 1506 595 3099 3525 3675 4144 3907 2839 368 4058 4027 92 2845...

output:

3342

result:

ok 1 number(s): "3342"

Test #33:

score: 0
Accepted
time: 121ms
memory: 27156kb

input:

200000 20000
17485 13498 4524 17578 10103 8397 9752 7312 17411 14975 4162 15581 7357 8831 12124 18180 8623 4117 4471 9608 19272 7622 14273 8549 16810 7250 13788 188 19245 2260 253 2433 5495 7113 2276 16987 6360 5933 19890 10831 826 11688 6597 5530 17688 19403 11290 4362 6821 9539 11647 16266 7633 79...

output:

885

result:

ok 1 number(s): "885"

Test #34:

score: 0
Accepted
time: 247ms
memory: 46556kb

input:

200000 100000
60639 17802 36721 18183 37239 63335 18428 86976 50494 14736 61800 46106 75841 64753 37368 72679 25992 7269 86142 27760 28928 1519 14946 43640 56284 26629 80707 39890 50533 75970 5472 20109 99205 60819 70832 38356 18385 49088 4414 1258 86635 77776 4314 84148 23137 35866 15683 84006 7164...

output:

25931

result:

ok 1 number(s): "25931"

Test #35:

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

input:

200000 100000
28621 84403 66504 88009 33699 45168 83585 66073 51460 48769 81812 48591 94870 7653 14138 72832 57263 37917 24777 54385 23020 96990 90057 46968 42882 59049 17715 33964 17070 26640 63099 70475 14457 46878 61895 94275 33289 44609 6196 65541 7511 58620 18711 41261 35186 27887 63684 85096 2...

output:

0

result:

ok 1 number(s): "0"

Test #36:

score: 0
Accepted
time: 229ms
memory: 48072kb

input:

200000 100000
75390 78935 11124 27297 7614 62319 88793 94068 33310 4278 14573 79493 69663 25483 20952 30150 63146 83220 57824 50057 62969 91889 99266 37166 972 85649 89135 39990 69383 89493 8420 49609 28131 30088 91708 24159 93736 92830 36275 29012 3800 48818 60130 77491 91638 62612 60417 64083 1282...

output:

0

result:

ok 1 number(s): "0"

Test #37:

score: 0
Accepted
time: 226ms
memory: 45308kb

input:

200000 100000
3638 30572 66168 68211 6667 27812 72236 41122 21072 27066 59132 30398 33981 6097 99404 63692 49976 54205 19137 83910 86735 87030 4826 69218 71881 82703 90521 11892 79782 97941 99283 4503 84537 43964 41372 86642 39674 89670 8452 22929 49054 52231 49874 94107 62949 88724 53720 65439 3421...

output:

0

result:

ok 1 number(s): "0"

Test #38:

score: 0
Accepted
time: 230ms
memory: 45504kb

input:

200000 100000
32331 36788 47678 52834 58353 25633 35341 61084 19512 23413 37927 74452 59234 70366 90402 58530 58330 59814 63501 6885 9551 14032 82995 70593 12883 81262 15209 89529 41802 86107 84882 19958 12921 93223 44067 1632 44083 84057 6411 6464 85883 86176 24570 25427 32085 93455 26284 71370 644...

output:

0

result:

ok 1 number(s): "0"

Test #39:

score: 0
Accepted
time: 242ms
memory: 45556kb

input:

200000 100000
71664 83264 49764 94504 11702 39907 97912 8068 88290 29222 48482 62003 94706 26107 78781 21146 72316 29934 36070 22279 70896 92680 66277 59031 78403 27401 19908 14054 30151 83136 7390 86575 63075 47752 19094 98112 77513 28158 49000 54343 95107 70838 97203 42398 83137 27784 37340 85860 ...

output:

0

result:

ok 1 number(s): "0"

Test #40:

score: 0
Accepted
time: 94ms
memory: 20460kb

input:

200000 1000
532 724 53 294 812 20 886 735 710 225 899 18 832 301 279 315 74 927 87 517 210 57 968 436 148 159 241 581 957 70 571 373 27 259 731 693 253 64 457 186 585 487 52 509 175 937 360 844 192 377 149 688 309 552 168 390 176 150 462 553 442 501 852 738 464 467 991 637 473 426 776 413 804 518 33...

output:

0

result:

ok 1 number(s): "0"

Test #41:

score: 0
Accepted
time: 127ms
memory: 26772kb

input:

200000 20000
8857 11661 19539 19499 5281 14518 18348 8086 17856 15621 4661 10170 2700 12001 5739 337 16983 12269 9289 19043 18137 4426 5299 8554 5819 3703 13696 12977 2993 9129 13541 6152 10942 12015 19028 3475 11432 2188 3298 16850 2891 17826 13418 12028 2050 1946 11707 11308 19163 7679 17599 2748 ...

output:

0

result:

ok 1 number(s): "0"

Test #42:

score: 0
Accepted
time: 117ms
memory: 24664kb

input:

200000 15000
4320 625 12266 564 11570 3709 9412 9406 7035 958 7908 14783 13392 14904 1036 4337 14232 9064 11894 8981 4001 5176 508 9121 12118 3869 13270 1391 14917 14059 9336 5130 5377 9302 14374 687 12552 3336 9568 1240 6135 7206 10108 5974 525 4265 8191 10381 14497 4124 14978 9467 12873 14180 1416...

output:

0

result:

ok 1 number(s): "0"