QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#104107#1385. Ogromne drzewo [A]xiaoyaowudi2 529ms100940kbC++174.0kb2023-05-08 18:12:562023-05-08 18:13:00

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-08 18:13:00]
  • 评测
  • 测评结果:2
  • 用时:529ms
  • 内存:100940kb
  • [2023-05-08 18:12:56]
  • 提交

answer

#include <iostream>
#include <algorithm>
#include <bitset>
constexpr int p(1e9+7);
using ll=long long;
int W(int k){return k>=p?k-p:k;}
struct I
{
	int len,tg;
	ll c[2],s[2];
};
I operator+(const I &a,const I &b)
{
	I r;r.len=a.len+b.len;r.tg=a.tg^b.tg;
	for(int i(0);i<2;++i)
	{
		bool flg((b.len&i)^b.tg);
		r.c[i]=b.c[i]+(flg?p-a.c[i]:a.c[i]);
		r.s[i]=(b.s[i]+b.c[i]*a.len+(flg?-a.s[i]:a.s[i]));
	}
	return r;
}
I delp(const I &a,const I &b)
{
	I r;r.len=a.len-b.len;r.tg=a.tg^b.tg;
	for(int i(0);i<2;++i)
	{
		bool flg((r.len&i)^r.tg);
		r.c[i]=a.c[i]+(flg?b.c[i]:-b.c[i]);
		r.s[i]=a.s[i]-r.c[i]*b.len+(flg?b.s[i]:-b.s[i]);
	}
	return r;
}
constexpr int K(800),N(6e5+10);
std::bitset<K> occ[N];
I ps[N<<1],ei,oi;
int off(N),vs[N],k;
struct B
{
	int tg;
	I itg;
}bs[K];
void rev(I &a)
{
	std::swap(a.c[0],a.c[1]);std::swap(a.s[0],a.s[1]);
	a.tg^=(a.len&1);
}
void shr()
{
	I las(oi);
	for(int j(1);j<=k;++j)
	{
		I nw;
		if(vs[j]-vs[j-1]==1)
		{
			nw=bs[j].itg+ps[vs[j]+off];
		}
		else
		{
			nw=delp(ps[vs[j]+off],ps[vs[j]+off-1]);
		}
		if(bs[j].tg) rev(nw),rev(las);
		ps[vs[j-1]+off]=delp(ei,bs[j].itg);
		bs[j].itg=las+bs[j].itg;
		las=nw;
	}
	--off;
}
int main()
{
	oi.len=1;oi.c[1]=1,oi.s[1]=0;
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	int n,qc;std::cin>>n>>qc;
	static int a[N],f[N],g[N],pos[N],bid[N],up[N],dn[N],sm[N],siz[N];
	for(int i(1);i<n;++i) std::cin>>a[i];
	for(int i(1);i<=n;++i)
	{
		if(i<n && (a[i]%2==0))
		{
			for(f[i]=2;i+f[i]-1<n && a[i+f[i]-1]%2;++f[i]);
		}
		else f[i]=1;vs[i]=f[i];
	}
	g[n]=1;
	for(int i(n-1);i;--i)
	{
		if(a[i]&1) g[i]=g[i+1]+1;
		else g[i]=1;
	}
	k=n;vs[++k]=2*n;
	std::sort(vs+1,vs+k+1);k=std::unique(vs+1,vs+k+1)-vs-1;
	for(int i(1);i<=k;++i)
	{
		I cur(ei);
		for(int j(vs[i-1]+1);j<=vs[i];++j)
		{
			bid[j]=i;
			cur=cur+oi;
			ps[off+j]=cur;
		}
	}
	for(int i(1);i<=n;++i)
	{
		int j(std::lower_bound(vs+1,vs+k+1,f[i])-vs);
		pos[i]=j;
		occ[i].set(j);occ[i]^=occ[i-1];
	}
	struct _q
	{
		int u,v,l,id;
		bool operator<(const _q &b) const {return l<b.l;}
	};
	static _q q[N];
	for(int i(1);i<=qc;++i)
	{
		std::cin>>q[i].u>>q[i].v>>q[i].l;q[i].id=i;
	}
	std::sort(q+1,q+qc+1);
	static int out[N];up[1]=0;dn[n]=0;siz[n]=1;
	for(int i(n-1);i;--i) dn[i]=1ll*a[i]*(siz[i+1]+dn[i+1])%p,siz[i]=(1ll*a[i]*siz[i+1]+1)%p;
	for(int i(2);i<=n;++i) up[i]=(up[i-1]+1ll*(a[i-1]-1)*(dn[i]+siz[i])+(siz[1]-siz[i]+p))%p;
	for(int i(1);i<=n;++i) sm[i]=(up[i]+dn[i])%p;
	for(int i(1),j(1);i<=n;++i)
	{
		shr();
		for(;j<=qc && q[j].l==i;++j)
		{
			int u(q[j].u),v(q[j].v);bool flg(false);
			if(u!=i) std::swap(u,v),flg=true;
			static std::bitset<K> sw;sw.reset();
			static int ts[10];int tc(0);ts[++tc]=2*n;
			if(u!=i)
			{
				sw^=occ[u-1]^occ[v-1];
				ts[++tc]=g[u];ts[++tc]=g[v];ts[++tc]=g[i];
			}
			else
			{
				if(v!=i)
				{
					sw^=occ[i-1]^occ[v-1];
					ts[++tc]=g[v];
				}
				else
				{
					ts[++tc]=g[i];
				}
			}
			std::sort(ts+1,ts+tc+1);
			auto qb=[&](int l,int r,int id)->I
			{
				I ret;
				if(l==vs[id-1]+1)
				{
					ret=bs[id].itg+ps[off+r];
					if(bs[id].tg^sw[id]) rev(ret);
				}
				else
				{
					ret=delp(ps[off+r],ps[off+l-1]);
					if(bs[id].tg^sw[id]) rev(ret);
				}
				return ret;
			};
			auto qry=[&](int l,int r)->I
			{
				if(l>r) return ei;
				int bl(bid[l]),br(bid[r]);
				if(bl==br) return qb(l,r,bl);
				else
				{
					I ret=qb(l,vs[bl],bl);
					for(int i(bl+1);i<br;++i) ret=ret+qb(vs[i-1]+1,vs[i],i);
					return ret+qb(vs[br-1]+1,r,br);
				}
			};
			I ans(ei);
			for(int i(k-1);i;--i) sw[i]=sw[i]^sw[i+1];
			for(int t(1);t<=tc;++t)
			{
				I cur=qry(ts[t-1]+1,ts[t]);
				if((tc-t)&1) rev(cur);
				ans=ans+cur;
			}
			int diff((((u-i+v-i)*ans.c[0]+2*ans.s[0])%p+p)%p);
			out[q[j].id]=1ll*((long long)p+(flg?sm[v]-sm[u]:sm[u]-sm[v])+diff)*((p+1)/2)%p;
		}
		for(int j(1);j<=pos[i];++j) bs[j].tg^=1;
	}
	for(int i(1);i<=qc;++i) std::cout<<out[i]<<"\n";
	return 0;
}

