QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#282395#5425. Proposition Compositionushg8877WA 492ms46036kbC++143.6kb2023-12-11 22:12:112023-12-11 22:12:11

Judging History

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

  • [2023-12-11 22:12:11]
  • 评测
  • 测评结果:WA
  • 用时:492ms
  • 内存:46036kb
  • [2023-12-11 22:12:11]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MP make_pair
mt19937 rnd(time(0));
const int MAXN=2.5e5+5;
int n,m,fa[MAXN],siz[MAXN],pre[MAXN],suf[MAXN];
ll ans[MAXN];
vector<pair<int,int> > vec[MAXN];
inline int find(int x){
	while(x^fa[x]) x=fa[x]=fa[fa[x]];
	return x;
}
struct segt{
int minn[MAXN<<2],maxx[MAXN<<2];
void init(){for(int i=0;i<=4*n;i++)minn[i]=maxx[i]=0;} 
void pushup(int id){
	minn[id]=min(minn[id<<1],minn[id<<1|1]);
	maxx[id]=max(maxx[id<<1],maxx[id<<1|1]);
}
int askL(int L,int R,int x,int id=1,int l=1,int r=n){
	int mid=l+r>>1;
	if(L<=l&&r<=R){
		if(minn[id]>x) return 0;
		else if(l==r) return l;
		else if(minn[id<<1]<=x?askL(L,R,x,id<<1,l,mid):askL(L,R,x,id<<1|1,mid+1,r));
	} 
	int ans=0;
	if(L<=mid&&(ans=askL(L,R,x,id<<1,l,mid))) return ans;
	if(mid<R&&(ans=askL(L,R,x,id<<1|1,mid+1,r))) return ans;
	return 0;
}
int askR(int L,int R,int x,int id=1,int l=1,int r=n){
	int mid=l+r>>1;
	if(L<=l&&r<=R){
		if(maxx[id]<x) return 0;
		else if(l==r) return l;
		else return (maxx[id<<1|1]>=x?askR(L,R,x,id<<1|1,mid+1,r):askR(L,R,x,id<<1,l,mid));
	}
	int ans=0;
	if(mid<R&&(ans=askR(L,R,x,id<<1|1,mid+1,r))) return ans;
	if(L<=mid&&(ans=askR(L,R,x,id<<1,l,mid))) return ans;
	return 0;
}
void update(int x,int v,int id=1,int l=1,int r=n){
	if(l==r){minn[id]=maxx[id]=v;return;}
	int mid=l+r>>1;
	if(x<=mid) update(x,v,id<<1,l,mid);
	else update(x,v,id<<1|1,mid+1,r);
	pushup(id); 
}
}Tp,Ts,Tc;
struct BIT{
ll a[MAXN];
void init(){for(int i=0;i<=n;i++)a[i]=0;} 
void add(int x,ll d){while(x<=n){a[x]+=d;x+=(x&-x);}}
ll ask(int x){ll r=0;while(x){r+=a[x];x-=(x&-x);}return r;} 
}T,B;
void solve(){
	cin>>n>>m;n--; 
	Tp.init(),Ts.init(),Tc.init();T.init();B.init();
	for(int i=1;i<=n;i++) pre[i]=i-1,suf[i]=i+1;
	pre[1]=1e9,suf[n]=-1e9;
	for(int i=1;i<=n;i++) Tp.update(i,pre[i]),Ts.update(i,suf[i]); 
	int c0=n,c1=0;
	for(int i=1;i<=m;i++){
		vec[i].clear();
		int l,r,x,v=rnd();cin>>l>>r;
		if(l==r){
			ans[i]=c0*(n+i-c0)+c1;
			continue;
		} 
		if(l>r)swap(l,r); r--;
		x=l-1;
		B.add(l,1);B.add(r+1,-1);
		T.add(l,v);T.add(r+1,-v); 
		map<ll,pair<int,int> > rep;
		while(x<r&&(x=Tc.askL(x+1,r,1))){
			if(B.ask(x)==2) c1--; 
			if(B.ask(x)==1) c0--,c1++;
			Tc.update(x,B.ask(x));
		}
		x=0;ans[i]=c0*(n+i-c0)+c1;
//		cout<<ans[i]<<endl;
		while(x=Tp.askL(l,r,l-1)) rep[T.ask(x)].first=x,Tp.update(x,1e9);
		while(x=Ts.askR(l,r,r+1)) rep[T.ask(x)].second=x,Ts.update(x,-1e9); 
		for(auto j:rep){
			int x=j.second.first,y=j.second.second;
			if(x&&y){
				vec[i].push_back(MP(pre[x],x));
				Ts.update(pre[x],suf[y]);
				suf[pre[x]]=suf[y];
				Tp.update(suf[y],pre[x]);
				pre[suf[y]]=pre[x];
				Tp.update(x,1e9);Ts.update(y,-1e9);
				pre[x]=1e9;suf[y]=-1e9;
			}else if(x){
				vec[i].push_back(MP(pre[x],x));
				Ts.update(pre[x],-1e9);
				suf[pre[x]]=-1e9;
				Tp.update(x,1e9);
				pre[x]=1e9;
			}else{
				vec[i].push_back(MP(y,suf[y]));
				Tp.update(suf[y],1e9);
				pre[suf[y]]=1e9;
				Ts.update(y,-1e9);
				suf[y]=-1e9;
			}
		}
//		cout<<"AFTER "<<i<<endl;
//		for(int i=1;i<=n;i++) cout<<pre[i]<<' '<<suf[i]<<endl;
	}
	ll sum=0;
	auto merge=[&](int x,int y){
		x=find(x);y=find(y);
		sum+=siz[x]*siz[y];
		siz[x]+=siz[y];fa[y]=x;
	};
	for(int i=1;i<=n;i++) siz[i]=1,fa[i]=i;
	for(int i=1;i<=n;i++) if(suf[i]>0) merge(i,suf[i]);
	for(int i=m;i>=1;i--){
		ans[i]+=sum;
		for(auto j:vec[i]) merge(j.first,j.second);
	} 
	for(int i=1;i<=m;i++) cout<<ans[i]<<'\n';
}
int main(){
	ios::sync_with_stdio(false);
	int _;cin>>_;
	while(_--) solve();
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 28220kb

input:

3
4 3
2 4
4 2
3 3
7 3
3 4
1 2
1 7
6 4
1 3
4 6
2 5
3 4

output:

6
5
6
21
24
10
15
12
3
2

result:

ok 10 numbers

Test #2:

score: 0
Accepted
time: 82ms
memory: 30164kb

input:

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

output:

45
36
36
36
36
36
36
36
36
45
36
28
21
21
15
10
10
10
6
36
44
50
57
28
21
15
28
28
21
21
15
15
10
3
1
1
3
3
3
3
1
1
1
0
0
45
21
3
1
1
1
1
1
1
1
3
1
1
1
1
1
45
36
36
36
36
36
36
36
3
3
1
0
0
0
0
0
0
3
1
0
0
15
10
10
0
0
0
0
0
0
0
0
28
34
21
6
6
6
6
1
0
0
21
15
15
0
0
0
0
0
0
0
45
53
0
0
0
0
0
0
0
0
1...

result:

ok 249586 numbers

Test #3:

score: 0
Accepted
time: 116ms
memory: 28128kb

input:

2507
86 4
41 41
36 36
31 30
86 1
110 22
1 110
110 1
11 11
110 1
110 1
110 1
1 110
107 106
72 72
106 106
74 74
1 110
110 1
58 58
110 1
110 1
1 110
101 100
110 1
100 100
110 1
8 7
114 180
114 1
114 1
114 1
1 114
1 114
114 1
37 38
49 48
105 106
1 114
90 90
1 114
9 9
114 1
67 68
20 20
114 1
1 114
54 55
...

output:

3655
3740
3823
3570
5995
5886
5886
5886
5886
5886
5886
5778
5778
5778
5778
5778
5778
5778
5778
5778
5778
5671
5671
5671
5671
5565
6441
6328
6328
6328
6328
6328
6216
6105
5995
5995
5995
5995
5995
5995
5886
5886
5886
5886
5778
5671
5671
5565
5565
5460
5460
5460
5460
5460
5356
5253
5253
5253
5151
5151
...

result:

ok 249877 numbers

Test #4:

score: 0
Accepted
time: 178ms
memory: 41868kb

input:

3
82425 27858
30801 30802
1 82425
73850 73850
1 82425
65949 65949
82425 1
76026 76025
61936 61936
82425 1
82425 1
82425 1
6504 6504
82425 1
25155 25156
79743 79743
1 82425
69406 69406
29247 29247
18351 18351
23171 23170
29704 29703
82425 1
1 82425
82425 1
74918 74917
22395 22394
893 894
82425 1
391 ...

output:

3396899100
3396816676
3396816676
3396734253
3396734253
3396734253
3396651831
3396651831
3396651831
3396651831
3396651831
3396651831
3396651831
3396569410
3396569410
3396569410
3396569410
3396569410
3396569410
3396486990
3396404571
3396404571
3396404571
3396404571
3396322153
3396239736
3396157320
339...

result:

ok 116748 numbers

Test #5:

score: 0
Accepted
time: 266ms
memory: 44396kb

input:

1
250000 250000
248617 248617
1 250000
47808 47809
1 250000
1 250000
110493 110494
1 250000
66675 66676
141326 141327
250000 1
115279 115280
193218 193219
250000 1
77714 77715
1 250000
1 250000
212943 212943
223061 223060
1 250000
250000 1
1 250000
71059 71059
1 250000
246523 246522
1 250000
88700 8...

output:

31249875000
31249875000
31249625001
31249375003
31249375003
31249125006
31249125006
31248875010
31248625015
31248625015
31248375021
31248125028
31248125028
31247875036
31247875036
31247875036
31247875036
31247625045
31247625045
31247625045
31247625045
31247625045
31247625045
31247375055
31247375055
...

result:

ok 250000 numbers

Test #6:

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

input:

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

output:

36
29
28
16
16
16
8
45
29
45
53
61
36
18
16
8
15
5
4
4
4
2
2
45
36
17
16
15
15
15
0
0
0
0
28
3
4
1
1
1
1
1
10
3
1
1
1
1
1
0
0
0
3
1
3
3
3
1
0
0
6
36
30
12
8
8
3
4
5
5
1
0
0
0
0
0
6
5
6
1
0
0
0
0
0
0
28
32
19
20
11
7
7
21
17
17
12
4
3
2
1
1
21
11
7
6
3
3
1
2
1
1
28
25
20
21
22
22
23
11
1
1
28
1
1
0
0...

result:

ok 249141 numbers

Test #7:

score: 0
Accepted
time: 158ms
memory: 28196kb

input:

2517
14 35
2 13
14 1
14 14
1 14
7 7
1 14
7 7
2 14
9 11
2 4
2 13
11 12
14 2
13 1
14 1
13 2
12 11
2 14
1 13
12 11
1 14
4 5
2 14
14 14
13 13
10 9
14 2
1 14
14 2
13 2
14 2
7 8
6 6
1 1
13 1
51 125
30 30
40 39
25 24
51 1
1 51
40 40
8 7
50 2
2 50
7 9
50 1
30 30
47 49
14 16
2 4
1 51
1 50
6 6
1 51
4 4
50 2
2...

output:

91
58
58
56
56
56
56
55
37
23
23
17
17
17
17
17
17
17
17
17
17
12
12
12
12
11
11
11
11
11
11
7
7
7
7
1275
1324
1370
1176
1128
1128
1081
991
991
947
946
946
862
782
706
706
706
706
706
706
706
706
706
668
598
598
598
598
532
532
532
532
532
532
532
500
469
469
469
469
411
383
383
383
331
331
331
331
...

result:

ok 250000 numbers

Test #8:

score: 0
Accepted
time: 152ms
memory: 35764kb

input:

5
65849 4012
8907 8905
21927 21927
2 65849
2 65848
65849 1
1 65849
48863 48861
2 65849
7795 7795
65849 2
2 65849
65849 2
2696 2695
65848 2
41766 41765
2 65849
36403 36403
65849 2
32613 32613
26782 26781
60024 60024
44568 44570
5043 5043
52955 52954
15301 15299
65849 2
1 65849
27002 27000
22706 22707...

output:

2168012476
2168078322
2167880786
2167749099
2167683248
2167683247
2167551563
2167551563
2167551563
2167551563
2167551563
2167551563
2167485722
2167485722
2167419882
2167419882
2167419882
2167419882
2167419882
2167354043
2167354043
2167222369
2167222369
2167156533
2167024865
2167024865
2167024865
216...

result:

ok 52236 numbers

Test #9:

score: 0
Accepted
time: 325ms
memory: 44984kb

input:

1
250000 250000
97733 97731
132027 132027
196875 196877
1 250000
170476 170476
44407 44407
250000 1
249999 2
133959 133958
45337 45335
246071 246069
2589 2587
1 249999
172569 172570
2 249999
250000 2
244802 244804
79199 79199
1 249999
249999 1
213003 213003
84015 84014
92491 92492
124485 124485
1803...

output:

31249875000
31250124997
31250374986
31248875012
31248875012
31248875012
31248625017
31248125031
31247875039
31247375059
31246875083
31246375111
31246375110
31246125125
31246125125
31246125125
31245625159
31245625159
31245625159
31245625159
31245625159
31245375177
31245125196
31245125196
31244875216
...

result:

ok 250000 numbers

Test #10:

score: 0
Accepted
time: 74ms
memory: 30204kb

input:

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

output:

15
15
5
2
2
36
43
49
15
6
2
2
2
2
2
2
2
1
21
27
27
15
18
21
17
18
20
21
23
25
27
0
0
0
0
0
0
0
0
0
0
45
31
26
28
45
36
29
29
22
21
10
3
1
36
29
31
30
32
28
29
4
1
2
3
4
5
6
1
1
0
0
45
52
43
37
34
34
36
35
37
21
16
12
11
12
13
12
13
10
10
8
8
9
10
11
1
1
36
28
8
45
32
26
27
18
16
17
17
2
1
10
8
2
1
0...

result:

ok 250000 numbers

Test #11:

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

input:

2446
12 162
6 8
8 9
11 8
3 10
9 8
2 5
10 1
1 4
7 8
10 12
1 5
10 4
2 11
7 4
3 9
10 5
8 3
11 1
4 10
11 6
7 10
12 8
11 9
4 3
6 1
8 4
2 2
10 12
7 9
12 12
7 9
8 11
4 4
11 11
6 10
8 5
8 5
11 8
8 2
5 7
9 9
2 2
10 4
6 9
12 8
7 1
1 6
12 10
1 8
5 11
4 3
6 8
4 5
3 7
4 8
12 7
1 11
2 9
6 8
12 7
8 5
9 3
11 3
9 3
...

output:

66
72
69
47
50
36
21
20
20
1
1
1
1
1
1
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

ok 244825 numbers

Test #12:

score: 0
Accepted
time: 337ms
memory: 41524kb

input:

4
39845 77223
11304 11308
2 39838
6 39838
9 39836
39840 2
3 39844
5582 5576
11054 11055
39841 6
15426 15418
39837 3
18844 18851
5 39839
15992 16000
9 39844
39358 39355
9 39843
6 39843
7 39844
34287 34281
284 276
6614 6606
27606 27605
2870 2868
6 39845
39842 7
36916 36913
33317 33321
39836 3
39841 3
...

output:

793792090
793632766
793433634
793234527
793154851
792995480
792756580
792716766
792716764
792398302
792398300
792119695
792119694
791801352
791801348
791681980
791681980
791681982
791681982
791443280
791125074
790806932
790767167
790687639
790647775
790647775
790528490
790369459
790369460
790369461
...

result:

ok 250000 numbers

Test #13:

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

input:

1
250000 250000
237315 237325
161044 161036
137460 137451
247727 247730
38655 38653
23041 23049
5 249992
249997 2
178760 178760
198841 198847
10 249995
146224 146229
5 249999
8273 8274
249995 5
210583 210583
5 249996
249997 2
249998 9
81327 81318
3 249991
25090 25085
249991 10
48955 48955
249996 1
1...

output:

31249875000
31250124901
31250374702
31250624584
31250874485
31251124156
31239876513
31237626626
31237626630
31236126988
31234877294
31233627643
31233127625
31232877697
31232877699
31232877701
31232877702
31232877701
31232877697
31230628410
31230378490
31229128917
31229128919
31229128921
31228878902
...

result:

ok 250000 numbers

Test #14:

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

input:

2502
18 58
12 14
10 14
16 6
17 5
11 12
7 7
3 3
13 3
9 10
10 6
10 7
4 4
2 14
7 12
9 9
10 6
2 6
16 3
12 9
14 8
18 14
9 11
7 8
13 10
15 8
4 5
3 6
6 2
6 17
18 9
17 18
12 7
15 6
18 16
11 12
14 8
13 15
9 5
5 15
2 11
18 2
1 3
16 6
5 1
13 11
12 13
17 13
4 3
16 14
11 15
6 18
18 15
13 7
10 7
4 4
16 11
9 6
16 ...

output:

153
160
135
110
114
119
124
80
80
83
84
87
62
64
66
68
69
71
73
74
40
41
42
43
43
43
44
45
46
46
47
48
49
50
51
52
53
54
55
56
57
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
4753
3942
3981
3590
3619
3639
3612
3584
3507
2005
2005
1721
1604
1225
1228
1227
1130
1120
1120
1120
1114
899
878
750
740
745
746
751
724...

result:

ok 250000 numbers

Test #15:

score: 0
Accepted
time: 279ms
memory: 30424kb

input:

102
4953 1459
24 4912
4916 160
4771 89
139 4945
4897 187
2648 2783
119 4844
2725 2891
3572 3737
695 880
316 258
45 4925
159 4883
199 4923
4847 52
1026 1185
193 4882
4449 4249
3997 4032
4860 10
163 4910
3344 3396
1738 1730
2418 2339
4304 4163
1874 1837
4884 106
4880 72
4809 86
2724 2895
67 4832
4820 ...

output:

12263628
11593112
10938335
10795386
10669759
10069175
10064737
9591474
8902465
8164161
7936078
7934952
7934417
7887382
7887046
7288919
7288879
6576510
6453096
6383660
6383579
6202896
6175177
5907542
5615612
5494824
5494607
5494244
5492889
5479786
5479452
5479335
5473146
5163189
4688416
4646510
46390...

result:

ok 250000 numbers

Test #16:

score: 0
Accepted
time: 341ms
memory: 42964kb

input:

4
21918 92931
82 21855
7116 7178
9491 9490
21730 78
43 21862
5666 5629
21015 20888
21890 82
5601 5698
104 21745
12125 12198
21860 87
20657 20742
147 21825
12995 13023
50 21817
21917 162
21740 43
9798 9869
5509 5678
21888 160
21916 38
21752 106
108 21891
11552 11750
52 21803
21741 67
17717 17606
193 ...

output:

240188403
238842403
238820836
236014166
235099375
234302197
231581828
230970546
229688956
229217918
227665570
227665545
225865230
224953966
224362956
224362226
223455542
223455528
221962867
220036366
220036331
219926847
219926348
219926283
215820989
215820261
215820130
213531015
212892565
212892184
...

result:

ok 250000 numbers

Test #17:

score: 0
Accepted
time: 445ms
memory: 45932kb

input:

1
250000 250000
111 249894
249917 58
218975 218775
249877 56
27879 27766
173773 173666
156284 156320
91013 90934
94 249845
87959 87909
249981 112
249935 1
249903 46
173989 173869
188 249834
13 249973
37722 37870
111 250000
47757 47909
249990 16
195 249827
249825 178
78173 78038
205733 205898
54532 5...

output:

31249875000
31230641849
31180725389
31175981911
31147793860
31121113976
31112138954
31092449843
31084475001
31072017689
31055776912
31042029658
31042029091
31012145750
30990487902
30990487150
30953665805
30948915873
30911122441
30911122252
30907641474
30907143405
30873597255
30832623630
30788949406
...

result:

ok 250000 numbers

Test #18:

score: 0
Accepted
time: 288ms
memory: 28316kb

input:

109
1078 1889
1007 282
178 79
751 816
125 68
1066 175
742 543
497 489
930 354
847 438
315 601
821 685
951 524
489 665
836 3
984 270
1062 332
344 978
550 22
580 703
895 626
1021 237
827 678
954 925
316 455
1059 524
679 727
945 945
254 123
1061 193
420 105
1054 522
484 402
251 359
770 922
704 785
284 ...

output:

580503
508981
466269
454941
317613
225953
222408
177191
154391
131150
126077
122805
120227
46277
44428
43793
43525
42262
40944
38303
35796
35665
35457
34877
34777
34425
34439
34093
33445
31803
31602
30607
30364
29378
28904
28824
27974
27919
27397
27111
27082
26766
26608
26498
26332
26334
26238
26190...

result:

ok 250000 numbers

Test #19:

score: 0
Accepted
time: 329ms
memory: 38956kb

input:

4
97869 79786
97622 3759
51039 48491
3746 96678
14109 12461
6629 4082
1371 93507
2333 97649
94628 1603
2356 93761
8368 12451
38763 36986
1521 96702
96912 1332
3645 4908
93548 3615
37535 42115
4122 94942
49098 48685
507 93973
38937 34664
61132 58080
96699 4317
94764 4828
54733 58221
24842 22743
96548...

output:

4789121646
4556452483
4469835648
4323624136
4104137856
3617965605
3614006620
3611540070
3611289472
3289052536
3151967461
3151934589
3148031619
3121667929
3121622977
2874678916
2874103923
2873223719
2793609996
2627852094
2420023828
2419909246
2419844884
2202720256
2071218632
2071009041
2070682619
182...

result:

ok 174605 numbers

Test #20:

score: 0
Accepted
time: 492ms
memory: 46036kb

input:

1
250000 250000
72499 76406
249218 4952
77574 76846
249739 244771
248750 3284
78949 74197
2272 247857
247357 1612
1772 246339
582 249942
17878 18405
245086 199
246304 4360
248683 3281
159052 160180
160056 163657
162450 161367
2701 248329
6867 3683
79691 76969
247219 2874
3917 248097
249343 4784
7903...

output:

31249875000
30310794213
30136347850
28963221739
28552818207
28125506134
27873333680
27708709360
27707034508
27401084011
27278376916
27182263647
27181584281
27181526168
26920153032
26126448743
26123856297
26123440645
25689764148
25521704629
25521513034
25521353948
25521233472
25521144124
24480414364
...

result:

ok 250000 numbers

Test #21:

score: -100
Wrong Answer
time: 330ms
memory: 38888kb

input:

6
4504 68246
1935 1539
2647 2420
4176 1531
1242 3504
594 1855
2365 3008
1399 2440
4283 3866
1281 822
1552 2661
2794 4456
581 1251
1730 2010
1408 4014
1493 1085
3013 572
1497 1984
3285 2854
147 1562
2360 949
645 1199
241 813
2881 3772
2481 90
3258 907
2744 3523
616 4378
4440 1546
3893 1335
1605 3559
...

output:

10140756
10054744
8794251
7122287
5183727
4799432
4542354
4046722
3946754
3938771
3270727
3220521
3172274
3147819
3103926
3067076
3066285
2998096
1338676
1319848
1306113
1273350
1244923
991293
981245
972501
964495
963536
956950
944044
934765
927579
895626
889606
878145
873397
867276
859443
825217
81...

result:

wrong answer 249999th numbers differ - expected: '4585707028', found: '290739732'