QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#184591#7088. Square GraphDualqwqAC ✓423ms121716kbC++144.7kb2023-09-20 21:41:102023-09-20 21:41:10

Judging History

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

  • [2023-09-20 21:41:10]
  • 评测
  • 测评结果:AC
  • 用时:423ms
  • 内存:121716kb
  • [2023-09-20 21:41:10]
  • 提交

answer

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

namespace FastIO {
	#define iL (1 << 20)
	char ibuf[iL],*iS = ibuf + iL,*iT = ibuf + iL;
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread(ibuf,1,iL,stdin),iS == iT ? EOF : *iS++) : *iS++)
	template<typename T>
	inline void read(T &a) {
		char ch;int sign = 0;
		for(ch = gc();!isdigit(ch);ch = gc())
			if(ch == '-') sign = 1;
		a = ch & 15;
		for(ch = gc();isdigit(ch);ch = gc())
			a = (a << 3) + (a << 1) + (ch & 15);
		if(sign) a = -a;
	}
	char Out[iL],*iter = Out;
	#define flush() fwrite(Out,1,iter - Out,stdout),iter = Out
	template<typename T>
	inline void write(T x,char end = '\n') {
		int c[40],l = 0;if(x < 0) *iter++ = '-',x = -x;
		do c[++l] = x % 10,x /= 10; while(x);
		while(l) *iter++ = c[l--] + '0';
		*iter++ = end;flush();
	}
	#undef iL
	#undef gc
	#undef flush
}
using namespace FastIO;
const int N = 3e5 + 5,Lg = 20;
typedef long long ll;
int SubId,n;
int a[N],b[N],w[N];
int lg[N];

struct SA {
	SA(){}
	int v1[N],v2[N];
	int sa[N],ton[N];
	inline bool cmp(int *r,int i,int j,int k) { 
        return r[i] == r[j] && (i + k > n ? 0 : r[i + k]) == (j + k > n ? 0 : r[j + k]);
    }
	inline void Getsa(int *s,int *sa,int n,int m) {
		#define For(i,a,b) for(int i = (a);i <= (b);i++)
		#define Rof(i,a,b) for(int i = (a);i >= (b);i--)
		For(i,1,n) sa[i] = rk[i] = v1[i] = v2[i] = 0;
		int *x = v1,*y = v2,*t;
		For(i,0,m) ton[i] = 0;
		For(i,1,n) ton[x[i] = s[i]]++;
		For(i,0,m) ton[i] += ton[i - 1];
		Rof(i,n,1) sa[ton[x[i]]--] = i;
		for(int j = 1,p;j <= n;j *= 2,m = p) {
			p = 0;
			For(i,n - j + 1,n) y[++p] = i;
			For(i,1,n) if(sa[i] > j) y[++p] = sa[i] - j;
			For(i,0,m) ton[i] = 0;
			For(i,1,n) ton[x[y[i]]]++;
			For(i,1,m) ton[i] += ton[i - 1];
			Rof(i,n,1) sa[ton[x[y[i]]]--] = y[i],y[i] = 0;
			t = x;x = y;y = t;p = 1;x[sa[1]] = 1;
			For(i,2,n) 
				x[sa[i]] = cmp(y,sa[i - 1],sa[i],j) ? p : (++p);
			if(p >= n) break;
		}
		#undef For
		#undef Rof
	}
	int rk[N],height[N];
	inline void GetHeight(int *s,int n) {
		s[n + 1] = 0;
		for(int i = 1;i <= n;i++) rk[sa[i]] = i;
		for(int i = 1,j = 0;i <= n;i++) {
			if(j) --j;
			if(rk[i] != 1) 
				while(i + j <= n && sa[rk[i] - 1] + j <= n && s[i + j] == s[sa[rk[i] - 1] + j]) ++j;
			height[rk[i]] = j;
		}
	}
	int ST[Lg][N];
	inline int LCP(int l,int r) {
		if(l < 1 || r < 1 || l > n || r > n) return 0;
		l = rk[l];r = rk[r];
		if(l > r) swap(l,r);
        int t = __lg(r - (++l) + 1);
        return min(ST[t][l], ST[t][r - (1 << t) + 1]);
	}
	inline void init(int *a,int n) {
		for(int i = 1;i <= n;i++) rk[i] = sa[i] = height[i] = 0;
		Getsa(a,sa,n,n);
		GetHeight(a,n);
		for(int i = 1;i <= n;i++) ST[0][i] = height[i];
		for(int j = 1;j < Lg;j++)
			for(int i = 1;i + (1 << j) - 1 <= n;i++)
				ST[j][i] = min(ST[j - 1][i],ST[j - 1][i + (1 << j - 1)]);
	}
};
SA A,B;

struct BCJ {
	int fa[N],sze[N];
	inline void init(int n) { for(int i = 1;i <= n;i++) fa[i] = i,sze[i] = 1;}
	int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]);}
	inline void Merge(int x,int y) {
		x = find(x);y = find(y);
		if(x == y) return;
		if(sze[x] < sze[y]) swap(x,y);
		fa[y] = x;sze[x] += sze[y];
	}
	inline int Same(int x,int y) { return find(x) == find(y);}
}S[Lg],S0;