詳細信息

Subtask #1:

score: 1
Accepted

Test #2:

score: 1
Accepted
time: 2ms
memory: 32060kb

input:

2 100
2
1 1 1
1 2 1
2 1 1
2 2 1
2 2 2
1 1 1
1 2 1
1 1 1
1 2 1
2 1 1
2 2 1
1 1 1
2 2 2
2 2 1
2 1 1
1 1 1
1 2 1
2 2 1
2 1 1
2 1 1
2 2 1
2 2 2
1 2 1
2 2 1
1 1 1
2 2 2
2 2 1
2 2 2
2 2 1
1 1 1
2 2 1
1 2 1
2 2 2
2 2 1
1 1 1
2 2 2
1 1 1
2 2 1
2 2 2
2 2 2
1 1 1
2 1 1
1 1 1
1 2 1
2 2 2
1 1 1
2 2 2
2 2 2
2 1 ...

output:

0
1
2
1
1
0
1
0
1
2
1
0
1
1
2
0
1
1
2
2
1
1
1
1
0
1
1
1
1
0
1
1
1
1
0
1
0
1
1
1
0
2
0
1
1
0
1
1
2
1
2
1
1
0
1
1
1
1
1
1
2
1
1
0
2
2
0
2
1
1
1
0
0
0
1
2
2
1
2
1
1
1
2
1
2
2
1
2
1
1
1
1
1
2
1
1
1
0
2
2

