QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#152753#440. 时代的眼泪c20231020100 ✓2102ms116052kbC++239.9kb2023-08-28 19:29:412023-08-28 19:29:42

Judging History

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

  • [2023-08-28 19:29:42]
  • 评测
  • 测评结果:100
  • 用时:2102ms
  • 内存:116052kb
  • [2023-08-28 19:29:41]
  • 提交

answer

/*
膜拜传奇特级宗师 Afterglow 大神儿
今天在 florr 首页称您为大夏尊贵的大名儿
一股敬佩之情油生然而
您在 florr 为国争光,扬我大夏威名
向您献上最真挚的膜拜!!!
膜拜传奇特级宗师 Afterglow 大神儿,今,一,您,扬。向!
膜拜传奇特级宗师 Afterglow 大神儿,今,一,您,扬。向!
膜拜传奇特级宗师 Afterglow 大神儿,今,一,您,扬。向!
*/
/*
          _____                    _____                     _____                    _____
         /\    \                  /\    \                   /\    \                  /\    \
        /  \    \                /  \    \                 /  \____\                /  \    \
        \   \    \              /    \    \               /   /    /                \   \    \
         \   \    \            /      \    \             /   /    /                  \   \    \
          \   \    \          /   /\   \    \           /   /____/                    \   \    \
           \   \    \        /   /  \   \    \         /    |    |                     \   \    \
            \   \    \      /   /    \   \    \       /     |    |                      \   \    \
             \   \    \    /   /    / \   \    \     /      |    |                       \   \    \
              \   \    \  /   /    /   \   \    \   /       |____|__ _____                \   \    \
_______________\   \____\/   /____/     \   \    \ /   /|            \    \ _______________\   \____\
\                  /    /\   \    \      \   \    \\  / |    _________\____\\                  /    /
 \    ____________/____/  \   \    \      \   \____\\/__|   |    |           \    ____________/____/
  \   \    \               \   \    \     |   |    |    |   |    |            \   \    \
   \   \    \               \   \    \    |   |    |    |   |    |             \   \    \
    \   \    \               \   \    \   |   |____|    |   |    |              \   \    \
     \   \    \               \   \    \  /   /    /    \   |    |               \   \    \
      \   \    \               \   \    \/   /    /      \  |    |                \   \    \
       \   \____\               \   \___/   /    /        \ |    |                 \   \____\
        \  /    /                \         /    /          \|    |                  \  /    /
         \/____/                  \_______/____/            \____|                   \/____/
*/
#define poj
#define zcz
#ifdef poj
//C++
#include<iomanip>
#include<iostream>
//C
#include<cassert>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
//STL
#include<algorithm>
#include<bitset>
#include<functional>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>
//C++11
#if __cplusplus>=201103L
#include<chrono>
#include<random>
#include<unordered_set>
#include<unordered_map>
#endif
#else
#include<bits/stdc++.h>
#endif
using namespace std;
#ifdef zcz
class fastin{
	private:
#ifdef poj
	static const int MAXBF=1<<20;
#else
	const int MAXBF=1<<27;
#endif
	FILE *inf;
	char *inbuf,*inst,*ined;
	inline char _getchar(){
		if(inst==ined)inst=inbuf,ined=inbuf+fread(inbuf,1,MAXBF,inf);
		return inst==ined?EOF:*inst++;
	}
	public:
	fastin(FILE*_inf=stdin){
		inbuf=new char[MAXBF],inf=_inf,inst=inbuf,ined=inbuf;
	}
	~fastin(){delete inbuf;}
	template<typename Int> fastin&operator>>(Int &n){
		static char c;
		Int t=1;
		while((c=_getchar())<'0'||c>'9')if(c=='-')t=-1;
		n=(c^48);
		while((c=_getchar())>='0'&&c<='9')n=n*10+(c^48);
		n*=t;
		return *this;
	}
	fastin&operator>>(char&c){
		while((c=_getchar())<'!'||c>'~');
		return *this;
	}
	fastin&operator>>(char*s){
		int t=0;
		static char c;
		while((c=_getchar())==' '||c=='\n');
		s[t++]=c;
		while((c=_getchar())>='!'&&c<='~')s[t++]=c;
		s[t]='\0';
		return *this;
	}
}fi;
class fastout{
	private:
#ifdef poj
	static const int MAXBF=1<<20;
#else
	const int MAXBF=1<<27;
#endif
	FILE *ouf;
	char *oubuf,*oust,*oued;
	inline void _flush(){fwrite(oubuf,1,oued-oust,ouf);oued=oust;}
	inline void _putchar(char c){
		if(oued==oust+MAXBF)_flush(),oued=oubuf;
		*oued++=c;
		#ifdef local
		_flush();
		#endif
	}
	public:
	fastout(FILE*_ouf=stdout){
		oubuf=new char[MAXBF],ouf=_ouf,oust=oubuf,oued=oubuf;
	}
	~fastout(){_flush();delete oubuf;}
	template<typename Int> fastout&operator<<(Int n){
		if(n<0)_putchar('-'),n=-n;
		static char S[20];
		int t=0;
		do{S[t++]='0'+n%10,n/=10;}while(n);
		for(int i=0;i<t;++i)_putchar(S[t-i-1]);
		return *this;
	}
	fastout&operator<<(char c){_putchar(c);return *this;}
	fastout&operator<<(char*s){
		for(int i=0;s[i];++i)_putchar(s[i]);
		return *this;
	}
	fastout&operator<<(const char*s){
		for(int i=0;s[i];++i)_putchar(s[i]);
		return *this;
	}
}fo;
#define cin fi
#define cout fo
#else
#define czc ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#endif
#define mod7 1000000007
#define mod9 998244353
#define ll long long
#define isinf 0x3f3f3f3f
#define ilinf 0x7fffffff
#define lsinf 0x3f3f3f3f3f3f3f3f
#define llinf 0x7fffffffffffffff
#define pii pair<int,int>
#define fr first
#define sc second
#define next ___
#define pb push_back
#define N 100010
#define M 200010
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b,c) for(int i=(a);i<=(b);i+=c)
#define Per(i,a,b,c) for(int i=(a);i>=(b);i-=c)
#define Gra(i) for(int i=h[x];i;i=next[i])
typedef int arr[N];
typedef int arm[M];
typedef ll arl[N];
typedef ll alm[M];
typedef double ard[N];
typedef double adm[M];
namespace modint{
	template<typename Int,Int mod>
	struct modint{
		Int v;
		modint(){v=0;}
		modint(Int a){v=a;}
		bool operator==(modint a){return v==a.v;}
		bool operator!=(modint a){return v!=a.v;}
		bool operator<(modint a){return v<a.v;}
		bool operator>(modint a){return v>a.v;}
		bool operator<=(modint a){return v<=a.v;}
		bool operator>=(modint a){return v>=a.v;}
		bool operator==(Int a){return v==a;}
		bool operator!=(Int a){return v!=a;}
		bool operator<(Int a){return v<a;}
		bool operator>(Int a){return v>a;}
		bool operator<=(Int a){return v<=a;}
		bool operator>=(Int a){return v>=a;}
		modint operator+(modint a){return v>mod-a.v?v-mod+a.v:v+a.v;}
		modint operator-(modint a){return v>a.v?v-a.v:v+mod-a.v;}
		modint operator*(modint a){return v*a.v%mod;}
		modint operator+=(modint a){*this=*this+a;return *this;}
		modint operator-=(modint a){*this=*this-a;return *this;}
		modint operator*=(modint a){*this=*this*a;return *this;}
		modint qpow(modint a,Int b){
			modint r(1);
			for(;b;b>>=1,a*=a)if(b&1)r*=a;
			return r;
		}
		modint operator/(modint a){return qpow(a,mod-2)*v;}
		modint operator/=(modint a){*this=*this/a;return *this;}
		modint&operator++(){*this=*this+1;return *this;}
		modint&operator--(){*this=*this-1;return *this;}
		const modint operator++(int){modint r=*this;++*this;return r;}
		const modint operator--(int){modint r=*this;--*this;return r;}
		#ifdef cout
		friend fastout&operator<<(fastout&out,modint n){out<<n.v;return out;}
		#else
		friend ostream&operator<<(ostream&out,modint n){out<<n.v;return out;}
		#endif
	};
	typedef modint<long long,1000000007> int7;
	typedef modint<long long,998244353> int9;
}
using namespace modint;
int n,m,q,l,L[320],R[320];
arr a,b,id,e;
arm as;
alm ans;
ll c[320][320],d[320];
struct G{
	int x1,y1,x2,y2;
}s[M];
struct H{
	int i,l,r,v;
};
struct I{
	arr a;
	int b[320];
	void add(int x){
		For(i,x,R[id[x]]){
			++a[i];
		}
		For(i,id[x]+1,l){
			++b[i];
		}
	}
	int ask(int x){
		return a[x]+b[id[x]];
	}
}f;
vector<H>t[N];
vector<pii>u[N];
int bf(int p,int x1,int y1,int x2,int y2){
	if(y1-x1>45){
		int mid=(x1+y1)>>1;
		t[x1-1].pb({p,mid+1,y1,-1});
		t[mid].pb({p,mid+1,y1,1});
		return bf(p,x1,mid,x2,y2)+bf(p,mid+1,y1,x2,y2);
	}
	int ans=0;
	For(i,x1,y1){
		if(a[i]>=x2&&a[i]<=y2){
			For(j,i+1,y1){
				ans+=(a[i]<a[j]&&a[j]<=y2);
			}
		}
	}
	return ans;
}
void solve(){
	cin>>n>>m;
	q=sqrt(n);
	l=(n-1)/q+1;
	For(i,1,l){
		L[i]=R[i-1]+1;
		R[i]=min(i*q,n);
	}
	For(i,1,n){
		cin>>a[i];
		b[a[i]]=i;
		id[i]=(i-1)/q+1;
	}
	For(i,1,m){
		cin>>s[i].x1>>s[i].y1>>s[i].x2>>s[i].y2;
		int bl=id[s[i].x1],br=id[s[i].y1];
		if(bl==br){
			ans[i]=bf(i,s[i].x1,s[i].y1,s[i].x2,s[i].y2);
			continue;
		}
		ans[i]=bf(i,s[i].x1,R[bl],s[i].x2,s[i].y2)+bf(i,L[br],s[i].y1,s[i].x2,s[i].y2);
		t[s[i].x1-1].pb({i,L[br],s[i].y1,-1});
		t[R[br-1]].pb({i,L[br],s[i].y1,1});
		if(br-bl<=1)continue;
		t[R[bl]].pb({i,s[i].x1,R[bl],-1});
		t[R[br-1]].pb({i,s[i].x1,R[bl],1});
		u[s[i].x2-1].pb({i,-1});
		u[s[i].y2].pb({i,1});
	}
	For(i,1,n){
		f.add(a[i]);
		for(H j:t[i]){
			For(k,j.l,j.r){
				int x2=s[j.i].x2,y2=s[j.i].y2;
				if(a[k]<x2||a[k]>y2){
					continue;
				}
				if(k>i){
					y2=min(y2,a[k]-1);
				}else{
					x2=max(x2,a[k]+1);
				}
				ans[j.i]+=(f.ask(y2)-f.ask(x2-1))*j.v;
			}
		}
	}
	For(i,1,n){
		int j=b[i],k=0;
		++d[id[j]];
		Per(l,id[j]-1,1,1){
			k+=d[l];
			c[l][id[j]]+=k;
		}
		for(pii x:u[i]){
			int l=id[s[x.fr].x1]+1,r=id[s[x.fr].y1]-1;
			For(o,l+1,r){
				ans[x.fr]+=c[l][o]*x.sc;
			}
		}
	}
	For(i,1,l){
		int lp=L[i],rp=R[i];
		For(j,1,n){
			e[j]=e[j-1]+(b[j]>=lp&&b[j]<=rp);
		}
		memset(c,0,sizeof(c));
		For(j,lp,rp){
			For(k,j+1,rp){
				c[e[a[j]]][e[a[k]]]+=a[j]<=a[k];
			}
		}
		Per(j,e[n],1,1){
			For(k,j,e[n]){
				c[j][k]+=c[j+1][k]+c[j][k-1]-c[j+1][k-1];
			}
		}
		For(j,1,m){
			if(id[s[j].x1]<i&&i<id[s[j].y1]){
				ans[j]+=c[e[s[j].x2-1]+1][e[s[j].y2]]-1ll*as[j]*(e[s[j].y2]-e[s[j].x2-1]);
				as[j]+=e[s[j].x2-1];
			}
		}
	}
	For(i,1,m){
		cout<<ans[i]<<'\n';
	}
	return;
}
int main(){
	#ifndef zcz
	czc;
	#endif
	#ifdef local
//	freopen("tears7.in","r",stdin);
//	freopen("tears7.out","w",stdout);
	int t1=clock();
	#endif
	int t=1;
	while(t--)solve();
	#ifdef local
	cerr<<clock()-t1;
	#endif
	return 0;
}