long long ans;
inline void Union(int x,int y,int dep) { // [x,x + 2^{dep}) , [y,y + 2^{dep})
	if(S[dep].Same(x,y)) return;
	if(dep == 0) {
		if(!S0.Same(x,y)) ans += w[y - x],S0.Merge(x,y);
		return;
	}
	S[dep].Merge(x,y);
	Union(x,y,dep - 1);
	if(y + (1 << dep - 1) <= n) Union(x + (1 << dep - 1),y + (1 << dep - 1),dep - 1);
}
int srt[N];
inline void Work() {
	read(n);
	for(int i = 1;i <= n;i++) read(a[i]),b[n - i + 1] = a[i];
	for(int i = 1;i <= n / 2;i++) read(w[i]),srt[i] = i;
	A.init(a,n);B.init(b,n);
	sort(srt + 1,srt + n / 2 + 1,[&](const int &x,const int &y) { return w[x] < w[y];});
	S0.init(n);
	for(int i = 0;i < Lg;i++) S[i].init(n);
	lg[0] = -1;
	for(int i = 1;i <= n;i++) lg[i] = lg[i >> 1] + 1;
	ans = 0;
	for(int _ = 1;_ <= n / 2;_++) {
		int len = srt[_];
		for(int i = len;i + len <= n;i += len) {
			int l = i,r = i + len;
			int L = n - (r - 1) + 1,R = n - (l - 1) + 1;
			int lcp = A.LCP(l,r);lcp = min(lcp,len);
			int lcs = B.LCP(L,R);lcs = min(lcs,len - 1);
			if(lcp + lcs >= len) {
				int tlen = lcp + lcs - len + 1;
				int cl = i - lcs,cr = cl + tlen - 1;
				cr = cr + len - 1;
				int k = lg[cr - cl + 1];
				Union(cl,cl + len,k);
				Union(cr - (1 << k) + 1,cr - (1 << k) + 1 + len,k);
			}
		}
	}
	write(ans);
}
int main() {
	// freopen("mst.in","r",stdin);
	// freopen("mst.out","w",stdout);
	int T;read(T);
	while(T--) Work();
	return 0;
}
/*
1
9
1 2 2 1 2 2 2 2 2
4 1 3 4
*/

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1
8
2 2 5 6 2 5 6 2
5 1 4 4

output:

21

result:

ok "21"

Test #2:

score: 0
Accepted
time: 38ms
memory: 90276kb

input:

3000
41
1 1 2 1 1 2 1 1 2 2 2 1 1 1 2 2 1 2 1 1 2 1 2 2 1 1 1 1 1 2 2 1 1 1 1 2 2 2 1 1 2
37 81 33 27 88 64 13 12 39 94 90 76 5 94 6 10 87 91 7 48
43
2 2 2 2 1 2 2 1 1 1 2 1 1 2 1 1 2 2 1 1 1 1 1 2 2 2 1 2 2 2 1 2 1 1 2 2 1 1 2 1 2 1 1
55 29 4 81 8 90 1 95 94 70 5 3 64 67 70 60 39 59 39 29 99
47
1 2...

output:

1169
1527
1193
1065
739
394
3245
1196
2962
1399
3334
1952
1093
2577
901
83
1559
226
3055
2631
212
2804
1769
925
2652
2040
2106
3917
1608
517
532
1447
2712
1845
2797
628
2551
2637
210
471
3293
1362
1210
2021
1096
1490
2931
3200
4073
1641
1851
4823
864
1502
1674
698
2189
2144
1878
1053
421
337
1524
26...

result:

ok 3000 tokens

Test #3:

score: 0
Accepted
time: 32ms
memory: 90256kb

input:

3000
75
1 1 1 2 2 1 1 2 1 1 2 2 2 1 1 2 1 1 2 1 1 2 1 1 2 2 2 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 2 2 1 2 1 1 1 2 2 2 2 1 1 1 1 2 2 1 1 2 2 1 2 2 2 2 2 2 2 2 1 2 1
69 55 48 7 94 67 75 44 45 87 7 20 74 86 33 87 98 38 59 75 15 67 48 70 89 69 30 34 92 96 91 15 63 54 67 65 9
60
2 2 1 2 2 2 2 1 2 1 2 1 1 2 1 2...

output:

2889
2671
2113
2727
840
2193
2600
2360
267
1367
4648
2062
1740
1853
2114
490
15
2887
452
3794
1031
3428
2213
2862
492
1769
854
2537
4498
3400
1177
2383
576
2621
2306
2799
333
959
2118
2370
3337
1538
605
1327
4021
1998
1038
2290
1725
1202
4298
2001
3841
361
1739
285
234
655
1738
1012
3311
715
3771
54...

result:

ok 3000 tokens

Test #4:

score: 0
Accepted
time: 32ms
memory: 90260kb

input:

3000
52
2 2 1 2 1 1 2 2 1 2 2 1 1 1 1 1 1 2 1 1 2 2 2 1 2 1 1 1 1 2 2 1 2 2 1 1 1 1 2 2 2 1 2 1 1 2 1 2 2 1 1 1
65 79 47 69 16 44 37 86 39 60 84 51 58 31 18 96 82 88 10 100 9 42 83 42 53 25
52
1 2 1 1 1 2 2 2 1 2 2 2 1 2 2 1 1 1 1 2 2 2 1 1 1 2 2 1 2 1 2 2 1 2 2 1 1 1 1 2 1 2 1 2 2 2 1 1 1 2 1 2
95 ...