result:

ok 100 lines

Test #3:

score: 0
Accepted
time: 2ms
memory: 32032kb

input:

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

output:

0
998033926
1966100
17
17
998953478
998459906
999016713
999278089
1308691
999869011
655316
785943
999344783
1044510
999868980
999475850
130057
131054
999344783
999345648
262155
918025
8
393176
999664138
1175576
393205
1769492
999506442
999214591
999376395
16
913454
998328839
999869967
999086574
9984...

result:

ok 100 lines

Test #4:

score: 0
Accepted
time: 2ms
memory: 32116kb

input:

2 97
299999
1 1 1
1 2 1
2 1 1
2 2 1
2 2 2
1 2 1
2 2 2
2 2 2
1 1 1
2 2 1
1 1 1
2 2 1
2 1 1
1 2 1
1 2 1
1 1 1
1 2 1
1 2 1
1 2 1
1 2 1
2 2 2
2 2 2
2 1 1
1 2 1
2 2 2
1 2 1
2 2 1
1 2 1
2 2 1
2 2 2
1 2 1
2 2 1
1 2 1
2 1 1
2 2 2
2 2 1
1 1 1
2 2 2
2 2 1
2 2 2
1 1 1
1 1 1
2 1 1
1 1 1
2 2 1
2 2 1
1 1 1
1 1 1
...

output:

1
999850008
149999
1
1
999850008
1
1
1
1
1
1
149999
999850008
999850008
1
999850008
999850008
999850008
999850008
1
1
149999
999850008
1
999850008
1
999850008
1
1
999850008
1
999850008
149999
1
1
1
1
1
1
1
1
149999
1
1
1
1
1
149999
1
1
999850008
999850008
999850008
1
999850008
1
1
1
999850008
149999...

result:

ok 97 lines

Test #5:

score: 0
Accepted
time: 2ms
memory: 32028kb

input:

15 100
2 3 2 3 3 2 2 2 2 2 3 2 2 2
1 1 1
1 15 1
15 1 1
15 15 1
15 15 15
14 3 2
5 8 2
3 10 1
6 5 2
6 7 6
10 10 3
14 14 6
11 8 1
8 13 1
10 8 6
12 12 5
7 7 1
14 14 10
5 14 5
12 6 3
6 12 4
9 11 8
5 3 3
4 15 1
5 14 5
11 12 11
8 13 1
5 5 1
7 5 2
14 14 10
11 8 1
3 3 1
15 15 7
4 8 4
4 13 2
5 14 2
13 4 2
4 1...

output:

0
998992623
1007400
14
12
872083
999759071
999452631
79693
999919574
9
13
243256
999594414
162109
11
6
13
999272283
485683
999514340
999837773
144344
999114412
999272283
999918841
999594414
4
160132
13
243256
2
14
999682390
999276788
999272283
723236
999195600
999675328
81107
405892
999757099
243427...

result:

ok 100 lines

Test #6:

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

input:

16 100
2 2 2 2 2 2 3 2 2 2 2 3 3 2 3
1 1 1
1 16 1
16 1 1
16 16 1
16 16 16
4 6 4
7 7 4
7 10 3
8 5 3
15 15 7
3 12 1
16 16 6
5 13 2
8 8 6
13 12 1
15 13 5
11 16 4
11 10 7
8 15 2
3 1 1
10 13 7
8 7 7
16 10 1
5 2 1
15 15 3
14 4 4
1 13 1
14 14 8
14 16 6
9 12 4
8 12 6
12 16 4
8 7 4
4 10 1
8 7 4
14 8 3
12 3 3...

output:

0
998281762
1718264
15
9
999760644
6
999606230
382442
12
998876006
15
998958575
7
132049
264126
999339828
131901
999076901
66034
999604111
130694
792097
280641
14
1289057
998677937
11
999735898
999604424
999473046
999471808
130696
999238924
130696
791067
1124016
999076214
262070
132071
521729
909412...

result:

ok 100 lines