详细

Test #1:

score: 4
Accepted
time: 3ms
memory: 10808kb

input:

10 10
7 6 3 5 9 1 10 8 4 2
2 7 6 8
2 5 4 10
6 9 8 9
6 9 7 9
4 5 6 7
4 9 8 8
2 9 3 5
3 7 4 8
4 6 1 10
6 7 8 9

output:

0
2
0
0
0
0
2
0
1
0

result:

ok 10 lines

Test #2:

score: 4
Accepted
time: 4ms
memory: 16224kb

input:

10 10
3 6 8 10 7 9 4 1 5 2
1 10 2 8
1 9 4 9
5 7 6 10
2 2 5 5
7 9 5 8
2 6 3 5
1 1 4 8
4 9 1 5
5 8 4 7
8 10 5 8

output:

8
6
1
0
0
0
0
2
0
0

result:

ok 10 lines

Test #3:

score: 4
Accepted
time: 1ms
memory: 16172kb

input:

10 10
5 4 7 1 10 9 6 2 3 8
2 3 3 9
5 8 7 8
8 8 1 8
6 8 7 8
3 7 3 6
2 10 5 5
3 4 5 10
4 10 4 5
6 9 2 4
3 4 4 6

output:

1
0
0
0
0
0
0
0
1
0

result:

ok 10 lines

Test #4:

score: 4
Accepted
time: 9ms
memory: 13604kb

input:

3000 3000
275 74 2540 1606 1717 239 793 2424 1923 2498 2871 870 2448 1189 2987 2962 42 2216 2876 730 2139 1609 1380 1438 1616 1186 1213 1362 2904 1672 2271 2857 1163 2026 2333 2977 2497 2082 2819 1120 1932 1539 2798 2006 1389 539 2168 2676 2742 1316 2899 874 2453 2672 15 2143 1399 160 630 138 1483 5...

output:

150753
25868
290
124866
897067
724
0
70078
184626
0
6
156
46367
154700
115976
272420
23594
75019
9790
51
27446
1517
36710
4015
19999
14
55774
109476
2948
47562
48916
5857
71029
16843
73224
32910
90101
90
5664
342
130
368886
441
2063
169675
55810
35507
27901
278
5988
2193
11909
50642
1672
54247
25837...

result:

ok 3000 lines

Test #5:

score: 4
Accepted
time: 13ms
memory: 16664kb

input:

4000 4000
1813 3333 1943 2840 1554 1070 1167 2683 3987 229 1883 1490 1031 2800 3882 2316 2640 1411 2032 2675 2093 401 3534 3627 2982 143 1080 1259 771 658 306 1580 2154 3482 2984 3551 215 2009 170 3377 932 2335 1368 2788 1191 3006 3223 3060 3924 2075 372 481 797 295 3465 2079 714 3139 33 1524 457 15...