output:

2573
2152
2784
2808
586
737
3491
3894
1551
3040
1324
2019
766
723
2045
534
1143
584
4691
1052
3218
798
1274
4603
1417
2285
2643
3030
432
840
597
1201
1375
1108
5191
4305
2770
490
2193
1988
2106
2283
4438
998
3188
788
2440
2095
2444
1547
376
2183
111
4627
3248
862
1110
2678
2056
51
2238
1162
1119
400...

result:

ok 3000 tokens

Test #5:

score: 0
Accepted
time: 28ms
memory: 92072kb

input:

3000
62
3 2 2 1 4 5 3 5 5 5 4 5 1 4 2 1 1 2 2 4 4 2 2 1 3 2 1 2 1 3 5 4 1 3 3 2 2 2 3 2 3 1 4 4 3 4 3 4 1 1 2 2 3 4 1 1 5 1 2 4 3 3
421365777 831616822 950787430 270300815 35365972 916821714 542965999 146553901 444779521 340715057 983926749 477210482 475811143 605420792 775843602 739625008 81179672 ...

output:

12141804409
3514131806
13169144445
2834321189
4486289916
9365861534
19576050944
5331567924
2478214236
10120189376
6234037984
4772438519
822409467
9546763284
1890883254
10063013047
9328670724
5941666882
1520030152
12085259192
2527539040
6837130908
3960468724
3734588204
16751260189
745609947
278011044...

result:

ok 3000 tokens

Test #6:

score: 0
Accepted
time: 27ms
memory: 90680kb

input:

3000
95
3 5 1 1 4 2 5 1 2 4 2 2 4 1 5 5 2 3 1 1 4 1 2 2 1 5 5 1 2 4 5 4 2 2 2 3 3 2 5 5 5 4 4 3 1 3 4 3 2 2 2 3 3 5 1 5 1 5 4 4 3 4 4 1 4 3 2 4 2 5 4 3 3 2 1 5 5 4 4 1 5 3 4 5 2 3 4 1 4 1 3 2 3 5 1
424088652 632010471 774450715 372487597 308102681 822963353 769946235 300697393 838458560 119222841 87...

output:

11641825395
423266192
8128431577
2975328961
724283784
7726787435
3958571304
5840908183
13109978662
6141304494
7475762420
5646743023
8075122865
5758155513
7431563108
5017751770
7718700502
11634959512
11745951987
5965010228
15387865647
8535897994
17809028780
23892051157
2323825336
1107917884
431613111...

result:

ok 3000 tokens

Test #7:

score: 0
Accepted
time: 27ms
memory: 92144kb

input:

3000
26
5 3 2 3 3 5 2 3 3 2 5 1 4 4 3 5 2 4 5 5 1 1 1 1 2 5
207931107 614536623 629001820 112093714 506722332 311961087 93990579 67140726 861435900 190087119 97599359 916252534 85629395
6
4 4 1 2 4 2
396521794 780484551 141958399
47
1 1 2 2 2 3 1 1 2 5 1 1 2 2 2 3 3 3 2 1 1 5 2 3 5 4 4 2 5 5 5 3 5 4...

output:

1455517749
396521794
10745876239
6630115397
10402871870
19077444882
572314658
20782278554
4352726008
24006096728
10633448335
3379046930
5272110524
4239680082
12558548995
8497545848
17559672467
16505145636
18494578194
11898911682
9351222916
4119102344
3238900654
10430517563
1686566822
3242206822
6470...

result:

ok 3000 tokens

Test #8:

score: 0
Accepted
time: 112ms
memory: 115880kb

input:

3
91459
1 2 2 1 2 1 2 2 1 1 2 1 1 2 1 2 1 1 2 2 1 1 1 2 2 2 1 2 1 2 1 2 1 2 1 1 2 1 1 1 1 2 1 2 2 2 2 2 2 1 2 1 1 2 2 1 1 2 1 2 2 2 2 1 1 2 1 2 1 2 1 1 1 2 2 1 1 2 2 2 1 2 1 1 1 2 2 1 1 1 2 1 2 1 2 1 1 2 2 2 1 1 1 1 1 2 2 2 2 1 2 1 1 2 1 2 1 2 2 2 2 1 1 1 2 1 2 1 2 2 2 2 2 2 1 1 2 1 2 1 1 1 2 1 2 2 ...

output:

34493510308025
28135712783521
16036163997127

result:

ok 3 tokens

Test #9:

score: 0
Accepted
time: 111ms
memory: 116640kb

input:

3
83722
2 1 1 2 1 2 2 2 1 2 2 1 1 2 1 1 1 2 1 2 2 2 2 2 1 2 1 2 2 2 2 2 1 2 1 2 1 2 1 1 1 1 1 2 1 1 1 1 1 1 2 2 1 1 2 2 2 2 1 2 2 1 2 1 2 2 2 1 1 2 2 1 2 1 2 2 1 1 1 1 1 1 1 1 1 2 2 2 2 1 2 2 2 2 1 1 2 2 2 1 1 1 1 1 2 2 1 2 2 1 1 1 1 1 1 2 2 2 2 2 1 2 1 1 2 1 1 1 2 2 1 2 2 2 1 2 1 2 2 1 1 2 2 1 2 2 ...