Test #7:

score: 0
Accepted
time: 2ms
memory: 32032kb

input:

14 100
3 2 3 3 2 2 2 3 3 3 2 3 2
1 1 1
1 14 1
14 1 1
14 14 1
14 14 14
10 12 9
9 13 4
7 8 6
13 5 1
12 13 7
5 8 3
14 10 10
4 14 2
12 6 2
14 6 5
12 11 7
10 4 3
12 11 3
8 7 5
4 7 3
14 11 1
12 12 12
8 5 5
14 9 3
11 9 7
4 3 2
12 13 7
5 7 2
5 12 3
6 7 1
14 11 9
6 8 1
3 7 2
9 6 6
11 11 6
11 13 11
12 13 3
5 ...

output:

1
998517157
1482854
1
9
999749078
999498176
999875107
999511
999874529
999627623
501903
998754182
750871
1001835
125476
743931
125474
124906
999631691
376436
9
372388
627318
250885
111542
999874529
999752526
999125979
999875685
376440
999750786
999520150
374516
3
999749062
999874529
120836
999502334...

result:

ok 100 lines

Test #8:

score: 0
Accepted
time: 2ms
memory: 34068kb

input:

14 96
2 3 2 3 3 3 2 2 3 3 2 3 2
1 1 1
1 14 1
14 1 1
14 14 1
14 14 14
3 8 2
10 10 9
7 9 6
12 12 11
5 13 2
12 13 2
4 8 4
8 13 6
3 5 1
3 12 1
11 10 9
14 14 13
1 1 1
7 13 2
10 12 5
14 12 2
10 12 8
14 13 12
2 10 2
2 8 1
4 6 3
5 6 4
14 12 2
6 9 5
12 12 10
10 6 4
7 6 1
7 1 1
12 10 5
6 9 4
4 2 2
3 11 3
7 9 ...

output:

0
998566001
1434027
13
5
999403257
3
999749325
5
998998733
999874390
999507946
999372142
999776663
998901017
125616
5
0
999246899
999748780
251273
999748778
125637
999068492
999319500
999758052
999876705
251273
999624470
5
501115
124864
555272
251241
999624470
188453
999026635
999749329
1182761
6278...

result:

ok 96 lines

Subtask #2:

score: 1
Accepted

Test #9:

score: 1
Accepted
time: 2ms
memory: 31976kb

input:

2 100
3
1 1 1
1 2 1
2 1 1
2 2 1
2 2 2
1 2 1
2 1 1
2 2 1
1 2 1
2 1 1
1 2 1
1 1 1
2 2 1
2 2 2
1 1 1
2 2 1
2 2 1
1 2 1
1 2 1
2 1 1
2 2 1
1 2 1
2 2 1
1 2 1
2 1 1
2 2 2
2 1 1
1 1 1
1 2 1
2 1 1
1 1 1
2 2 2
2 2 2
2 2 2
2 1 1
1 2 1
2 2 1
2 2 2
1 2 1
1 2 1
2 2 1
1 2 1
2 2 1
1 1 1
2 2 2
2 2 1
2 2 1
2 1 1
1 2 ...

output:

1
1000000006
1
1
1
1000000006
1
1
1000000006
1
1000000006
1
1
1
1
1
1
1000000006
1000000006
1
1
1000000006
1
1000000006
1
1
1
1
1000000006
1
1
1
1
1
1
1000000006
1
1
1000000006
1000000006
1
1000000006
1
1
1
1
1
1
1000000006
1000000006
1
1000000006
1000000006
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1000000006
...

result:

ok 100 lines

Test #10:

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

input:

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

output:

6
998671401
1328606
6
6
999204485
664128
999734345
132850
999867513
999203393
1180984
531266
999204485
999867153
925106
999207767
6
752946
265720
795532
6
265672
6
999738667
6
531266
6
999603007
529826
999870429
132860
131770
999601449
261352
999734309
796620
795528
999335889
999734777
999601603
398...

result:

ok 99 lines

Test #11:

score: 0
Accepted
time: 1ms
memory: 32064kb

input:

3 100
402 745
1 1 1
1 3 1
3 1 1
3 3 1
3 3 3
2 2 1
3 3 2
1 1 1
2 3 2
2 3 2
1 1 1
1 2 1
1 1 1
3 1 1
3 1 1
1 1 1
2 3 2
3 3 2
3 3 1
3 1 1
3 2 2
3 3 3
1 2 1
1 3 1
3 2 1
3 2 1
3 3 2
2 2 2
1 3 1
2 3 2
2 3 2
3 3 2
3 3 3
3 3 3
3 2 2
3 2 1
3 2 2
2 3 2
3 2 2
2 1 1
2 2 2
1 3 1
2 3 2
1 2 1
2 3 2
2 2 1
3 1 1
3 3 ...

output:

0
999700863
299148
2
2
1
2
0
999850064
999850064
0
999850809
0
299148
299148
0
999850064
2
2
299148
149948
2
999850809
999700863
149948
149948
2
1
999700863
999850064
999850064
2
2
2
149948
149948
149948
999850064
149948
149203
1
999700863
999850064
999850809
999850064
1
299148
2
149948
1
999700863
...

result:

ok 100 lines

Test #12:

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

input:

14 100
2 3 2 3 3 3 2 3 2 3 2 3 2
1 1 1
1 14 1
14 1 1
14 14 1
14 14 14
14 13 10
2 12 1
12 10 2
14 9 8
14 12 6
8 9 2
7 8 7
13 6 1
8 7 2
7 6 2
3 9 3
14 5 3
12 10 5
5 6 2
8 4 3
13 8 3
9 5 2
8 8 4
8 5 4
6 5 3
5 13 4
13 14 4
4 12 3
14 9 4
6 5 5
8 13 6
13 14 8
9 5 3
13 6 6
4 13 2
4 2 2
12 10 8
9 11 7
10 8 ...

output:

0
998562237
1437789
13
3
125961
998814144
251893
629689
251917
999874188
999874441
880314
125577
125186
999275887
1129893
251889
999876389
493337
629566
500206
5
374377
123629
998996085
999874063
999003080
629693
123627
999370458
999874059
500206
880310
998877128
188939
251887
999748183
251727
99962...

result:

ok 100 lines

Test #13:

score: 0
Accepted
time: 2ms
memory: 31980kb

input:

14 100
2 3 2 2 2 3 2 3 3 3 2 3 2
1 1 1
1 14 1
14 1 1
14 14 1
14 14 14
13 13 6
11 6 6
10 2 1
4 4 3
9 9 5
6 9 6
5 12 1
3 13 1
14 3 1
11 14 2
13 11 1
9 11 6
9 13 3
14 12 11
14 11 10
10 10 10
10 14 2
8 7 5
13 14 7
10 7 4
6 13 2
6 9 2
8 14 7
8 13 2
12 11 9
5 5 1
11 4 4
11 7 6
12 9 7
1 4 1
12 11 1
6 8 6
3...

output:

0
999050657
949367
13
7
10
416180
614845
3
8
999751030
999420061
999190055
893609
999749119
167276
999832823
999665561
167281
250911
5
999665500
83063
999916381
250087
999416580
999751034
999498476
999582116
83637
4
573006
333702
250829
999874551
83641
999834476
999440935
999832770
698464
12
167257
...

result:

ok 100 lines

Test #14:

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

input:

13 100
2 3 3 3 2 3 2 3 3 3 3 2
1 1 1
1 13 1
13 1 1
13 13 1
13 13 13
12 13 11
7 5 2
11 9 7
6 3 3
4 5 1
1 6 1
8 10 6
6 5 1
4 2 2
2 13 2
7 12 3
10 9 2
6 11 1
13 10 5
9 12 9
6 7 2
12 10 4
2 2 2
13 10 3
11 9 1
11 2 2
6 5 2
8 13 3
9 11 6
3 12 3
5 4 2
11 6 5
7 11 7
9 8 8
13 12 2
11 11 8
11 11 8
9 12 7
8 7 ...

output:

0
999035543
964482
12
10
999908070
181634
183864
260527
999911468
999678189
999816242
90253
143035
999035542
999540697
91929
999541260
275842
999724215
999908632
183895
1
275844
183866
780586
90253
999540414
999816159
999188791
88548
458768
999632639
91862
91960
8
8
999724215
91677
999362468
9990355...