output:

101368
695
338802
3587
16990
23
37325
433
59932
7569
87
236695
9292
625
214
43196
11570
73267
34835
8
43764
227721
5821
12737
14
2073
19379
2
1589
585
246196
39250
1085
77766
1860
31184
106892
5890
41848
3393
1713
21877
152927
42253
120551
365718
4
2525
66256
3323
2196
14786
2646
165
2349
183925
102...

result:

ok 4000 lines

Test #6:

score: 4
Accepted
time: 11ms
memory: 16912kb

input:

5000 5000
4584 3973 1352 4671 419 4060 2422 1887 1113 4149 3583 511 2168 3996 963 870 1871 1972 2974 3771 2725 2276 4578 194 4600 114 4297 1714 3530 3353 2904 4842 366 744 116 1785 3646 2473 1421 4245 1366 4483 1555 4595 1179 1394 3648 3066 4024 1935 2263 4237 4268 29 2148 4647 4515 2135 4131 4589 3...

output:

4780
792
124699
64326
8561
164490
7301
24121
36709
32759
3204
249940
176215
134871
7241
65159
28557
1
0
9989
216642
2986
375
1406776
639
115857
14
23645
125671
4625
407343
131116
1390
1996578
5150
23
5959
6715
2562
250255
640
20942
6382
3134
6218
461
0
22
19913
35924
176308
4351
235171
30928
79
2003...