output:

21339463701730
30869499177303
24972625595784

result:

ok 3 tokens

Test #10:

score: 0
Accepted
time: 110ms
memory: 116712kb

input:

3
92527
2 2 2 1 1 2 1 2 1 2 2 2 2 1 2 1 2 2 1 1 2 1 1 2 2 2 2 2 1 2 1 2 2 1 2 2 2 1 2 2 1 1 2 2 1 1 2 1 2 2 1 2 2 2 1 2 2 2 2 1 2 2 2 2 1 1 1 2 1 1 2 1 2 1 2 2 1 2 2 2 2 1 2 1 2 1 1 2 2 2 1 1 1 1 1 1 2 2 2 1 1 1 2 2 2 2 2 2 2 1 2 1 2 1 1 1 2 2 1 1 2 1 2 1 1 2 1 1 2 1 2 2 2 1 2 2 1 1 1 1 1 2 1 2 2 2 ...

output:

41213747600146
25828522635122
28026863142855

result:

ok 3 tokens

Test #11:

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

input:

3
92197
6 86 53 47 10 75 24 83 22 4 86 21 80 73 6 59 71 75 53 65 61 91 68 55 84 96 15 89 69 36 13 33 34 39 12 65 59 84 67 38 54 46 81 16 21 75 14 31 43 93 23 65 69 77 82 37 41 87 37 77 70 61 53 11 94 66 91 33 90 64 89 90 78 89 2 83 88 77 13 80 66 62 19 15 83 13 75 52 75 95 24 42 54 10 54 84 21 38 69...

output:

699397471008
44364093983
336754742868

result:

ok 3 tokens

Test #12:

score: 0
Accepted
time: 90ms
memory: 116604kb

input:

3
94967
15 22 65 29 28 75 54 57 72 64 41 99 49 25 74 36 59 41 59 86 50 68 8 46 38 24 84 90 70 98 24 36 46 98 48 97 60 62 13 27 19 1 16 67 40 16 57 97 62 85 65 50 41 62 32 66 68 4 96 17 11 34 92 37 66 71 42 13 99 93 73 24 24 3 10 91 34 71 54 95 18 53 53 63 56 54 32 20 98 11 27 86 93 80 100 26 60 56 8...

output:

253110659385
233578104813
793066483260

result:

ok 3 tokens

Test #13:

score: 0
Accepted
time: 92ms
memory: 115716kb

input:

3
93301
5886 8694 8457 717 562 1275 6014 9328 6830 3019 5807 5714 3794 8075 753 6790 8398 1133 2631 4926 497 8423 6502 8985 3517 4589 6819 6471 1659 1467 1724 1080 2303 4953 9910 1695 1983 6301 1829 5863 9412 6597 9495 8856 8609 7205 1649 9456 5904 6668 2481 3174 3603 4378 8154 635 807 6861 9767 734...

output:

1926143406
795305966
17002152

result:

ok 3 tokens

Test #14:

score: 0
Accepted
time: 78ms
memory: 117548kb

input:

3
97546
9398 5543 9700 2614 3767 4086 7357 3134 6178 5854 1218 1404 6766 9329 1055 3435 3518 2796 1796 9385 9711 9392 6299 5901 1461 8451 2735 8952 2612 9917 9241 464 2524 6612 3355 453 9412 3861 7016 5979 191 8627 5406 4441 1081 8076 7099 9499 3627 4831 4621 3974 9618 58 1496 3239 3136 7329 6989 10...

output:

1558402928
2704756613
7163756899

result:

ok 3 tokens

Test #15:

score: 0
Accepted
time: 89ms
memory: 113100kb

input:

3
99151
83591 88986 4418 19978 61468 30875 16554 54165 84586 57443 7800 32179 47267 83481 2783 29241 53642 64615 92607 7554 83823 18679 955 21618 92930 91051 11868 29260 28914 92682 66157 83817 90238 20185 87072 69833 15088 88991 23176 36840 17192 75788 84674 85197 93882 11985 58481 34148 14049 4412...

output:

0
357503443
0

result:

ok 3 tokens

Test #16:

score: 0
Accepted
time: 88ms
memory: 113124kb

input:

3
90848
16640 44350 16341 74602 8372 61272 52662 51880 52140 90104 88662 57719 50687 41946 55445 65221 26720 32475 69482 25090 66788 47587 46157 7882 45818 12070 60532 28876 49441 46100 53175 87090 3040 28537 87250 69915 48749 34549 71314 8834 32400 49601 72681 17536 42197 51151 88654 44294 79041 31...

output:

0
1063388446
848771538

result:

ok 3 tokens

Test #17:

score: 0
Accepted
time: 48ms
memory: 86240kb

input:

10000
22
4 4 3 1 1 1 2 3 1 3 2 3 1 3 1 1 3 1 3 1 3 4
855047817 947040334 747297665 844735514 145683531 9174576 925287705 290220725 544646344 56999149 579921467
29
2 4 1 4 1 3 2 1 4 1 1 2 4 2 3 1 3 2 4 3 2 3 2 1 2 2 1 1 3
405590995 784488104 51399657 815873088 53146786 551778403 502568093 647407380 5...

output:

12829187655
4354725401
8533727721
2249658690
5067626052
6267821286
3835278075
3928917960
3792098644
7096563453
933888906
552641187
1129011982
4522771166
6906984722
6304859181
2762542831
6594948698
7156693139
8739355977
1812484617
2163726842
208648202
2690205454
5924291304
4764603555
2387770350
69928...

result:

ok 10000 tokens

Test #18:

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

input:

10000
24
1 1 2 1 2 2 1 2 2 1 1 2 2 1 1 2 1 2 1 2 1 1 1 1
853843663 380421798 311693886 937974842 542169444 962906346 655668186 188203995 602082001 297000536 236582089 474829154
30
2 2 1 2 2 1 2 1 1 1 1 1 1 2 2 2 1 1 1 1 1 1 2 2 2 1 2 2 2 2
687190658 945723542 95985182 142072042 372983896 577286290 1...

output:

12065408453
7511783076
3826911909
13253171856
5431324965
5578488016
6550243216
8963769170
6148324698
8535260179
6424810853
8369086588
5681853508
4046515195
4502429344
6677472473
794941715
9817742879
12485574905
3215170821
7422458855
6863754246
6118292561
2769087420
11523513917
7701768934
13820648397...

result:

ok 10000 tokens

Test #19:

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

input:

10
23824
25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 ...

output:

23823
27682
155582
128524
141260
8277951
2522962
34417174
44809097
6186268

result:

ok 10 tokens

Test #20:

score: 0
Accepted
time: 44ms
memory: 86668kb

input:

10000
25
14 7 8 16 15 17 4 13 1 12 3 11 3 7 3 12 6 8 11 3 13 5 11 9 17
189739725 708624977 173084125 39562260 332294514 822787899 216591448 998294372 437292343 25418152 962993248 236786172
41
10 8 4 10 16 7 13 1 8 3 10 11 18 12 15 12 6 5 3 14 3 17 9 9 3 15 7 3 5 12 18 14 6 3 8 18 1 18 5 8 6
99999999...

output:

0
999999990
999999993
999999997
4999999952
5999999928
999999999
16999999802
5999999960
384698952
999999999
2857697415
750321309
1717326142
6047599495
24999999867
18696709999
999999995
3999999974
999999993
5999999990
3999999980
579690135
5999999970
3999999988
0
999999988
1999999996
9362452038
0
42786...

result:

ok 10000 tokens

Test #21:

score: 0
Accepted
time: 144ms
memory: 114840kb

input:

7501
115
96 5 112 112 49 95 96 46 49 112 46 96 5 64 95 38 5 5 71 64 64 71 63 112 64 63 64 38 96 49 63 96 64 49 77 71 77 5 38 5 96 63 5 112 95 71 49 96 77 112 96 77 63 46 49 95 46 112 95 5 77 96 49 96 71 95 96 63 49 49 5 63 112 71 96 112 96 38 95 112 38 63 77 49 95 64 71 112 77 77 38 38 71 5 64 95 38...

output:

1832016626
3333441936
138617656
2000000000
2392692504
1000000000
136743898
0
0
1000000000
0
1000000000
1000000000
250813349
1000000000
581370684
1000000000
980963304
993145610
795954129
0
1000000000
891066957
1000000000
1000000000
0
563330408
0
1047790427
1000000000
17772067
2000000000
448018570
640...

result:

ok 7501 tokens

Test #22:

score: 0
Accepted
time: 423ms
memory: 121068kb

input:

1
300000
244455 244455 244455 244455 244455 244455 244455 244455 244455 244455 244455 244455 244455 244455 244455 244455 244455 244455 244455 244455 244455 244455 244455 244455 244455 244455 244455 244455 244455 244455 244455 244455 244455 244455 244455 244455 244455 244455 244455 244455 244455 2444...

output:

299954000494633

result:

ok "299954000494633"

Test #23:

score: 0
Accepted
time: 415ms
memory: 120304kb

input:

1
300000
281337 281337 281337 281337 281337 281337 281337 281337 281337 281337 281337 281337 281337 281337 281337 281337 281337 281337 281337 281337 281337 281337 281337 281337 281337 281337 281337 281337 281337 281337 281337 281337 281337 281337 281337 281337 281337 281337 281337 281337 281337 2813...

output:

299952002650593

result:

ok "299952002650593"

Test #24:

score: 0
Accepted
time: 361ms
memory: 121440kb

input:

1
300000
201614 201614 201614 201614 201614 201614 201614 201614 201614 201614 201614 201614 201614 201614 201614 201614 201614 201614 201614 201614 201614 201614 201614 201614 201614 201614 201614 201614 201614 201614 201614 201614 201614 201614 201614 201614 201614 201614 201614 201614 201614 2016...

output:

299945003792230

result:

ok "299945003792230"

Test #25:

score: 0
Accepted
time: 344ms
memory: 121524kb

input:

1
300000
101142 101142 101142 101142 101142 101142 101142 101142 101142 101142 101142 101142 101142 101142 101142 101142 101142 101142 101142 101142 101142 101142 101142 101142 101142 101142 101142 101142 101142 101142 101142 101142 101142 101142 101142 101142 101142 101142 101142 101142 101142 1011...

output:

299925010181880

result:

ok "299925010181880"

Test #26:

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

input:

1
300000
299900 299900 299900 299900 299900 299900 299900 299900 299900 299900 299900 299900 299900 299900 299900 299900 299900 299900 299900 299900 299900 299900 299900 299900 299900 299900 299900 299900 299900 299900 299900 299900 299900 299900 299900 299900 299900 299900 299900 299900 299900 2999...

output:

299855039739800

result:

ok "299855039739800"

Test #27:

score: 0
Accepted
time: 280ms
memory: 121696kb

input:

1
300000
111630 111630 111630 111630 111630 111630 111630 111630 111630 111630 111630 111630 111630 111630 111630 111630 111630 111630 111630 111630 111630 111630 111630 111630 111630 111630 111630 111630 111630 111630 111630 111630 111630 111630 111630 111630 111630 111630 111630 111630 111630 1116...

output:

299655171854700

result:

ok "299655171854700"

Test #28:

score: 0
Accepted
time: 240ms
memory: 120180kb

input:

1
300000
22911 22911 22911 22911 22911 22911 22911 22911 22911 22911 22911 22911 22911 22911 22911 22911 22911 22911 22911 22911 22911 22911 22911 22911 22911 22911 22911 22911 22911 22911 22911 22911 22911 22911 22911 22911 22911 22911 22911 22911 22911 22911 22911 22911 22911 22911 22911 22911 229...

output:

298955540767000

result:

ok "298955540767000"

Test #29:

score: 0
Accepted
time: 214ms
memory: 119308kb

input:

1
300000
244443 244443 244443 244443 244443 244443 244443 244443 244443 244443 244443 244443 244443 244443 244443 244443 244443 244443 244443 244443 244443 244443 244443 244443 244443 244443 244443 244443 244443 244443 244443 244443 244443 244443 244443 244443 244443 244443 244443 244443 244443 2444...

output:

296956675350000

result:

ok "296956675350000"

Test #30:

score: 0
Accepted
time: 189ms
memory: 119216kb

input:

1
300000
133082 159736 133082 133064 133082 159736 133082 278845 133082 159736 133082 133064 133082 159736 133082 60336 133082 159736 133082 133064 133082 159736 133082 278845 133082 159736 133082 133064 133082 159736 133082 76986 133082 159736 133082 133064 133082 159736 133082 278845 133082 159736...

output:

0

result:

ok "0"

Test #31:

score: 0
Accepted
time: 186ms
memory: 120632kb

input:

1
300000
80541 80541 286446 286446 265590 265590 286446 286446 153241 153241 286446 286446 265590 265590 286446 286446 81737 81737 286446 286446 265590 265590 286446 286446 153241 153241 286446 286446 265590 265590 286446 286446 248199 248199 286446 286446 265590 265590 286446 286446 153241 153241 2...

output:

149978071800000

result:

ok "149978071800000"

Test #32:

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

input:

1
300000
237786 237786 237786 98612 98612 98612 237786 237786 237786 295644 295644 295644 237786 237786 237786 98612 98612 98612 237786 237786 237786 262303 262303 262303 237786 237786 237786 98612 98612 98612 237786 237786 237786 295644 295644 295644 237786 237786 237786 98612 98612 98612 237786 23...

output:

199970121000000

result:

ok "199970121000000"

Test #33:

score: 0
Accepted
time: 202ms
memory: 120464kb

input:

1
300000
75431 75431 75431 75431 260394 260394 260394 260394 75431 75431 75431 75431 199712 199712 199712 199712 75431 75431 75431 75431 260394 260394 260394 260394 75431 75431 75431 75431 28217 28217 28217 28217 75431 75431 75431 75431 260394 260394 260394 260394 75431 75431 75431 75431 199712 1997...

output:

224973738075000

result:

ok "224973738075000"

Test #34:

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

input:

1
300000
130589 130589 130589 130589 130589 268282 268282 268282 268282 268282 130589 130589 130589 130589 130589 137710 137710 137710 137710 137710 130589 130589 130589 130589 130589 268282 268282 268282 268282 268282 130589 130589 130589 130589 130589 93460 93460 93460 93460 93460 130589 130589 13...

output:

239972299440000

result:

ok "239972299440000"

Test #35:

score: 0
Accepted
time: 201ms
memory: 121716kb

input:

1
300000
231516 231516 231516 231516 231516 231516 209411 209411 209411 209411 209411 209411 289124 289124 289124 289124 289124 289124 209411 209411 209411 209411 209411 209411 43277 43277 43277 43277 43277 43277 209411 209411 209411 209411 209411 209411 289124 289124 289124 289124 289124 289124 209...

output:

249974555500000

result:

ok "249974555500000"

Test #36:

score: 0
Accepted
time: 198ms
memory: 120264kb

input:

1
300000
33475 33475 33475 33475 33475 33475 33475 46474 46474 46474 46474 46474 46474 46474 33475 33475 33475 33475 33475 33475 33475 58205 58205 58205 58205 58205 58205 58205 33475 33475 33475 33475 33475 33475 33475 46474 46474 46474 46474 46474 46474 46474 33475 33475 33475 33475 33475 33475 334...

output:

257109963192504

result:

ok "257109963192504"

Test #37:

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

input:

1
300000
118215 118215 118215 118215 118215 118215 118215 118215 285873 285873 285873 285873 285873 285873 285873 285873 57135 57135 57135 57135 57135 57135 57135 57135 285873 285873 285873 285873 285873 285873 285873 285873 214330 214330 214330 214330 214330 214330 214330 214330 285873 285873 28587...