result:

ok 100 lines

Test #15:

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

input:

14 100
3 3 2 2 2 3 3 2 2 3 2 3 2
1 1 1
1 14 1
14 1 1
14 14 1
14 14 14
4 13 2
4 4 1
13 10 7
13 14 3
9 8 5
10 12 1
9 7 4
7 6 1
6 7 4
10 8 5
13 11 10
7 11 6
11 1 1
9 14 6
11 14 1
14 11 3
9 8 4
6 5 1
8 13 3
6 8 4
5 9 1
9 6 6
14 4 3
13 12 12
9 11 7
11 4 4
7 12 4
7 4 3
8 13 4
4 9 2
12 10 4
9 7 5
9 12 2
1 ...

output:

1
998999163
1000861
14
6
999251444
4
252256
999915927
83972
999831861
167805
83322
999916696
168000
168181
999664112
748593
999579647
999747753
252277
83972
81765
999579776
999832861
999667142
251120
832672
84096
999831912
580402
999580031
244502
999579776
999587718
168164
167805
999747831
999503493...

result:

ok 100 lines

Subtask #3:

score: 0
Wrong Answer

Test #16:

score: 0
Wrong Answer
time: 182ms
memory: 87640kb

input:

294859 99
9779 263842 162862 41309 205878 187011 120812 215594 144926 266659 91220 39902 35717 267493 76723 16658 128623 58659 71768 36576 16756 208904 127375 96504 2801 156958 287176 270333 115149 78879 187396 78481 209993 294915 151981 256988 122823 177567 2651 197632 91283 243813 247303 256011 54...

output:

1
864213173
135786856
1
417803354
269844654
207652367
381732145
119440528
969989049
749015015
128171912
305605168
362196882
586839768
763916759
312737819
364597261
75826709
679564170
407437948
707832987
71667163
10404963
603616400
302437012
721630007
107594596
218280995
872519610
259509267
669700003...

result:

wrong answer 5th lines differ - expected: '147355', found: '417803354'

Subtask #4:

score: 0
Wrong Answer

Test #33:

score: 0
Wrong Answer
time: 189ms
memory: 88544kb

input:

296856 99
112996 98273 118559 223016 283428 279243 44779 74799 249502 152381 153839 270440 174 279303 115472 116654 165877 81514 46036 74655 101113 298120 150105 174116 12215 158041 109669 240981 58173 59192 156109 242021 226979 232687 20959 85434 265728 282204 55838 172589 88312 242769 82403 252774...

output:

0
692171170
308125710
296855
417804592
953772946
566312798
72093185
750747290
621295623
233295720
505288174
600014341
980329616
983211245
158588599
422334981
309035397
853916805
208803204
230489725
737652624
505754258
492993949
545612165
932522245
224979636
683491739
640768866
593742274
130801402
27...

result:

wrong answer 5th lines differ - expected: '148593', found: '417804592'

Subtask #5:

score: 0
Wrong Answer

Test #50:

score: 0
Wrong Answer
time: 229ms
memory: 63904kb

input:

147184 150000
235610 69680 235575 212062 266680 19667 86350 114242 128529 251483 101550 24480 268227 254336 282625 198521 47272 181899 82751 87904 288520 105770 214645 291236 289808 75071 20399 183118 226768 194667 57810 21319 224954 270965 52359 273660 260475 17317 282282 160015 97351 138701 62176 ...

output:

0
289869256
759834605
386220471
329317223
327081390
378018557
51139936
983997475
916759075
710130754
1
1
469965352
469965350
96351216
96351214
39447970
39447968
37212135
37212133
88149304
88149302
761270688
761270686
694128222
694128220
626889820
626889818
240165406
530034662
530034660
2
2
0
6263858...

result:

wrong answer 151st lines differ - expected: '73671', found: '708901674'

Subtask #6:

score: 0
Wrong Answer

Test #66:

score: 0
Wrong Answer
time: 261ms
memory: 63784kb

input:

148319 150000
9748 219404 79271 293152 124388 212544 63679 63438 275709 269894 259787 167203 284500 121715 130247 91345 167175 161040 236708 263116 159003 284529 200111 195628 241532 131076 22057 33892 98702 170577 155026 189517 258093 174310 243785 173813 291746 295272 288315 286692 181374 221835 2...