result:

ok 5000 lines

Test #7:

score: 4
Accepted
time: 178ms
memory: 29576kb

input:

25000 50000
17933 12647 4126 561 20565 17721 3237 20956 23810 15182 1371 1964 19155 23873 16313 20143 23077 15413 14837 23101 15220 2217 22784 2221 17865 11528 9072 23426 15666 9562 23566 7278 11913 6636 10360 8741 13378 13274 515 17382 15017 11838 24731 10977 643 23193 24811 18852 20273 17879 16016...

output:

4718718
63789917
38019203
3478646
10434678
8411216
16384465
3347278
1046457
117450666
10512079
65064601
1942523
36670336
14927967
64208380
1401054
45566293
352016
7364184
34900823
26854299
279153
29351592
2484422
39769235
21811702
21217156
8123867
2807588
41928739
6779645
47354518
107544652
25203384...

result:

ok 50000 lines

Test #8:

score: 4
Accepted
time: 515ms
memory: 51212kb

input:

50000 100000
34190 30883 11333 45339 39327 7782 31720 17826 49088 48395 26423 1963 15006 13296 31887 39411 41575 47505 26979 39758 29082 5053 35619 36746 28511 45672 37295 30506 46420 36833 48283 34088 32552 48561 22638 32469 22093 49328 21194 8280 24202 26909 49400 11332 12274 29937 15451 42485 486...

output:

37863428
1295597
29943678
126664876
3911440
338059817
450026960
38777862
1118962
152246
24709849
163084008
10674162
430721
55211011
35929751
17199958
409346985
158519381
7285528
41865472
398734305
447907721
93208778
20852920
100855887
178457289
88021209
238975826
117706868
2673284
660447
171625695
2...

result:

ok 100000 lines

Test #9:

score: 4
Accepted
time: 985ms
memory: 83140kb

input:

75000 150000
30149 54180 3798 34212 67897 28067 50060 44816 38037 27530 70405 68069 16326 14256 66092 36541 72536 72996 63812 65847 23781 72137 39834 29700 11212 11156 41911 9140 57560 21211 39159 53063 71051 45303 39914 9566 32134 69835 24071 7055 58777 70053 69284 73900 53302 28963 74142 46429 792...

output:

174259304
3348579
28497163
339191113
39371728
185218292
33086871
70516557
976407591
41958758
160694969
22797960
570235465
27397379
410554
5620782
4203869
12694401
17246305
1715255
72166453
493948656
9647789
218033623
313880736
21022591
25608005
525294519
286016745
90693329
33580996
37515799
22553874...

result:

ok 150000 lines

Test #10:

score: 4
Accepted
time: 1580ms
memory: 114512kb

input:

100000 200000
47534 82358 90198 90311 86971 78138 57685 92820 95572 82397 45779 74859 67319 89881 76297 71344 68227 55217 75262 94126 96422 87581 94223 87931 88679 42475 75545 30649 91491 96694 85088 94656 24494 69871 78199 69331 99352 18668 74574 78408 79693 61591 99297 49169 83870 93128 88383 6998...

output:

602065448
735033221
1362516482
70624069
61374041
141022179
551054645
6086443
30209985
84950365
5406301
145290747
294740513
380446592
549845670
747200677
656638810
355813396
7569397
42291643
235788343
13866777
5764511
903571789
7281037
928447043
572529173
731423589
1579439
1883416560
1092532513
23763...

result:

ok 200000 lines

Test #11:

score: 4
Accepted
time: 331ms
memory: 35304kb

input:

60000 120000
55906 54576 34973 43550 27137 16914 48320 13154 45299 33624 22807 18737 45915 39093 25737 38507 198 31416 35416 59392 20151 4701 42665 52467 45908 27531 16407 38855 37382 19685 35572 43031 27903 49191 25509 17411 7293 20341 23414 34224 22012 28138 53083 57765 32612 44127 45575 45576 257...

output:

0
0
0
0
19
1
0
0
5
0
1378
4
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
421
0
0
0
0
0
0
0
127
0
0
0
1494
0
0
16
0
0
0
0
0
0
3
0
0
0
0
0
0
0
0
2
0
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
6
0
0
0
0
214
16
0
11
0
0
0
6899
3
0
0
0
0
0
2
1
0
0
9
0
0
0
0
0
0
0
0
0
0
0
13
0
0
0
9
0
0
0
0
0
0
1151
0
0
0
0
0
0
0
3
0
0
0
562
0
0
0...

result:

ok 120000 lines

Test #12:

score: 4
Accepted
time: 546ms
memory: 45044kb

input:

80000 160000
10198 4604 1327 11423 66261 30105 42184 30866 47473 1330 31892 60909 62567 71904 12724 46276 28865 71787 44630 47976 76446 9910 75574 9540 69676 75531 10411 62125 70843 43627 44229 49730 45411 48262 35241 49880 20876 57304 3639 23968 6048 34167 59093 37783 50369 62696 31078 16927 47356 ...

output:

0
0
0
0
0
0
0
1
0
0
0
0
0
0
7
0
0
0
0
0
0
6
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
67
0
0
0
0
0
12
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
3
0
0
0
0
0
11
0
0
0
0
0
0
0
0
0
0
0
3
0
0
0
0
0
0
752
0
28
1
13383
0
0
0
0
0
0
0
0
0
0
1
0
0
0
6
0
0
0
22
0
0
0
0
24
0
0
0
0
3
0
0
0
0
0
0
1
0
4
0
796
0
0
0
...

result:

ok 160000 lines

Test #13:

score: 4
Accepted
time: 578ms
memory: 59356kb

input:

100000 200000
3001 2999 2754 2995 2994 4 2992 2990 2988 2987 2986 2984 2983 11801 13 14 15 2977 2976 16 88077 19 2973 2971 24674 53095 2969 2968 80415 22 2965 2964 2962 2960 2958 2957 2956 2955 2954 2951 28 29 30 33 34 35 2946 2945 36 38 39 2942 2941 42 44 45 2939 2938 17182 49 2934 2933 50 52 24901...

output:

1420333
0
1420333
0
1420333
0
1420333
0
1417926
0
1415520
0
1415329
0
1415329
0
1415329
0
1415329
0
1415329
0
1415329
0
1412930
0
1410532
0
1410532
0
1410532
0
1410532
0
1410532
0
1410532
0
1410532
0
1410532
0
1410532
0
1408142
0
1408142
0
1408142
0
1408142
0
1408142
0
1405757
0
1405757
0
1405757
0
...

result:

ok 200000 lines

Test #14:

score: 4
Accepted
time: 54ms
memory: 20860kb

input:

20000 19260
8075 16966 10721 18323 13760 16546 8500 4931 2710 4070 4939 3934 442 16813 2702 6006 12079 19539 6984 5646 3024 15789 4508 11676 15036 16563 824 10150 18948 6418 6421 9916 11984 11580 17053 683 14236 17896 11307 4769 10225 19109 15416 16258 14897 5795 14886 13848 2561 7846 13555 2988 150...

output:

73953667
77869923
81007411
78560413
81152054
73424881
75246642
77194299
73895423
73931218
75549782
81405290
76740635
72321985
82655727
86665639
76896933
76614731
75254280
76841820
80663242
83856274
86414220
88835620
75559849
77274841
78020378
71502558
79346696
93181550
73222310
83916497
70693808
844...

result:

ok 19260 lines

Test #15:

score: 4
Accepted
time: 373ms
memory: 30792kb

input:

30000 60000
18100 17984 29616 26532 16351 25306 28940 17968 12149 21623 10913 25728 7504 1694 18649 20697 12374 28510 28482 24090 23186 26948 24342 8516 28375 24474 26716 10580 18582 25290 29675 5255 22335 21818 28936 918 11068 8231 14805 25816 29904 26304 12336 12440 28867 27898 20999 18451 17788 1...