output:

262466350987500

result:

ok "262466350987500"

Test #38:

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

input:

1
300000
38535 38535 38535 105156 105156 105156 105156 105156 105156 105156 105156 105156 62851 62851 62851 62851 62851 62851 62851 62851 62851 105156 105156 105156 105156 105156 105156 105156 105156 105156 38535 38535 38535 38535 38535 38535 38535 38535 38535 105156 105156 105156 105156 105156 1051...

output:

266637774056719

result:

ok "266637774056719"

Test #39:

score: 0
Accepted
time: 222ms
memory: 121468kb

input:

1
300000
167645 167645 167645 167645 167645 167645 167645 167645 167645 167645 97206 97206 97206 97206 97206 97206 97206 97206 97206 97206 167645 167645 167645 167645 167645 167645 167645 167645 167645 167645 71285 71285 71285 71285 71285 71285 71285 71285 71285 71285 167645 167645 167645 167645 167...

output:

269970944490000

result:

ok "269970944490000"

Test #40:

score: 0
Accepted
time: 253ms
memory: 121556kb

input:

1
300000
213095 285340 285340 213095 285340 213095 285340 285340 213095 285340 213095 285340 285340 213095 285340 285340 213095 285340 213095 285340 285340 213095 285340 285340 213095 285340 213095 285340 285340 213095 285340 213095 285340 285340 213095 285340 285340 213095 285340 213095 285340 2853...

output:

299956228832791

result:

ok "299956228832791"

Test #41:

score: 0
Accepted
time: 257ms
memory: 120328kb

input:

1
300000
53858 81447 53858 53858 53858 81447 53858 53858 81447 53858 53858 81447 53858 53858 53858 81447 53858 53858 81447 53858 53858 53858 81447 53858 53858 81447 53858 53858 53858 81447 53858 53858 81447 53858 53858 81447 53858 53858 53858 81447 53858 53858 81447 53858 53858 53858 81447 53858 538...

output:

299954085569840

result:

ok "299954085569840"

Test #42:

score: 0
Accepted
time: 251ms
memory: 120452kb

input:

1
300000
268697 22447 268697 268697 268697 268697 22447 268697 268697 268697 22447 268697 268697 268697 22447 268697 268697 268697 22447 268697 268697 268697 268697 22447 268697 268697 268697 22447 268697 268697 268697 22447 268697 268697 268697 268697 22447 268697 268697 268697 22447 268697 268697 ...

output:

299954783722278

result:

ok "299954783722278"

Test #43:

score: 0
Accepted
time: 243ms
memory: 120696kb

input:

1
300000
272918 57930 272918 59357 272918 57930 272918 272918 57930 272918 59357 272918 57930 272918 57930 272918 59357 272918 57930 272918 272918 57930 272918 59357 272918 57930 272918 59357 272918 57930 272918 272918 57930 272918 59357 272918 57930 272918 57930 272918 59357 272918 57930 272918 272...

output:

299953742883715

result:

ok "299953742883715"

Test #44:

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

input:

1
300000
80352 71019 71019 72078 71019 72078 80352 71019 71019 72078 71019 72078 80352 71019 71019 72078 80352 71019 71019 72078 71019 72078 80352 71019 71019 72078 71019 72078 80352 71019 71019 72078 80352 71019 71019 72078 71019 72078 80352 71019 71019 72078 80352 71019 71019 72078 71019 72078 803...

output:

10199343133824

result:

ok "10199343133824"

Test #45:

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

input:

1
300000
32766 276814 32766 32766 281628 32766 276814 32766 281628 32766 276814 32766 32766 281628 32766 276814 32766 281628 32766 32766 281628 32766 276814 32766 281628 32766 276814 32766 32766 281628 32766 276814 32766 281628 32766 32766 281628 32766 276814 32766 32766 281628 32766 276814 32766 28...

output:

17988937001535

result:

ok "17988937001535"

Test #46:

score: 0
Accepted
time: 210ms
memory: 120368kb

input:

1
300000
93379 38368 38368 93379 38368 93379 93379 38368 38368 93379 93379 38368 93379 38368 38368 93379 38368 93379 93379 38368 93379 38368 38368 93379 93379 38368 38368 93379 38368 93379 93379 38368 93379 38368 38368 93379 38368 93379 93379 38368 38368 93379 93379 38368 93379 38368 38368 93379 383...

output:

8420853691549

result:

ok "8420853691549"

Test #47:

score: 0
Accepted
time: 260ms
memory: 120364kb

input:

1
300000
108749 244778 244778 108749 244778 108749 244778 244778 108749 244778 108749 108749 244778 108749 244778 244778 108749 244778 108749 244778 244778 108749 244778 108749 108749 244778 244778 108749 244778 108749 244778 244778 108749 244778 108749 108749 244778 108749 244778 244778 108749 2447...

output:

299954801363244

result:

ok "299954801363244"

Test #48:

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

input:

1
300000
42547 42547 42547 42547 42547 42547 269632 269632 269632 269632 269632 269632 269632 269632 269632 269632 269632 269632 269632 269632 269632 269632 96297 96297 96297 96297 96297 96297 96297 96297 96297 96297 96297 96297 96297 96297 96297 96297 96297 96297 96297 96297 96297 96297 96297 96297...

