QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#503554#9159. 登山C1942huangjiaxu30 1487ms251340kbC++143.3kb2024-08-03 19:57:162024-08-03 19:57:17

Judging History

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

  • [2024-08-03 19:57:17]
  • 评测
  • 测评结果:30
  • 用时:1487ms
  • 内存:251340kb
  • [2024-08-03 19:57:16]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
char buf[1<<23],*p1=buf,*p2=buf;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<23,stdin),p1==p2)?EOF:*p1++)
template<class rd>
void read(rd &x){
	char c=getchar();
	for(;c<48||c>57;c=getchar());
	for(x=0;c>47&&c<58;c=getchar())x=(x<<1)+(x<<3)+(c^48);
}
const int N=1e5+5,P=998244353,M=N*50;
int tid,T,n,p[N],l[N],r[N],h[N],w[N],ans,f[N],dp[N],rp[N];
int rt[N],ls[M],rs[M],cv[M],sum[M],va[M],cnt,tp;
bool vis[M],dl[M];
vector<int>e[N];
struct rb{
	int ty,x,y;
}st[M<<2];
inline int md(int x){
	return x>=P?x-P:x;
}
inline void Add(int &x,int y){
	if((x+=y)>=P)x-=P;
}
inline void chg(int k,int v){
	st[++tp]=rb{1,k,cv[k]};
	cv[k]=v,dl[k]=false;;
}
inline void mer(int x,int y){
	st[++tp]=rb{2,x,y};
	cv[x]+=cv[y],dl[x]=false;
}
inline void mdf(int k,int x,int y){
	cv[k]=x,va[k]=y,vis[k]=false;
}
inline void pushup(int k){
	sum[k]=(va[k]&&cv[k])?(sum[ls[k]]+sum[rs[k]]+1ll*va[k]*cv[k])%P:md(sum[ls[k]]+sum[rs[k]]);
}
void modify(int &k,int l,int r,int x,int y){
	if(!k)k=++cnt;
	if(x<=l&&r<=y)return chg(k,cv[k]+1);
	int mid=l+r>>1;
	if(x<=mid)modify(ls[k],l,mid,x,y);
	if(y>mid)modify(rs[k],mid+1,r,x,y);
}
void mark(int k,int l,int r,int x,int y){
	vis[k]=false;
	if(x<=l&&r<=y)return;
	int mid=l+r>>1;
	if(x<=mid)mark(ls[k],l,mid,x,y);
	if(y>mid)mark(rs[k],mid+1,r,x,y);
}
int merge(int x,int y,int l,int r){
	if(!x||!y)return x|y;
	if(l==r){
		mer(x,y);
		return x;
	}
	int mid=l+r>>1;
	mer(x,y);
	ls[x]=merge(ls[x],ls[y],l,mid);
	rs[x]=merge(rs[x],rs[y],mid+1,r);
	return x;
}
void clear(int &k,int l,int r,int p){
	if(!k||dl[k])return;
	if(l>=p){
		chg(k,0);
		if(l==r)return;
		int mid=l+r>>1;
		clear(ls[k],l,mid,p);
		clear(rs[k],mid+1,r,p);
		dl[k]=true;
		return;
	}
	int mid=l+r>>1;
	if(!ls[k])ls[k]=++cnt;
	if(p>mid&&!rs[k])rs[k]=++cnt;
	chg(ls[k],cv[ls[k]]+cv[k]);
	if(p>mid)chg(rs[k],cv[rs[k]]+cv[k]);
	chg(k,0);
	clear(rs[k],mid+1,r,p);
	if(p<=mid)clear(ls[k],l,mid,p);
}
void ins(int k,int l,int r,int x,int v){
	if(!k)return;
	mdf(k,cv[k],md(va[k]+v));
	if(l==r)return;
	int mid=l+r>>1;
	if(x<=mid)ins(ls[k],l,mid,x,v);
	else ins(rs[k],mid+1,r,x,v);
}
void restore(int o){
	while(tp>o){
		int x=st[tp].x,y=st[tp].y;
		if(st[tp].ty==2)mdf(y,cv[y],va[x]),mdf(x,cv[x]-cv[y],va[x]);
		else mdf(x,y,va[x]);
		--tp;
	}
}
void dfs1(int x){
	for(auto v:e[x])dfs1(v);
	rp[x]=tp;
	for(auto v:e[x])rt[x]=merge(rt[x],rt[v],0,n-1);
	modify(rt[x],0,n-1,dp[x]-r[x],dp[x]-l[x]);
	clear(rt[x],0,n-1,dp[x]-h[x]);
}
void dfs3(int x){
	if(!x||vis[x])return;
	vis[x]=true;
	dfs3(ls[x]),dfs3(rs[x]);
	pushup(x);
}
void dfs2(int x){
	if(x==1)f[x]=1;
	else dfs3(rt[x]),f[x]=sum[rt[x]];
	ins(rt[x],0,n-1,dp[x],f[x]);
	mark(rt[x],0,n-1,dp[x]-r[x],dp[x]-l[x]);
	restore(rp[x]);
	reverse(e[x].begin(),e[x].end());
	for(auto v:e[x])dfs2(v);
}
void solve(){
	read(n);
	for(int i=1;i<=n;++i)e[i].clear(),rt[i]=0;
	for(int i=1;i<=cnt;++i)ls[i]=rs[i]=cv[i]=va[i]=sum[i]=vis[i]=dl[i]=0;
	cnt=tp=0;
	for(int i=2;i<=n;++i){
		read(p[i]),read(l[i]),read(r[i]),read(h[i]);
		e[p[i]].push_back(i);
		dp[i]=dp[p[i]]+1;
	}
	dfs1(1);
	dfs2(1);
	for(int i=2;i<=n;++i)printf("%d%c",f[i]," \n"[i==n]);
}
int main(){
	read(tid),read(T);
	while(T--)solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Pretests

Pretest #1:

score: 5
Accepted
time: 3ms
memory: 16080kb

input:

1
4
6
1 1 1 0
1 1 1 0
3 1 2 1
3 2 2 0
4 2 3 1
6
1 1 1 0
2 1 2 0
2 1 2 0
1 1 1 0
4 1 2 2
6
1 1 1 0
1 1 1 0
3 1 2 1
4 2 2 0
3 1 1 0
6
1 1 1 0
1 1 1 0
3 1 1 0
4 2 3 1
2 1 2 0

output:

1 4 2 1 5
3 4 4 1 0
1 2 1 2 2
2 2 5 3 3

result:

ok 20 numbers

Pretest #2:

score: 0
Wrong Answer
time: 0ms
memory: 16252kb

input:

2
4
300
1 1 1 0
2 1 2 1
3 1 3 1
1 1 1 0
3 1 3 0
4 2 2 3
7 1 2 0
8 2 2 2
7 1 3 4
7 3 4 4
11 1 6 1
12 1 3 5
10 2 5 5
13 1 5 4
13 4 7 2
15 8 8 8
16 8 9 4
15 1 9 6
18 4 5 6
19 3 8 8
18 5 10 2
19 3 7 5
23 5 7 6
22 6 8 10
23 4 7 3
24 1 4 6
24 8 12 9
28 7 11 8
26 1 9 7
28 1 3 1
29 2 5 0
32 1 6 4
30 5 12 7
...

output:

19 18 35 1 38 15 50 0 0 15 364 261 0 1165 195 0 108 1655 0 0 103 632 393 0 1461 0 378 625 2267 1025 9891 4960 139 12593 1873 26899 37 62599 1873 10709 19 0 5171 0 19 1790 152451 19244 147265 108765 91828 37485 16850 144662 0 285879 29472 156200 851225 327121 1007903 35819 2519043 1873 13607 2514820 ...

result:

wrong answer 11th numbers differ - expected: '349', found: '364'

Pretest #3:

score: 0
Wrong Answer
time: 0ms
memory: 16228kb

input:

3
4
300
1 1 1 0
2 1 2 1
3 3 3 0
2 1 2 1
3 1 3 1
3 1 3 0
4 1 4 1
6 4 4 2
9 3 5 1
7 3 4 2
10 2 5 4
12 1 5 2
11 1 3 2
12 3 6 6
13 6 6 3
13 3 8 0
14 3 5 0
16 3 5 5
16 6 9 5
20 2 7 3
20 3 7 9
21 7 9 2
23 3 4 8
21 4 9 6
24 11 12 2
25 3 4 1
27 7 13 5
26 1 8 3
29 2 4 6
29 6 15 14
29 5 5 10
32 6 10 11
30 1 9...

output:

20 18 40 1 233 80 39 212 229 41 190 5094 56 0 4147 713 118 0 4129 5124 0 3313 2850 947 26658 9179 903 79936 35632 1 5124 0 38443 153819 61784 73122 10105 25021 131251 3214 0 0 82668 44365 27652 38 25699 526738 23912 112690 305255 13400 25076 504529 73071 421315 24657 0 136965 122010 181533 113430 28...

result:

wrong answer 25th numbers differ - expected: '21534', found: '26658'

Pretest #4:

score: 0
Wrong Answer
time: 31ms
memory: 22752kb

input:

4
4
5000
1 1 1 0
1 1 1 0
1 1 1 0
4 1 2 0
5 2 3 2
5 1 3 1
6 2 3 2
6 2 3 1
8 3 5 4
8 4 5 3
11 2 4 4
11 1 3 3
11 5 6 3
12 1 1 6
15 1 5 3
15 1 6 6
17 5 6 5
17 6 8 4
18 7 9 3
19 1 10 3
19 2 4 7
20 1 9 3
23 8 11 7
22 2 5 4
23 7 8 1
24 1 9 8
26 9 11 7
28 8 10 13
29 1 11 3
30 9 9 14
31 11 15 4
32 8 16 8
31 ...

output:

1 1 28 83 25 29 108 111 1 79 21 0 29 42 133 133 533 514 1522 345 133 1428 352 21 718 108 531 336 4250 384 2926 2610 4190 0 9453 3482 9453 4732 6122 2639 22337 28 32894 28 30748 28 21022 0 5835 10455 0 150758 38315 112310 1024 31840 211875 250 80544 80025 263568 424137 258184 5140 383099 30228 635939...

result:

wrong answer 14th numbers differ - expected: '21', found: '42'

Pretest #5:

score: 0
Wrong Answer
time: 35ms
memory: 22660kb

input:

5
4
5000
1 1 1 0
1 1 1 0
1 1 1 0
2 1 2 0
3 1 1 1
4 1 1 0
6 1 3 2
7 1 3 1
8 2 2 0
8 1 3 2
11 3 5 1
10 1 5 4
13 1 2 4
12 3 4 3
15 3 5 2
15 2 6 2
15 1 3 3
16 7 7 3
19 1 7 4
18 2 3 4
20 1 10 5
21 2 3 8
21 4 9 6
22 7 9 3
24 2 6 8
25 1 3 4
25 3 4 1
26 3 4 3
29 5 11 9
28 8 11 12
29 7 9 11
32 5 12 5
32 11 1...

output:

2 35 2 3 34 5 34 3 35 277 514 1 0 444 1451 380 1092 1106 2177 134 726 0 782 345 198 0 3283 1190 69 0 29 2430 1695 0 1625 0 0 1589 0 8704 10660 302 68 17845 1235 1471 15332 3869 0 23922 20868 2966 17798 34877 4737 4235 42491 7189 41152 33190 161608 47633 36170 37485 1339 54807 48271 4866 1338 36 4422...

result:

wrong answer 17th numbers differ - expected: '134', found: '1092'

Pretest #6:

score: 5
Accepted
time: 467ms
memory: 88460kb

input:

6
4
100000
1 1 1 0
2 1 1 0
3 1 1 0
4 2 2 0
5 1 1 0
6 2 2 0
7 6 6 0
8 3 3 0
9 6 6 0
10 8 8 0
11 6 6 0
12 12 12 0
13 11 11 0
14 2 2 0
15 2 2 0
16 2 2 0
17 9 9 0
18 1 1 0
19 4 4 0
20 18 18 0
21 13 13 0
22 20 20 0
23 3 3 0
24 21 21 0
25 8 8 0
26 11 11 0
27 11 11 0
28 3 3 0
29 21 21 0
30 1 1 0
31 27 27 0...

output:

7 90 1343 13340 200010 2186770 17480820 279693113 800242414 420706509 214087588 358274752 946289212 530647994 955227776 663050301 438245147 621009062 780623708 80919478 728275212 743623748 978006196 735181462 256088384 612217572 335562169 696082683 110948988 53450390 637356472 107616671 988788196 54...

result:

ok 399996 numbers

Pretest #7:

score: 5
Accepted
time: 771ms
memory: 134620kb

input:

7
4
100000
1 1 1 0
1 1 1 0
1 1 1 0
3 1 1 0
1 1 1 0
3 1 1 0
7 1 1 0
6 1 1 0
9 2 2 0
6 1 1 0
6 1 1 0
7 2 2 0
9 2 2 0
11 1 1 0
11 2 2 0
14 4 4 0
12 1 1 0
16 3 3 0
15 1 1 0
17 3 3 0
20 5 5 0
18 4 4 0
20 2 2 0
19 2 2 0
22 5 5 0
22 2 2 0
22 3 3 0
23 5 5 0
27 7 7 0
26 6 6 0
27 5 5 0
31 1 1 0
33 9 9 0
34 2 ...

output:

1 1 1 1 31 2 2 94 31 1298 33 1 126 41443 62 95 35 93 1490650 94 49108564 2 41443 62 31502098 1491949 41443 1 1 882058713 1298 808538694 650336433 808538694 808538695 53283330 1298 31502098 1 31502098 319947267 692436002 360370658 1534689 1298 41443 692394559 41443 518136386 1298 972986764 32 6923530...

result:

ok 399996 numbers

Pretest #8:

score: 0
Wrong Answer
time: 607ms
memory: 106764kb

input:

8
4
100000
1 1 1 0
2 2 2 0
3 3 3 0
4 4 4 2
5 2 2 1
6 6 6 0
7 2 2 0
8 7 7 3
9 4 4 3
10 1 1 4
11 3 3 0
12 8 8 11
13 13 13 7
14 5 5 10
15 8 8 11
16 14 14 5
17 9 9 2
18 17 17 7
19 3 3 1
20 1 1 9
21 14 14 5
22 5 5 17
23 8 8 14
24 8 8 9
25 24 24 7
26 24 24 7
27 17 17 8
28 27 27 27
29 26 26 6
30 17 17 14
3...

output:

12 23 22 21 88 154 153 371 1189 1101 2290 1919 1943 1942 753 1701 1678 1307 4674 7647 2973 2820 1142 3085 13222 13210 13187 12086 12896 28855 29526 72262 69177 125458 124151 124171 123047 53870 195133 690548 1947493 5853965 5853953 5729802 5039254 5029087 5029066 5027759 5026211 5028489 5028601 5027...

result:

wrong answer 5th numbers differ - expected: '42', found: '88'

Pretest #9:

score: 0
Wrong Answer
time: 1006ms
memory: 176940kb

input:

9
4
100000
1 1 1 0
2 2 2 0
2 1 1 1
2 2 2 1
1 1 1 0
6 1 1 1
3 1 1 0
6 1 1 0
7 1 1 2
6 2 2 0
8 3 3 2
9 1 1 1
9 1 1 0
12 5 5 2
14 1 1 3
13 4 4 3
13 1 1 3
14 3 3 3
17 5 5 2
19 1 1 0
18 3 3 3
22 3 3 5
23 1 1 0
21 5 5 3
22 4 4 4
23 7 7 2
24 6 6 3
25 2 2 1
29 6 6 7
29 8 8 3
31 8 8 7
32 6 6 5
31 5 5 7
31 2 ...

output:

4 6 0 1 23 0 11 44 0 1 5 3 62 1 0 2 4 18 1 220 1 1 45 202 0 1 44 399 0 179 23 18 0 554 0 0 155 554 0 261 179 701 220 0 1214 971 23 417 269 155 565 0 779 0 85 457 62 756 62 554 1428 457 0 0 40 677 3264 475 0 0 40 3223 18 1067 457 0 3798 502 3244 479 0 0 2030 519 0 62 18 1569 62 3609 3547 2428 16090 1...

result:

wrong answer 17th numbers differ - expected: '1', found: '4'

Pretest #10:

score: 5
Accepted
time: 693ms
memory: 99596kb

input:

10
4
100000
1 1 1 0
2 2 2 0
3 3 3 0
4 2 2 0
5 2 4 0
6 1 3 0
7 2 4 0
8 3 8 0
9 1 6 0
10 4 6 0
11 2 9 0
12 2 3 0
13 1 13 0
14 4 12 0
15 1 9 0
16 7 13 0
17 10 17 0
18 17 17 0
19 10 11 0
20 2 13 0
21 9 11 0
22 15 18 0
23 9 22 0
24 4 6 0
25 21 22 0
26 9 16 0
27 18 27 0
28 4 16 0
29 13 24 0
30 1 5 0
31 5 ...

output:

27 1160 73079 5773240 508043960 401903691 408194108 913457210 404309453 850776989 162033550 491800762 693950334 88591672 90581013 261837127 124549390 607776285 954584563 426982262 910735533 125508942 301425049 369545791 349157696 256736908 276834134 449249498 408190411 362993320 980271019 745442146 ...

result:

ok 399996 numbers

Pretest #11:

score: 5
Accepted
time: 1188ms
memory: 184924kb

input:

11
4
100000
1 1 1 0
1 1 1 0
2 1 2 0
1 1 1 0
2 1 2 0
6 1 3 0
5 1 2 0
7 2 3 0
6 2 2 0
8 1 3 0
9 2 3 0
9 3 5 0
10 2 4 0
13 2 4 0
12 4 6 0
13 1 6 0
16 1 4 0
18 6 7 0
18 2 4 0
20 1 6 0
21 2 9 0
20 1 3 0
23 1 4 0
22 1 8 0
24 10 10 0
23 3 5 0
24 3 11 0
26 8 11 0
27 1 9 0
30 2 11 0
28 12 12 0
32 4 8 0
32 9 ...

output:

41 1 42 3 3401 407995 8 65275757 3484 12 30977333 131377791 3443 65687153 608294415 197064986 558803128 3442 391883539 973952531 292262895 548293486 864139803 925368887 65687235 614731260 251165603 65687194 646118904 822181649 995485114 956758427 65275757 656989819 750355997 665993179 321752162 1997...

result:

ok 399996 numbers

Pretest #12:

score: 5
Accepted
time: 1169ms
memory: 186024kb

input:

12
4
100000
1 1 1 0
1 1 1 0
3 1 2 0
3 1 2 0
4 1 1 0
4 1 3 0
6 2 4 0
7 2 4 0
9 1 4 0
8 1 3 0
11 3 3 0
11 5 6 0
12 1 2 0
14 3 3 0
13 2 7 0
16 2 3 0
17 2 4 0
17 7 9 0
17 3 8 0
20 2 6 0
21 10 11 0
21 6 11 0
21 7 9 0
23 3 4 0
24 5 11 0
26 6 9 0
26 5 7 0
27 12 13 0
29 10 10 0
28 1 3 0
31 13 15 0
32 7 13 0...

output:

1 44 3430 45 363401 10424 49055705 17373 31271 763087444 528293936 364247389 57980118 763087444 558370737 701077016 687461217 3475 530193136 875194506 45 47291471 587072521 233025799 902397684 501363487 984008256 763090918 763087444 553932106 460519388 415423761 485110453 526953701 435687917 4594610...

result:

ok 399996 numbers

Pretest #13:

score: 0
Wrong Answer
time: 893ms
memory: 127252kb

input:

13
4
100000
1 1 1 0
2 1 2 0
3 2 2 2
4 2 4 1
5 1 2 4
6 4 6 2
7 1 6 4
8 6 6 5
9 5 8 8
10 6 6 1
11 8 11 5
12 8 11 1
13 4 8 6
14 4 7 1
15 11 15 5
16 1 1 10
17 6 9 7
18 8 16 2
19 2 9 10
20 6 20 7
21 12 14 11
22 9 14 14
23 6 7 22
24 12 14 11
25 20 20 21
26 10 20 0
27 19 26 8
28 21 23 12
29 4 13 23
30 15 2...

output:

28 55 26 109 134 246 162 79 24 1488 1379 3003 2785 2670 917 1615 2364 30420 37670 70907 58718 58453 61617 57915 52045 280219 1386727 5546069 22563413 112385341 449536393 799621024 402374594 616130665 819928736 228816980 93920514 282593673 847578408 112045191 386311585 930502817 862576985 862641159 6...

result:

wrong answer 5th numbers differ - expected: '25', found: '134'

Pretest #14:

score: 0
Wrong Answer
time: 1419ms
memory: 239880kb

input:

14
4
100000
1 1 1 0
2 1 1 1
1 1 1 0
2 1 2 1
4 2 2 1
5 2 2 1
7 1 4 1
8 2 5 3
8 5 5 3
10 2 3 5
11 1 6 5
10 1 4 5
12 5 8 1
12 3 6 5
13 3 6 2
15 2 5 8
17 6 7 6
18 6 8 5
17 10 10 1
18 4 5 5
20 4 11 7
22 8 9 4
23 9 13 12
24 9 13 10
24 6 8 7
26 3 13 13
26 11 14 11
28 11 11 2
27 9 16 8
30 6 12 0
31 13 17 16...

output:

38 0 2 37 1 150 149 39 34 332 109 0 226 252 374 32 300 333 556 0 555 438 391 225 1289 371 225 34 4270 6612 11354 3029 850 35450 3109 0 73179 50943 56494 725 62381 2594 1970 15616 470 8233 7058 109 3869 0 129423 248158 3035 188940 244526 185867 1 59127 174 39 24 11133 584021 523390 915490 142467 849 ...

result:

wrong answer 10th numbers differ - expected: '33', found: '332'

Pretest #15:

score: 0
Wrong Answer
time: 1467ms
memory: 249996kb

input:

15
4
100000
1 1 1 0
1 1 1 0
3 1 1 1
3 2 2 0
4 1 2 0
5 1 1 2
2 1 2 0
3 1 2 0
7 3 3 1
9 3 3 1
8 1 2 1
10 1 5 1
8 2 3 0
9 1 2 1
11 3 3 3
14 1 2 2
15 1 3 1
15 2 4 0
15 1 4 3
17 3 4 2
19 5 5 2
21 4 6 4
21 6 6 2
24 2 4 6
24 3 7 4
22 3 4 0
23 1 5 5
23 5 6 6
26 2 8 3
30 5 9 8
27 4 6 1
27 3 7 2
31 6 8 7
32 5...

output:

8 69 0 2 69 1 63 1791 141 1 8 73 46 1720 0 37 1860 60684 1 226 58823 9 146 0 145 254634 0 0 193 38 76796 174327 63 73216 66055 64195 110062 119507 3581 108201 1720 0 0 102970 44147 1423470 3580 700676 247967 119507 64264 3580 650752 739241 0 3580 1860 123018 1746141 150012 0 5441 531314 3274426 0 35...

result:

wrong answer 29th numbers differ - expected: '156', found: '193'

Pretest #16:

score: 0
Wrong Answer
time: 1451ms
memory: 251324kb

input:

16
4
100000
1 1 1 0
1 1 1 0
1 1 1 0
4 1 1 1
1 1 1 0
2 1 2 0
7 2 3 2
3 2 2 0
6 2 2 0
8 2 3 0
11 1 5 1
11 2 5 3
11 3 3 4
14 2 6 2
14 2 3 0
12 2 3 0
12 4 5 0
16 3 7 1
19 3 7 2
18 3 4 2
21 2 4 0
22 1 3 0
21 1 6 6
21 4 5 3
21 1 7 4
23 1 10 2
26 1 6 4
23 9 10 0
25 7 8 1
25 3 9 2
27 9 11 3
29 4 11 7
33 2 6...

output:

55 2 1 0 2 109 53 1 1 2332 2110 56 2 218 7486 2385 13499 5101 2551 13335 76708 135475 0 5359 13605 31659 2385 274 424 18159 165 218 14265 212675 260 212675 0 31329 491413 13378 256958 13335 486918 0 470891 42 239017 0 68855 170936 50914 20692 283699 360031 170936 39 38374 164 50792 26834 172636 3964...

result:

wrong answer 25th numbers differ - expected: '270', found: '13605'

Pretest #17:

score: 0
Wrong Answer
time: 1465ms
memory: 249816kb

input:

17
4
100000
1 1 1 0
2 2 2 0
1 1 1 0
1 1 1 0
5 1 2 1
5 1 2 1
6 2 2 2
7 1 1 0
8 1 1 3
8 3 4 2
6 1 3 2
9 2 4 1
8 4 4 0
11 1 4 2
10 3 3 1
11 2 5 0
14 2 3 0
17 4 4 2
14 3 4 4
17 1 4 2
19 2 6 6
17 1 1 5
18 1 5 3
23 3 7 2
22 2 3 7
24 4 6 3
23 1 7 4
23 7 7 5
27 5 6 2
26 6 9 5
28 1 7 4
30 1 9 5
29 2 6 6
29 4...

output:

2 1 1 54 51 2 49 59 0 209 1 57 468 105 51 351 935 52 0 100 964 44 1770 364 404 409 211 852 664 155 154 1228 54 5366 154 0 5090 2301 10216 3998 1610 2037 106 8504 2079 6198 11757 0 154 4588 15279 560 4109 714 11703 33902 2447 663 714 663 31306 33162 660 0 24090 73146 0 29662 33992 59956 28806 40467 1...

result:

wrong answer 17th numbers differ - expected: '467', found: '935'

Pretest #18:

score: 0
Wrong Answer
time: 1473ms
memory: 249728kb

input:

18
4
100000
1 1 1 0
2 1 2 1
2 1 2 0
2 1 2 0
3 3 3 1
5 1 3 1
4 2 3 2
7 1 3 1
8 2 4 0
9 1 4 1
8 2 3 3
12 2 5 3
9 2 3 2
11 1 1 1
11 2 4 1
14 1 6 2
15 7 7 0
17 2 4 4
18 6 7 1
17 2 6 6
17 5 5 1
20 2 5 7
22 1 7 3
23 6 10 7
25 4 4 6
25 8 11 7
26 2 10 3
26 6 7 6
27 12 12 2
28 1 1 0
29 8 11 11
32 3 9 12
30 2...

output:

60 2 64 1193 1 1132 3 10615 125 6733 65 61 4893 2023 12940 5964 2023 0 4045 0 14193 2792 13000 5541 24201 4712 27764 54469 19674 27764 47736 30388 0 19673 0 182421 23719 62476 327127 1132 0 4045 389664 121761 102205 130393 1254 31542 88072 0 86819 15487 30512 15487 741196 8756 19008 174733 99458 728...

result:

wrong answer 11th numbers differ - expected: '1', found: '65'

Pretest #19:

score: 0
Wrong Answer
time: 1434ms
memory: 246696kb

input:

19
4
100000
1 1 1 0
1 1 1 0
2 1 1 1
4 1 3 1
1 1 1 0
6 2 2 1
5 2 2 1
6 1 1 0
5 2 3 1
9 1 3 0
10 1 5 3
11 2 4 1
10 2 5 2
13 1 2 2
15 1 3 0
16 1 3 1
16 3 4 6
14 6 6 0
18 6 6 1
19 1 7 2
21 6 6 4
20 9 9 3
21 1 4 5
22 4 8 7
24 2 9 8
26 7 8 0
25 1 2 8
28 1 9 8
26 2 5 3
30 2 2 1
27 9 9 3
30 4 9 2
29 3 7 8
3...

output:

38 1 37 873 5 1 37 18 982 49 39 25 868 1 102 26 1 2647 19 2646 3358 1 2649 11887 3 947 33773 52523 29756 3 37 28887 6060 33924 107702 20834 198219 70370 13299 106407 898155 11449 16186 1739201 3154254 9867 11689 10743 445 6017933 22388 4843 8053 1207325 51664 11606 109633 704 100035 5445 349540 0 21...

result:

wrong answer 21st numbers differ - expected: '712', found: '3358'

Pretest #20:

score: 0
Wrong Answer
time: 1471ms
memory: 249252kb

input:

20
4
100000
1 1 1 0
2 1 1 0
3 1 3 2
4 4 4 1
5 1 5 0
6 1 6 3
4 2 2 1
3 3 3 2
8 1 1 3
7 2 5 0
10 1 3 4
11 1 7 5
9 1 1 3
14 1 3 1
12 4 6 4
16 1 4 7
15 2 4 4
17 2 7 1
19 6 9 6
18 4 6 2
18 2 7 4
18 2 4 3
22 1 7 0
19 3 9 6
20 4 7 7
26 5 10 9
27 2 7 10
27 3 10 6
29 8 9 10
26 7 8 5
31 3 9 1
31 5 13 5
32 10 ...

output:

52 103 49 571 2332 6220 200 2 697 3210 1194 155 1 263 400 245 157 5090 2243 157 311 2 889 204 1839 503 0 3086 0 16476 10276 11442 52 946 10968 155 9236 11365 39152 16528 26031 103 61183 897 53 10690 38914 155 167073 2048 3357 8031 2140 10714 260218 362 20683 2888 7790 9993 0 457 26521 37206 78735 36...

result:

wrong answer 5th numbers differ - expected: '1190', found: '2332'


Final Tests

Test #1:

score: 5
Accepted
time: 3ms
memory: 16192kb

input:

1
4
6
1 1 1 0
2 1 2 0
3 2 3 0
3 2 2 2
5 4 4 3
6
1 1 1 0
1 1 1 0
3 1 1 1
3 1 1 0
4 2 3 1
6
1 1 1 0
2 1 2 1
2 1 2 0
2 2 2 0
2 1 2 0
6
1 1 1 0
2 1 1 1
1 1 1 0
4 1 2 1
5 1 2 2

output:

4 11 5 1 1
1 2 1 2 3
5 1 6 1 6
1 0 2 1 0

result:

ok 20 numbers

Test #2:

score: 0
Wrong Answer
time: 0ms
memory: 18308kb

input:

2
4
300
1 1 1 0
2 1 1 0
1 1 1 0
4 1 2 1
2 2 2 0
6 1 2 1
3 1 3 0
4 1 2 1
6 1 1 1
10 2 3 0
6 2 3 2
11 2 4 0
11 4 5 2
14 4 4 5
10 1 3 2
12 3 4 0
12 2 4 1
15 7 7 5
17 3 4 1
16 4 4 0
21 2 2 5
20 2 4 2
20 2 2 1
23 3 5 1
20 3 4 0
22 4 5 0
26 5 7 1
28 1 8 1
27 2 6 6
26 1 5 2
30 1 3 6
28 1 1 4
28 2 7 6
34 2 ...

output:

34 69 3 1 236 34 104 1 173 749 28 443 36 1 415 2124 271 1 2089 623 589 528 2124 2388 7628 2245 4976 12140 4081 2388 7186 0 193 298 1 444 1 388 0 0 22122 5170 2423 89 32104 236 4511 29441 0 0 54255 17308 12797 20 290 0 28 66702 53864 47192 29310 268147 12140 15625 92547 105295 45281 107649 11412 1007...

result:

wrong answer 15th numbers differ - expected: '69', found: '415'

Test #3:

score: 0
Wrong Answer
time: 0ms
memory: 14336kb

input:

3
4
300
1 1 1 0
2 1 2 0
3 1 3 0
4 1 3 2
4 1 4 2
3 1 2 0
5 1 5 0
4 1 2 3
4 1 4 3
5 1 2 2
8 5 6 3
10 1 3 2
9 4 5 3
13 4 6 1
10 1 4 3
12 4 5 5
13 1 2 1
13 2 3 4
18 6 7 6
17 6 8 3
19 1 3 3
21 9 9 4
22 2 4 5
21 5 7 4
22 1 5 1
23 3 9 3
24 1 1 6
25 1 2 7
28 1 8 6
30 1 11 2
30 4 9 0
32 2 10 3
30 6 8 8
32 6 ...

output:

25 249 447 129 26 274 929 1 16 0 78 1288 26 275 25 52 17 763 1 1951 3700 851 5304 825 2514 1857 8557 0 6382 21070 22144 11767 823 3914 2067 9277 585 8365 106290 46087 2789 274 274 29520 92155 0 65423 0 2789 548943 296893 50586 202166 297855 0 305199 1288 55966 360873 369322 1386236 251794 107012 391...

result:

wrong answer 23rd numbers differ - expected: '3253', found: '5304'

Test #4:

score: 0
Wrong Answer
time: 27ms
memory: 24196kb

input:

4
4
5000
1 1 1 0
2 1 2 1
1 1 1 0
4 1 1 0
1 1 1 0
3 2 3 2
6 1 2 1
5 1 2 0
8 3 3 1
10 1 3 2
8 2 2 0
11 1 5 4
11 3 5 3
13 4 5 3
12 3 3 1
16 1 5 1
13 4 5 5
18 1 5 5
17 1 6 5
17 1 5 4
20 5 7 4
19 1 1 7
23 1 8 3
23 4 6 4
23 8 9 7
24 3 4 2
27 3 6 3
28 5 8 9
26 1 4 4
27 3 10 8
28 8 11 9
31 4 6 3
31 10 10 2
...

output:

3 2 1 2 41 1 40 3 118 235 207 34 42 81 166 332 67 134 2 41 82 33 3613 353 42 3514 356 0 0 2957 121 234 6810 3287 40 2666 6770 628 14228 41764 0 19279 24367 1804 12768 0 15066 4982 51179 666 0 0 153144 17560 67 666 207 138305 0 40 20641 0 133990 88363 0 33568 0 35193 12733 2957 64174 101724 2 518499 ...

result:

wrong answer 10th numbers differ - expected: '117', found: '235'

Test #5:

score: 0
Wrong Answer
time: 36ms
memory: 23648kb

input:

5
4
5000
1 1 1 0
2 2 2 1
3 1 2 2
1 1 1 0
3 1 1 0
4 2 2 3
5 1 1 1
8 3 3 1
8 2 3 2
6 4 4 3
10 2 4 2
10 2 4 2
12 4 5 3
11 2 3 4
11 5 5 1
14 1 3 5
16 1 1 2
15 1 3 0
17 1 4 2
18 3 7 3
21 5 8 6
18 6 7 2
22 1 5 5
24 4 7 4
21 5 7 7
24 2 9 0
26 9 9 2
24 5 9 9
29 8 11 2
30 3 7 4
30 8 9 6
31 5 10 6
30 3 5 4
34...

output:

34 33 0 6 65 0 5 1 4 32 14 7 7 0 265 7 529 97 18 229 95 35 223 362 1 1282 1 26 7605 12284 944 23640 1901 132 22654 10180 853 10753 1815 9030 9900 10204 1084 758 50 1068 1102 0 495 1283 32355 430 194 105520 34 32064 324 62401 74002 51843 1531 9900 106577 110331 547 0 264213 219704 20832 10843 958 335...

result:

wrong answer 16th numbers differ - expected: '0', found: '7'

Test #6:

score: 5
Accepted
time: 457ms
memory: 87460kb

input:

6
4
100000
1 1 1 0
2 2 2 0
3 2 2 0
4 2 2 0
5 3 3 0
6 3 3 0
7 6 6 0
8 3 3 0
9 5 5 0
10 2 2 0
11 4 4 0
12 6 6 0
13 8 8 0
14 6 6 0
15 2 2 0
16 2 2 0
17 17 17 0
18 5 5 0
19 15 15 0
20 2 2 0
21 14 14 0
22 17 17 0
23 10 10 0
24 23 23 0
25 10 10 0
26 17 17 0
27 23 23 0
28 21 21 0
29 29 29 0
30 7 7 0
31 21 ...

output:

13 116 1159 11577 150385 1654119 16540031 198480359 787928493 734581969 103223677 120676063 963754385 618704320 378636756 206516872 241703175 693677871 68103114 817225791 671888130 60162705 601476665 456558188 30918290 836035627 422508580 961059777 721412290 780076554 866081801 542037914 961741065 6...

result:

ok 399996 numbers

Test #7:

score: 5
Accepted
time: 744ms
memory: 132436kb

input:

7
4
100000
1 1 1 0
1 1 1 0
1 1 1 0
1 1 1 0
5 2 2 0
5 2 2 0
7 1 1 0
8 1 1 0
6 1 1 0
7 3 3 0
9 3 3 0
12 2 2 0
10 2 2 0
13 1 1 0
13 4 4 0
13 7 7 0
15 1 1 0
15 7 7 0
16 7 7 0
19 1 1 0
18 8 8 0
19 2 2 0
23 1 1 0
23 5 5 0
24 8 8 0
23 6 6 0
27 3 3 0
28 4 4 0
26 12 12 0
29 6 6 0
30 1 1 0
31 12 12 0
30 9 9 0...

output:

1 1 1 21 1 376 9022 162020 2 1 3879458 77588784 1 475771479 9043 1 475771500 836010287 21 836010287 21 723456114 723627157 3879458 171043 462547233 193433576 974019581 162021 821331611 162021 376 162020 686601685 418942555 31199510 217891022 462547233 836010287 944144826 217891022 575663750 44315401...

result:

ok 399996 numbers

Test #8:

score: 0
Wrong Answer
time: 603ms
memory: 104744kb

input:

8
4
100000
1 1 1 0
2 2 2 0
3 2 2 1
4 2 2 2
5 3 3 0
6 6 6 2
7 1 1 6
8 8 8 2
9 1 1 6
10 2 2 3
11 4 4 2
12 6 6 5
13 2 2 11
14 1 1 6
15 7 7 4
16 7 7 3
17 14 14 15
18 12 12 12
19 17 17 3
20 20 20 11
21 5 5 7
22 12 12 3
23 14 14 10
24 3 3 1
25 23 23 10
26 5 5 18
27 5 5 25
28 18 18 1
29 2 2 14
30 23 23 3
3...

output:

7 13 12 5 18 5 4 25 54 29 33 62 57 81 161 136 490 521 525 512 565 429 400 1905 1340 1327 816 399 1567 1567 3130 6248 3118 1665 4995 12575 15686 31315 63146 60457 58792 176322 173283 287774 287253 287196 287163 285498 284171 281041 281034 796658 509405 337689 681501 442053 438935 433940 433990 433983...

result:

wrong answer 9th numbers differ - expected: '24', found: '54'

Test #9:

score: 0
Wrong Answer
time: 993ms
memory: 180204kb

input:

9
4
100000
1 1 1 0
1 1 1 0
1 1 1 0
3 1 1 0
4 2 2 1
6 2 2 2
6 1 1 2
8 3 3 2
9 1 1 4
8 4 4 0
9 4 4 0
12 6 6 3
13 3 3 4
13 6 6 3
15 5 5 0
15 2 2 7
15 4 4 2
17 5 5 2
18 5 5 0
18 4 4 6
19 2 2 8
22 8 8 9
23 3 3 10
24 6 6 12
25 7 7 13
24 1 1 11
27 3 3 7
27 12 12 2
28 4 4 0
30 3 3 9
31 15 15 15
32 1 1 7
31 ...

output:

1 1 15 1 14 0 27 57 0 1 42 27 0 53 27 95 114 178 57 0 121 26 26 53 0 26 78 14 78 52 26 78 178 63 15 0 37 68 215 189 104 26 11 95 0 401 0 0 775 374 0 0 337 791 0 53 602 335 0 78 508 0 0 482 334 271 121 605 52 0 1132 26 1132 1132 1169 0 57 1300 27 1085 215 27 1795 95 2890 0 10728 374 10999 53 0 9699 1...

result:

wrong answer 7th numbers differ - expected: '13', found: '27'

Test #10:

score: 5
Accepted
time: 672ms
memory: 100332kb

input:

10
4
100000
1 1 1 0
2 1 1 0
3 3 3 0
4 3 4 0
5 3 5 0
6 1 4 0
7 5 5 0
8 5 7 0
9 3 6 0
10 6 10 0
11 1 2 0
12 8 11 0
13 4 12 0
14 2 12 0
15 7 10 0
16 6 8 0
17 13 15 0
18 8 9 0
19 2 6 0
20 8 14 0
21 3 18 0
22 11 18 0
23 5 11 0
24 6 12 0
25 3 24 0
26 13 23 0
27 3 8 0
28 14 22 0
29 4 26 0
30 1 5 0
31 13 17...

output:

16 527 25807 1883910 167667973 634982620 705207129 488881034 887725160 151025554 347960978 855383206 80305903 380559379 538908054 777587576 260990688 523673420 353610155 624705377 700258326 228676702 200177699 984634103 68249951 263072670 517709689 650106087 34684922 592160972 944601706 376074738 79...

result:

ok 399996 numbers

Test #11:

score: 5
Accepted
time: 1172ms
memory: 188036kb

input:

11
4
100000
1 1 1 0
2 1 2 0
3 1 2 0
3 1 2 0
5 3 4 0
5 1 3 0
5 2 3 0
8 1 3 0
9 2 5 0
10 3 5 0
11 4 6 0
10 1 3 0
11 6 8 0
13 4 8 0
13 2 7 0
14 1 3 0
17 3 8 0
17 5 7 0
19 10 11 0
19 1 2 0
20 5 12 0
22 12 12 0
22 8 10 0
23 6 14 0
23 2 8 0
25 2 9 0
27 6 9 0
26 9 15 0
29 3 10 0
30 9 9 0
30 12 13 0
32 14 1...

output:

37 2478 2515 242769 38 245284 32040440 39124800 942462595 336524633 32285687 63297973 516597219 32285725 15628766 418384838 352153362 613054463 541763722 33194948 718423411 374189456 71408009 227001638 334965261 356495372 886316800 521955760 368374612 227507583 587492770 498900953 709154717 10323060...

result:

ok 399996 numbers

Test #12:

score: 5
Accepted
time: 1154ms
memory: 186048kb

input:

12
4
100000
1 1 1 0
2 1 2 0
3 2 3 0
4 1 3 0
2 1 1 0
4 2 2 0
3 1 2 0
8 1 4 0
8 1 3 0
5 2 5 0
9 1 4 0
10 3 5 0
11 1 6 0
11 3 6 0
11 3 3 0
14 2 6 0
17 3 7 0
14 2 4 0
14 4 6 0
18 2 8 0
18 6 9 0
21 8 10 0
22 5 5 0
20 6 8 0
22 1 4 0
24 3 9 0
26 3 8 0
25 3 3 0
24 6 7 0
25 5 9 0
27 2 9 0
32 4 6 0
32 9 11 0
...

output:

69 7796 1278127 262008169 69 7796 39327 94385 55058 777304836 141577 7866 482180153 1285993 1278127 465685418 825856966 42346779 575383498 990228081 154169563 7866 833831197 726620149 749228357 498747852 817824963 482180153 41068652 699428075 474778269 447467594 402643074 564999930 7866 869370470 84...

result:

ok 399996 numbers

Test #13:

score: 0
Wrong Answer
time: 901ms
memory: 125288kb

input:

13
4
100000
1 1 1 0
2 1 2 1
3 1 2 2
4 1 3 2
5 1 5 4
6 1 4 4
7 6 6 1
8 3 7 5
9 3 4 4
10 5 6 2
11 6 9 4
12 5 11 9
13 1 3 4
14 6 10 10
15 4 6 8
16 3 8 6
17 1 9 3
18 3 13 8
19 3 11 10
20 2 4 11
21 12 13 0
22 13 17 20
23 9 17 1
24 10 11 16
25 22 25 9
26 5 9 4
27 12 27 26
28 13 13 22
29 8 23 1
30 21 23 19...

output:

25 24 47 48 71 122 194 169 263 547 428 238 552 1527 1530 2383 10138 23337 18909 12748 44668 44236 45953 41913 51168 339241 585551 583274 589247 471494 771024 1353870 1642216 14901714 47781416 26242762 4866097 4918480 4918335 23194275 28094304 130637987 258995391 256363737 190431441 285400210 1898453...

result:

wrong answer 3rd numbers differ - expected: '23', found: '47'

Test #14:

score: 0
Wrong Answer
time: 1441ms
memory: 249884kb

input:

14
4
100000
1 1 1 0
1 1 1 0
1 1 1 0
4 1 2 1
1 1 1 0
5 1 1 2
6 1 1 0
6 2 2 1
5 2 3 2
5 1 2 1
7 2 2 1
8 1 2 1
11 2 4 1
11 4 4 2
15 2 4 0
13 1 3 3
15 1 3 3
18 2 4 4
16 2 5 5
16 4 4 0
18 6 6 4
22 4 4 5
18 2 5 5
20 5 6 5
24 1 6 4
25 5 6 2
22 3 4 1
28 3 7 0
25 2 4 4
29 1 6 4
27 3 8 0
28 5 5 7
30 2 3 1
33 ...

output:

1 1 68 67 2 0 4 1 1 337 67 2 136 200 739 0 131 0 200 67 131 0 200 136 135 1882 1939 1340 0 537 3896 62 336 8322 0 8060 2285 61 799 2935 18384 67 995 61 0 2686 10731 0 462 0 19249 42026 14061 19317 65489 131 0 130773 672 83391 0 2805 19048 130369 537 604 61 19962 13496 279442 19722 7604 0 404 3407 23...

result:

wrong answer 15th numbers differ - expected: '539', found: '739'

Test #15:

score: 0
Wrong Answer
time: 1476ms
memory: 247384kb

input:

15
4
100000
1 1 1 0
1 1 1 0
2 1 2 0
1 1 1 0
4 1 3 1
3 2 2 1
5 1 2 0
5 2 2 1
7 2 3 1
9 1 2 0
9 2 3 0
8 1 2 1
9 1 2 0
10 3 3 2
11 2 3 1
13 2 3 3
15 3 5 4
14 4 4 2
16 2 4 0
20 4 5 5
18 1 6 4
21 2 5 6
19 4 5 4
23 3 7 4
23 3 5 0
25 3 3 8
26 4 8 8
26 3 7 6
28 6 9 5
26 6 9 2
29 8 9 7
29 6 10 1
31 4 4 5
34 ...

output:

3 5 8 46 4 4 93 44 13 354 47 46 92 7 264 0 6 2 528 84 6 40 1 444 4224 0 0 533 708 2545 90 753 1702 1742 398 0 44 1033 993 0 6071 14428 13312 11286 8502 5767 8972 11645 6906 7421 2553 5585 935 25622 4264 31985 30625 5814 95938 35209 36530 75933 24102 0 9832 0 41494 31181 25597 7370 238836 40224 43463...

result:

wrong answer 10th numbers differ - expected: '310', found: '354'

Test #16:

score: 0
Wrong Answer
time: 1452ms
memory: 245472kb

input:

16
4
100000
1 1 1 0
1 1 1 0
1 1 1 0
1 1 1 0
5 2 2 1
5 1 1 0
5 1 2 1
4 1 2 0
7 1 2 2
6 1 2 0
7 2 3 0
12 1 4 0
11 1 1 2
13 1 4 0
14 3 3 4
12 1 4 0
16 2 2 1
18 1 7 5
19 6 6 5
20 4 5 1
17 2 5 4
22 1 3 4
23 1 3 3
21 5 5 9
22 3 4 3
24 1 7 3
23 2 5 1
27 2 5 4
25 2 8 7
29 6 7 3
27 5 9 6
30 10 11 6
30 1 2 3
...

output:

1 1 2 60 3 355 1 3 0 65 1360 3551 2 5326 5 1828 66 74 16 13 52 351 12001 6 355 24797 3595 32364 322 19393 831 271 0 3603 126599 150825 208 383 311 36846 149465 20923 0 0 145861 145992 29970 12352 72753 60712 4208 37201 73168 270338 2433 0 291313 643901 36798 1124357 108475 88555 16268 376431 2196957...

result:

wrong answer 15th numbers differ - expected: '2', found: '5'

Test #17:

score: 0
Wrong Answer
time: 1460ms
memory: 251340kb

input:

17
4
100000
1 1 1 0
1 1 1 0
1 1 1 0
2 1 1 0
2 1 2 1
4 1 1 0
3 1 2 1
7 2 3 0
8 3 3 0
6 1 3 0
9 2 3 0
8 1 3 1
9 3 4 2
11 3 4 3
13 2 3 0
12 4 5 4
16 1 2 1
15 1 2 2
19 2 5 5
16 3 5 4
19 1 4 5
21 3 4 5
23 3 5 0
21 1 6 1
23 3 3 2
25 1 2 2
26 1 3 0
26 5 6 6
27 2 4 3
28 1 5 8
31 2 3 5
29 3 7 1
32 7 10 10
32...

output:

4 54 4 4 3 19 53 34 1 9 24 159 5 1 369 1 159 0 0 103 0 48 581 1005 417 369 1033 0 369 1498 740 732 1 679 898 580 3783 1217 0 2736 3736 893 2237 1577 2182 4260 2915 54 0 1419 524 2182 786 8764 581 10144 5174 478 212 3680 30641 1077 212 30060 0 8654 13154 23573 212 27282 5685 1735 14928 0 24079 106106...

result:

wrong answer 15th numbers differ - expected: '316', found: '369'

Test #18:

score: 0
Wrong Answer
time: 1487ms
memory: 241008kb

input:

18
4
100000
1 1 1 0
1 1 1 0
3 1 2 1
2 1 2 0
2 2 2 0
5 1 3 1
6 1 1 1
6 2 3 2
6 1 3 2
9 1 4 1
10 2 3 1
12 1 3 0
10 1 4 2
11 2 5 0
12 4 5 1
14 2 4 1
15 5 6 2
16 4 5 5
18 3 3 5
18 1 6 4
18 3 4 4
21 2 4 3
21 4 7 4
23 7 9 3
23 1 5 3
25 3 5 3
26 5 6 2
25 1 7 4
29 3 4 6
30 4 11 2
29 1 3 3
29 1 5 6
32 9 12 0...

output:

47 2 1 96 44 48 0 40 3 2679 183 230 95 2627 48 94 2495 0 0 2447 0 37572 131 40043 10612 5122 5306 37324 2810 47951 39005 47 125490 66026 47 125358 18075 84 125227 12546 275399 0 45141 372392 2811 341217 2811 18076 253038 82741 579372 25645 491425 18076 8064 797744 87995 227539 0 1149686 2811 230389 ...

result:

wrong answer 44th numbers differ - expected: '288291', found: '372392'

Test #19:

score: 0
Wrong Answer
time: 1477ms
memory: 243592kb

input:

19
4
100000
1 1 1 0
1 1 1 0
1 1 1 0
2 1 2 1
2 2 2 0
3 1 1 1
4 1 1 0
8 1 3 0
7 2 2 0
8 2 2 2
8 1 1 1
11 2 4 3
13 1 3 2
13 1 3 1
12 1 2 0
15 2 5 1
16 4 5 0
18 4 5 3
17 2 4 0
19 3 6 5
21 4 8 2
21 2 6 4
23 7 8 6
22 1 4 3
22 1 3 2
24 1 8 1
25 5 5 1
26 3 3 2
26 1 10 5
30 8 9 0
29 3 5 2
29 3 6 0
31 4 7 10
...

output:

3 1 43 1 1 0 515 559 1 1 427 1 515 1076 1884 562 942 898 1078 340 9674 2015 1073 1884 7614 7021 942 3758 3978 5086 10912 11854 164 3980 28792 25939 558 4787 559 60600 4820 2870 1 8345 39117 30843 43 0 17851 898 94970 59007 898 211163 10283 0 0 0 230639 116314 56377 27075 171002 30416 17548 191173 56...

result:

wrong answer 30th numbers differ - expected: '1108', found: '5086'

Test #20:

score: 0
Wrong Answer
time: 1456ms
memory: 230536kb

input:

20
4
100000
1 1 1 0
1 1 1 0
1 1 1 0
3 1 2 1
5 1 1 0
4 1 2 1
5 1 1 2
8 4 4 0
8 1 2 3
10 3 4 0
11 5 5 3
10 3 4 2
11 2 3 3
12 1 7 6
14 1 2 1
15 5 8 3
15 1 2 6
17 5 8 4
17 3 4 0
18 7 9 6
20 1 10 2
21 1 4 9
22 1 9 9
23 3 8 6
25 3 7 8
24 2 7 6
27 1 9 8
27 12 12 8
29 3 11 3
30 2 6 4
31 6 14 8
30 6 8 3
33 8...

output:

1 44 2 43 43 1 85 1 41 172 85 87 0 41 172 945 253 213 1155 676 898 1264 4282 420 0 2425 41 1314 11917 2520 467 5975 945 2889 1149 4361 3841 4189 2770 1456 7228 0 9778 0 0 4663 0 4450 39283 31166 21095 0 9175 11317 1154 85 763 0 5008 89925 109909 0 55256 47379 0 0 15112 169 70185 52353 2141 32312 120...

result:

wrong answer 7th numbers differ - expected: '42', found: '85'