output:

5616635
268767
67149
33831788
24760
5654768
135868
3952186
33516
34593746
748958
628513
6333725
2000117
2050974
96427
865572
15180825
42188
1025674
5064786
4930417
9418480
5267
68563477
225104
17384
1891957
175658
2589505
99923
17289
67815
45448
3736168
890908
32179606
5167265
210433
4716038
187108
...

result:

ok 60000 lines

Test #16:

score: 4
Accepted
time: 601ms
memory: 41280kb

input:

40000 80000
6155 33310 18982 32436 23117 11936 23625 36826 24896 18185 2373 31232 5057 20465 18997 36213 39297 32273 32461 29674 18962 13728 30106 33069 4625 35639 28937 32955 36807 31210 12487 33040 26415 13758 38447 20070 16135 32305 34756 22396 24672 32400 28184 22671 5895 5628 7054 27520 28612 1...

output:

2482912
3989810
2769849
61327113
1941
430688
2265362
13734472
841573
876749
1964893
1871085
58135
341014
1283806
251147
336822
1881637
1759
55220
54636306
89273293
3507762
150
481259
60713662
29805710
528588
28797
15556420
152834
3031161
6281519
3447319
3484
1007874
12024770
45238668
111546
63461564...

result:

ok 80000 lines

Test #17:

score: 4
Accepted
time: 806ms
memory: 50948kb

input:

50000 100000
38469 24525 32217 24789 47311 24293 3571 14829 26717 913 21309 8308 37327 8734 17912 43870 48997 10733 2270 26728 7330 16464 40796 11288 47560 48672 46090 18389 25933 46137 41744 48976 38039 41118 38084 40612 47921 45345 45410 48851 31754 38299 27413 23608 24009 31513 40500 49878 8252 4...

output:

12576436
0
32713667
0
0
8600646
0
0
1
3392613
112442
1363510
1837462
16730090
15496184
0
8376293
47519
13815
136015
11128838
0
19206597
593088
219225916
93028559
108768
127361
2147519
7752211
8651523
1394136
2020729
94978224
175434
140061
6946246
10979281
9030509
15007149
355416
0
16729298
781478
16...

result:

ok 100000 lines

Test #18:

score: 4
Accepted
time: 1073ms
memory: 63192kb

input:

60000 120000
28929 27272 6259 45423 15780 40321 15580 4868 47291 3546 27936 45710 20567 26606 30216 52113 50838 55739 49818 56542 31288 49488 50806 8957 57695 52604 58066 14076 38002 58344 26180 36232 22180 32879 34138 51711 34760 25593 43389 31396 51616 13814 58547 40038 55058 48403 34408 25186 517...

output:

40147837
0
51566690
0
0
13220254
0
0
0
4030325
31586
1057561
4122040
22338675
28401522
148717
12477764
25267590
123865
106476
18079642
0
230
269436
279649802
8146344
119074
21619
3802353
20191494
9412057
3069672
6894123
15496172
359109
299071
1553726
432529
16596413
22834900
108266
0
26402289
689929...

result:

ok 120000 lines

Test #19:

score: 4
Accepted
time: 1301ms
memory: 74276kb

input:

70000 140000
52924 17320 66317 8157 30299 14111 65609 39835 21071 62191 51780 53198 44998 54574 66213 14371 58818 68483 39851 47765 42611 69393 63471 60519 9205 11577 69131 61430 13885 29809 66714 44006 62051 58921 12599 53974 40692 64816 36682 3519 24905 52640 10114 68493 49109 41844 48600 66776 38...

output:

0
71168260
0
0
10568172
0
0
0
6088047
113
1148444
9325891
37773605
47103219
241450
20159460
193961
772110
51361
31312522
0
351128607
737922
338220816
26600575
196883
0
4841669
34708647
10142188
4411511
4894816
17480487
186770
59261234
14598820
31761435
22231195
24858756
747914
0
45723576
871925
1321...

result:

ok 140000 lines

Test #20:

score: 4
Accepted
time: 1257ms
memory: 116040kb