output:

0
518737242
37651938
906535087
61152077
997202316
806042869
318449953
986405775
654233660
481262768
1
1
518914706
518914704
387797846
387797844
542414845
542414843
478465077
478465075
287305628
287305626
799712721
799712719
467668534
467668532
135496421
135496419
962348073
481085308
481085306
2
2
0
...

result:

wrong answer 151st lines differ - expected: '74230', found: '708902233'

Subtask #7:

score: 0
Wrong Answer

Test #81:

score: 0
Wrong Answer
time: 251ms
memory: 67528kb

input:

150000 150000
166270 280783 219855 25047 191988 171783 65384 43785 117120 194975 240798 242286 190979 210363 75415 43852 288773 128295 282657 261312 41683 24742 34976 32145 89318 248131 252941 33237 23804 171547 42970 36897 93802 32346 232284 187742 282885 220363 256924 80818 228122 54253 145029 162...

output:

0
594690572
64774384
384352854
24562027
730082137
278949009
791684439
293851870
795928042
405309444
1
1
470083826
470083826
789662292
789662292
429871467
429871467
135391566
135391564
684258449
684258447
196993870
196993868
699161310
699161308
201237473
201237471
935225627
529916190
529916190
2
2
2
...

result:

wrong answer 151st lines differ - expected: '74823', found: '708902826'

Subtask #8:

score: 0
Wrong Answer

Test #96:

score: 0
Wrong Answer
time: 514ms
memory: 94324kb

input:

300000 296149
120693 103294 197599 81478 180429 287231 207123 24953 276287 20750 183518 11100 101777 264363 152039 207542 70785 191815 130129 170975 116131 284586 139850 37287 139855 187905 100458 82326 291998 269296 208646 277820 183614 244575 220693 246340 201324 292765 198792 287243 248176 47419 ...

output:

1
655494174
655721476
979171024
70264706
40293225
780464444
833950831
806446020
778668951
344505833
1
1
227301
227301
323676851
323676851
414770538
414770538
384799059
384799059
124970269
124970269
178456658
178456658
150951845
150951845
123174778
123174778
344278535
999772708
999772708
1
1
3
323449...

result:

wrong answer 151st lines differ - expected: '149979', found: '417805978'

Subtask #9:

score: 0
Wrong Answer

Test #111:

score: 0
Wrong Answer
time: 529ms
memory: 95576kb

input:

300000 296183
253817 213650 26983 49231 54000 94314 180311 99764 58587 293526 40583 191616 195622 139856 66564 285086 175178 235177 197887 17396 130747 60756 109964 251539 149246 232925 188060 93753 144263 2885 158989 188531 196718 144960 214314 228199 43447 129862 227469 40824 18493 206587 29465 14...

output:

1
339343594
335179295
225479364
532993135
638772611
745280165
684683348
781647461
878525788
660656413
1
1
995835707
995835707
886135778
886135778
193649540
193649540
299429018
299429018
405936570
405936570
345339755
345339755
442303866
442303866
539182195
539182195
664820718
4164304
4164304
1
1
3
89...

result:

wrong answer 151st lines differ - expected: '150101', found: '417806100'

Subtask #10:

score: 0
Wrong Answer

Test #126:

score: 0
Wrong Answer
time: 497ms
memory: 100940kb

input:

300000 300000
142087 155563 179354 154435 173470 148675 120962 42971 161352 62432 183381 152465 279212 196345 258512 234427 187069 203076 299221 283407 112019 184133 286485 176058 206744 195289 280945 4032 3580 143823 10895 87359 274130 86109 62335 49505 276722 141225 26523 23127 199179 253026 16668...

output:

1
633965867
429677283
679356197
596672370
700733700
439635651
762021800
397011706
31894398
366034143
2
0
795711427
795711425
45390330
45390330
962706512
962706512
66767833
66767833
805669793
805669793
128055933
128055933
763045848
763045848
397928538
397928538
570322726
204288587
204288585
3
1
1
249...

result:

wrong answer 151st lines differ - expected: '150280', found: '417806279'