output:

21144522931597

result:

ok "21144522931597"

Test #49:

score: 0
Accepted
time: 187ms
memory: 114964kb

input:

3
100000
23132 5198 91169 5198 91169 5198 91169 5198 91169 5198 91169 5198 91169 5198 91169 15754 42440 93757 5930 32495 65889 42440 93757 5930 32495 65889 42440 93757 5930 32495 65889 42440 93757 5930 32495 65889 42440 93757 5930 32495 65889 42440 93757 5930 32495 65889 15754 42440 93757 5930 32495...

output:

99923449286005
410524909392
672324897904

result:

ok 3 tokens

Test #50:

score: 0
Accepted
time: 147ms
memory: 112412kb

input:

10
30000
9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9095 9...

output:

776128461128
3360270671312
29975565185274
642028790769
1886891992186
29968582010269
29961619127504
1125273148920
29951560476846
2012998776624

result:

ok 10 tokens

Test #51:

score: 0
Accepted
time: 129ms
memory: 107108kb

input:

30
10000
3685 2420 3791 6235 3791 6235 3791 6235 3791 6235 3791 6235 2420 3791 6235 3791 6235 3791 6235 3791 6235 3791 6235 2420 3791 6235 3791 6235 3791 6235 3791 6235 3791 6235 2420 3791 6235 3791 6235 3791 6235 3791 6235 3791 6235 3685 2420 3791 6235 3791 6235 3791 6235 3791 6235 3791 6235 2420 3...

output:

106328009328
974564482558
825899207594
9982952032169
9982953823233
148344557107
361718885463
262423220882
627745941196
1506819290027
737140096192
547151831126
9993950283877
605444031441
9995951932152
838571077016
9977952391652
9972953259748
480440384366
1255418478866
381263981183
398944681122
146699...

result:

ok 30 tokens

Test #52:

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

input:

100
3000
1660 758 758 758 758 758 758 1660 758 758 758 758 758 758 1660 758 758 758 758 758 758 1660 758 758 758 758 758 758 1660 758 758 758 758 758 758 1660 758 758 758 758 758 758 2658 2263 303 303 303 303 303 303 303 303 303 303 303 303 2263 303 303 303 303 303 303 303 303 303 303 303 303 2263 3...

output:

520690053094
486468349104
2992995569217
331754709765
3232710615
2993995768286
2989996052839
2982995879432
2980995746770
2990995624072
449546015482
2975995941401
2980995680821
429240487464
2996995523211
166981425525
438088157857
2992995711497
2976995800141
2982996256894
115823214628
143308235106
2993...

result:

ok 100 tokens

Test #53:

score: 0
Accepted
time: 107ms
memory: 98820kb

input:

300
1000
919 763 301 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369...

output:

992999635781
1773325156
981999589972
2896682278
983999537857
983999549344
26508668632
2856788254
985999567996
395061218168
989999566895
100401356930
990999514684
89426084422
984999546732
21658940174
1344324908
983999597489
994999534995
2650359006
982999560914
258327893357
995999504241
10187858941
99...

result:

ok 300 tokens

Test #54:

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

input:

1000
300
164 93 164 93 164 93 164 93 164 93 164 93 164 93 164 93 164 93 164 93 164 93 164 93 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 88 88 88 88 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 88 88 88 88 72 72 72 72 72 72 72 72 72 72 72 72 72 ...

output:

39897457738
18749378775
5561880188
76264361795
21724600489
63769826130
297999955878
293999958360
282999965757
65794260273
16191876250
284999961492
36312627923
296999958163
38908157042
12561832496
1617788650
294999958785
296999956665
296999956686
9414586322
19587359768
85595113546
283999961463
290999...

result:

ok 1000 tokens

Test #55:

score: 0
Accepted
time: 89ms
memory: 92352kb

input:

3000
100
89 93 39 96 8 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 24 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 24 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 24 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 24 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 9...

output:

92999995658
90999996853
23489798514
2819994990
97999995318
9213451631
93999995696
9292716178
96999995272
4515725492
3592593150
3420975512
97999995232
97999995243
11330049220
29974842064
18817760332
94999995367
1515203714
97999995759
91999996736
98999995161
95999995359
11940102612
3102482257
96999995...

result:

ok 3000 tokens

Test #56:

score: 0
Accepted
time: 70ms
memory: 87680kb

input:

10000
30
6 20 3 6 20 3 6 20 3 6 20 3 6 20 3 6 20 3 6 20 3 6 20 3 6 20 3 6 20 3
448799041 44060015 27122642 696944844 913311800 830103706 186575729 352636172 19135824 723113036 671187091 861285552 790713908 413162540 679145983
30
25 15 19 5 5 25 5 25 5 25 5 25 5 25 5 25 8 5 25 5 25 5 25 5 25 5 25 5 2...

output:

564588156
9197157552
2824049904
1160352352
2614868919
3444150714
4550359251
4452326457
23999999736
1433209188
28999999606
4126784157
143771473
1629112339
6178961943
1464171982
28999999601
3159619649
3787004888
5531785027
23999999760
26999999657
28999999595
26999999642
24999999751
27999999712
2799999...

result:

ok 10000 tokens