input:

100000 200000
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:

0
137721903
0
0
194133638
44250527
0
4471544
910129753
72771
176917433
310465818
0
3496690
0
0
0
124875303
174237759
1814217937
123048818
0
33670
1044085030
0
0
0
2362051
199071076
0
15045346
164103768
0
0
190876473
60538504
0
29571894
0
27261
47838862
116403
15576
0
0
0
194015430
0
1006680857
53301...

result:

ok 200000 lines

Test #21:

score: 4
Accepted
time: 1306ms
memory: 116052kb

input:

100000 200000
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:

135243672
445436620
105771238
3638253
341558310
7938114
139152881
0
1657814543
0
491865906
11165173
0
271899527
33166438
207173180
0
44514328
0
989969225
13382550
33837649
0
877993543
0
606163955
315595119
5552778
1059725674
0
566649265
0
0
81032803
51577245
0
549610411
0
14680052
303084497
0
0
4329...

result:

ok 200000 lines

Test #22:

score: 4
Accepted
time: 1191ms
memory: 113124kb

input:

100000 200000
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:

0
0
1203662559
0
0
96445210
1
0
0
0
0
125666725
0
306145130
2922153
0
295986605
2476425
2122830
0
278468190
0
2025756693
18274033
2207169989
765089386
0
0
47516622
846188073
44495457
0
0
133179354
0
0
0
0
0
295524505
17431558
1
218812731
57926462
57636211
298620131
2486781990
212891284
1027291106
0
...

result:

ok 200000 lines

Test #23:

score: 4
Accepted
time: 1991ms
memory: 109476kb

input:

95000 190000
54869 89685 84021 77335 29643 94178 67158 60183 31735 63706 79776 89995 89643 62925 35391 76241 81318 59689 94539 42088 29258 71464 41104 76091 24922 72978 89700 92047 64960 12525 70519 82967 85527 88068 85048 89273 19561 66101 53150 88863 43065 94970 41214 71260 82429 52175 75847 14693...

output:

47
30689895
267124620
78216351
63087704
3333976
41526889
584018017
728108
597788
109571
35350
70304877
133574783
5943297
1476137
255079616
19002613
387858933
29
93586621
3301382
41269247
115240
1
13810
1553857
62095869
542821361
5191367
73253734
781863
4662341
7695371
23650076
138362
52849
0
104351
...

result:

ok 190000 lines

Test #24:

score: 4
Accepted
time: 2102ms
memory: 112332kb

input:

100000 200000
85963 54232 81192 62832 86584 80503 31766 74547 68821 73102 73096 72267 89495 33829 99520 43962 54837 89342 84555 71099 98465 64321 69793 39525 70934 87510 76927 85543 80068 25394 93361 4064 75959 51666 98914 15652 80946 90768 98387 88616 95082 44075 76628 84428 90891 63623 85280 43215...

output:

36093846
0
1675690837
31114627
2140378
1050874940
0
1
94607712
4946271
0
28697963
214972326
0
0
0
6207822
35627739
397699411
8002461
696467
17655604
26094681
19639152
54935823
511379
7809617
2271102
325946
81249458
2863
6973334
0
9284653
740101920
1862135
20401
6705308
1283407
71418076
6748091
75138...

result:

ok 200000 lines

Test #25:

score: 4
Accepted
time: 2034ms
memory: 109684kb

input:

100000 200000
90787 49393 38459 68555 92570 80827 83843 39871 57205 59948 85227 96519 94578 78479 78947 89776 58887 21176 89863 99298 44414 29776 25867 88717 53798 75196 76719 87201 71049 86356 44186 47657 77140 74621 90681 81634 99004 97417 67801 73807 30440 47271 98457 50945 68642 92999 98340 9941...

output:

0
0
608987425
0
0
3909175
6819715
38000652
0
1008098686
0
7696064
7708109
38712
15755716
0
41430219
0
0
576312728
76467695
0
74246325
2493471
8151930
735782171
7204
0
57952877
442383283
4287677
0
1202139
60051291
0
0
18671099
24659536
35333040
22872720
1002187
1
97724144
1929567
5774836
148319839
72...

result:

ok 200000 lines

Extra Test:

score: 0
Extra Test Passed